First of all, thank you for your patience. I am getting to grips with PHP coding after a long while. I have finished the famous Cake tutorial and am now continuing with what I know and creating new solutions.
I am creating a voting system. When the current user votes on a suggestion (sames as an article), a new entry needs to be saved in a related cross table between suggestions and users. I thought that the public function link() is the best way to do this. See the function in the ArticlesController below. However, I get an error message "Call to undefined method Authentication\Identity::isNew()". This suggests I have not taken care of some authorization around this call. Can anyone tell me what I missed? Or whether there is a better way to do this?
Note; I do know it looks strange that when I already have my one suggestion I am working through the suggestions table, but I could not find a way for one entity to directly link it to an associated entity (ie I found no link function for entities). It would be nice to hear if this can be done in a leaner way.
public function upvote($id = null)
{
$suggestion = $this->Suggestions->get($id);
$this->Authorization->skipAuthorization();
$user = $this->request->getAttribute('identity');
//Create link between current suggestions and current user in the suggestions_users table
$suggestionsTable = $this->getTableLocator()->get('Suggestions');
$suggestionsTable->Users->link($suggestion,[$user]);
if ($voteTable->save($vote)) {
// The foreign key value was set automatically.
$this->Flash->success(__('Your vote has been cast.'));
}
else {
$this->Flash->error(__('The vote could not be cast. Apologies for the technical issue.'));
}
}
Stack trace;
2020-11-12 13:46:52 Error: [Error] Call to undefined method Authentication\Identity::isNew() in C:\wamp64\www\cake\vendor\cakephp\authorization\src\IdentityDecorator.php on line 125
Stack Trace:
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\ORM\Association\BelongsToMany.php:1323
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\ORM\Association\BelongsToMany.php:864
- C:\wamp64\www\cake\src\Controller\SuggestionsController.php:143
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Controller\Controller.php:529
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Controller\ControllerFactory.php:79
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\BaseApplication.php:251
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:77
- C:\wamp64\www\cake\vendor\cakephp\authorization\src\Middleware\AuthorizationMiddleware.php:129
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\authentication\src\Middleware\AuthenticationMiddleware.php:122
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Routing\Middleware\RoutingMiddleware.php:166
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Middleware\CsrfProtectionMiddleware.php:156
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Middleware\BodyParserMiddleware.php:159
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Routing\Middleware\RoutingMiddleware.php:166
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Routing\Middleware\AssetMiddleware.php:68
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Error\Middleware\ErrorHandlerMiddleware.php:121
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\debug_kit\src\Middleware\DebugKitMiddleware.php:60
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:73
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Runner.php:58
- C:\wamp64\www\cake\vendor\cakephp\cakephp\src\Http\Server.php:90
- C:\wamp64\www\cake\webroot\index.php:40
Request URL: /suggestions/upvote/1
Referer URL: http://localhost:8000/cake/suggestions
Related
I have a Comments db table
var c = new comment
{
name = message,
userID = userId
};
this.commentDataContext.Comments.InsertOnSubmit(c);
this.commentDataContext.SubmitChanges();
this.logger.WriteInfo($"Message: {c.name}");
this.logger.WriteInfo($"CommentId: {c.id}");
Within my log files I do receive an CommentId
2019-11-04 11:06:28,042 [79] INFO Root [(null)] - CommentId: 271609
However when I do a query on the db table it returns nothing.
Is it rolling back? I have looked at the event viewer but see no errors. As this is on a live server, I hope to not go down the route of turning on tracking as its constantly being hit, so will be like trying to find a needle in a hay stack. Is there another way I can work out why it thinks it has inserted but then roll-backed the change?
I'm using saltstack on my servers. I did a simple schedule:
job1:
schedule.present:
- function: state.apply
- seconds: 1800
- splay: 5
Now I want to get the output of the schedule back on my master
(or on my minion but I just like to know the best way)
I don't really know how to use salt mine or returners or what is best preferred for my needs.
thank you :)
Job data return and job metadata
By default, data about jobs runs from the Salt scheduler is returned to the master.
It can therefore be useful to include specific data to differentiate a job from other jobs. By using the metadata parameter a value can be associated with a scheduled job, although these metadata values aren't used in the execution of the job they can be used to search for specific job later.
job1:
schedule.present:
- function: state.apply
- seconds: 1800
- splay: 5
- metadata:
foo: bar
An example job search on the salt-master might look similar to this:
salt-run jobs.list_jobs search_metadata='{"foo": "bar"}'
Take a look at the salt.runners.jobs documentation for more examples.
Scheduler with returner
The schedule.present function includes a parameter to set a returner to use to return the results of the scheduled job. You could for example use the pushover returner:
job1:
schedule.present:
- function: state.apply
- seconds: 1800
- splay: 5
- returner: pushover
Take a look at the returners documentation for a full list of of builtin returners and usage information.
Using:
- Minecraft 1.7.10
- Forge 10.13.4.1614
- [Mod] Dr. Zhark's Mo Creatures (not enough rep to post link)
- [Mod] Realistic World Generator (RWG) 2
- [Mod] Dr. Zhark's Custom mob Spawner (CMS) (not enough rep to post link)
I attempted to modify the config files in the .minecraft folder to add all of the RWG Biomes to the acceptable spawn locations for the MoCreatures mod via CMS. I modified the EntityBiomeGroups.cfg file found at
C:...\AppData\Roaming.minecraft\config\CustomSpawner\overworld
And just for an example of the code used in the file:
S:MOC_MEDIUMFISH_DEFAULT <RWG|rwg_oceanIce:RWG|rwg_oceanCold:RWG|rwg_oceanTemperate:RWG|rwg_oceanHot:RWG|rwg_oceanWet:RWG|rwg_oceanOasis:MC|Swampland:MC|MushroomIslandShore:MC|Beach:MC|Stone Beach:MC|Cold Beach:MC|Swampland M>
After modifying the file, and checking multiple times to ensure that everything was typed in correctly, I received this error while attempting to load any minecraft world:
Description: Exception in server tick loop
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1954)
at drzhark.customspawner.utils.CMSUtils.parseName(CMSUtils.java:63)
at drzhark.customspawner.environment.EnvironmentSettings.populateSpawnBiomes(EnvironmentSettings.java:732)
at drzhark.customspawner.environment.EnvironmentSettings.updateSettings(EnvironmentSettings.java:259)
at drzhark.customspawner.utils.CMSUtils.addWorldEnvironment(CMSUtils.java:128)
at drzhark.customspawner.EventHooks.onWorldLoad(EventHooks.java:175)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_156_EventHooks_onWorldLoad_Load.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140)
at net.minecraft.server.integrated.IntegratedServer.func_71247_a(IntegratedServer.java:73)
at net.minecraft.server.integrated.IntegratedServer.func_71197_b(IntegratedServer.java:92)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)
I do not understand this completely. Does it help me find where the error is? Can anybody read this and tell me where I can find it? I'm at a loss here.
May be this mod download is error,
you try reinstall this mod - download here
Using the Java SDK I am creating a load job for just a single record with a fairly complicated schema. When monitoring the status of the load job, it takes a surprisingly long time (but perhaps this is due to working out the schema), but then says:
11:21:06.975 [main] INFO xxx.GoogleBigQuery - Job status (21694ms) create_scans_1384744805079_172221126: DONE
11:24:50.618 [main] ERROR xxx.GoogleBigQuery - Job create_scans_1384744805079_172221126 caused error (invalid) with message
Too many errors encountered. Limit is: 0.
11:24:50.810 [main] ERROR xxx.GoogleBigQuery - {
"message" : "Too many errors encountered. Limit is: 0.",
"reason" : "invalid"
?}
BTW - how do I tell the job that it can have more than zero errors using Java?
This load job does not appear in the list of recent jobs in the console, and as far as I can see, none of the Java objects contains any more details about the actual errors encountered. So how can I pro-grammatically find out what is going wrong? All I can find is:
if (err != null) {
log.error("Job {} caused error ({}) with message\n{}", jobID, err.getReason(), err.getMessage());
try {
log.error(err.toPrettyString());
}
...
In general I am having a difficult time finding good documentation for some of these things and am working it out by trial and error and short snippets of code found on here and older groups. If there is a better source of information than the getting started guides, then I would appreciate any pointers to that information. The Javadoc does not really help and I cannot find any complete examples of loading, querying, testing for errors, cataloging errors and so on.
This job is submitted via a NEWLINE_DELIMITIED_JSON record, supplied to the job via:
InputStream dummy = getClass().getResourceAsStream("/googlebigquery/xxx.record");
final InputStreamContent jsonIn = new InputStreamContent("application/octet-stream", dummy);
createTableJob = bigQuery.jobs().insert(projectId, loadJob, jsonIn).execute();
My authentication and so on seems to work correctly as separate Java code to list the projects, and the datasets in the project all works correctly. So I just need help in working what the actual error is - does it not like the schema (I have records nested within records for instance), or does it think that there is an error in the data I am submitting.
Thanks in advance for any help. The job number cited above is an actual failed load job if that helps any Google staffers who might read this.
It sounds like you have a couple of questions, so I'll try to address them all.
First, the way to get the status of the job that failed is to call jobs().get(jobId), which returns a job object that has an errorResult object that has the error that caused the job to fail (e.g. "too many errors"). The errorStream list is a lost of all of the errors on the job, which should tell you which lines hit errors.
Note if you have the job id, it may be easier to use bq to lookup the job -- you can run bq show <job_id> to get the job error information. If you add the --format=prettyjson it will print out all of the information in the job.
A hint you also might want to consider is to supply your own job id when you create the job -- then even if there is an error starting the job (i.e. the insert() call fails, perhaps due to a network error) you can look up the job to see what actually happened.
To tell BigQuery that some errors are allowed during import, you can use the maxBadResults setting in the load job. See https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/java/latest/com/google/api/services/bigquery/model/JobConfigurationLoad.html#getMaxBadRecords().
I have created my default group in bPermissions and the players that have the default rank can't build, I can't figure out why. I have even added the permission node "bpermissions.build". Here is the groups.yml:
default: default
groups:
default:
permissions:
- bpermissions.build
- essentials.afk
- essentials.afk.auto
- essentials.back
- essentials.home
- essentials.sethome
- essentials.spawn
- essentials.suicide
- mineconomy.balance.check
- mineconomy.bank.account.balance
- plotme.limit.1
- plotme.use.add
- plotme.use.auto
- plotme.use.buy
- plotme.use.protect
- plotme.use.remove
- warptastic.makesign
- warptastic.warp
groups: []
Please Help!
Try using the permission essentials.build
Your bpermissions.build is lowercase... Did you try uppercase?
As in: bPermissions.build
It's not the spawn area they're trying to build in, is it?
For bPermissions, you have to use the groups.yml in plugins/bPermissions/world-name, don't forget to set the other worlds to mirror the original world (same permissions for Nether and what not).
If that's the one you're using: are you SURE there isn't an issue with bPermissions and Essentials butting heads? Often mods won't work properly or certain functions fail to work due to them fighting.
On a side note, is there a reason you don't have the meta/priorities? It doesn't really matter right this second since you only have one group in this example, but add it if you plan on creating other groups like Mods and Admins or w/e.
I didn't need a permission for being able to build, it was enabled to all players by default o.o So I'm assuming that it's Essential permissions making it up or something xD If you want the building ability to be false for bPermissions, you'll have to tell it to be false.