Hi,

I have the following lines (amongst others) in my config file for making a cronjob:
module: marktwacht
callback: marktwacht_check_opdracht
callback arguments: array('84','84')
pass job argument: TRUE

and the following function:

function marktwacht_check_opdracht($job, $args) {
...
}

When i run the cronjob I get the following error:
Too few arguments to function marktwacht_check_opdracht(), 1 passed and exactly 2 expected.

as you can see ive specified to pass the job argument and an extra argument (array). But for some reason it is not passed.
What am i doing wrong?

Kind regards,
Mark

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Mark aka Dark created an issue. See original summary.

Mark aka Dark’s picture

Issue summary: View changes
umed91’s picture

@mark were you able to get this working?

murz’s picture

@Mark can you describe where did you set callback arguments? I can't see such parameter in config/schema/ultimate_cron.schema.yml file.

e.bogatyrev’s picture

Status: Active » Needs review
StatusFileSize
new15.75 KB

Hi everyone,
Please review the patch.
I suggest to use callback arguments as a string with line ending separation in the Cron Job configuration form since we don't actually know the final amount of them. It depends on the particular implementation of each callback. Then this string will be parsed, split to arguments and passed to callback.

Status: Needs review » Needs work

The last submitted patch, 5: ultimate_cron-callback-arguments-2909191-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

e.bogatyrev’s picture

e.bogatyrev’s picture

Status: Needs work » Needs review
nikolabintev’s picture

I just set it up on a project and it works well. I believe that this is e must-have feature.

nikolabintev’s picture

Status: Needs review » Reviewed & tested by the community
berdir’s picture

Status: Reviewed & tested by the community » Needs work

This has a few conflicts. I have some concerns about the argument structure, XSS filtering doesn't seem relevant here as it's not displayed.

The schema talks about comma separated values, but according to tests and code, it's really line breaks.

What about storing arguments as a sequence, then only the form needs to process them into an array and runtime can just pass it through directly as an array?

e.bogatyrev’s picture

Status: Needs work » Needs review
StatusFileSize
new13.21 KB

Hi @berdir,

Thanks for findings, they make sense.
Please take a look and review updated patch or MR

berdir’s picture

Category: Support request » Feature request
Status: Needs review » Needs work

> What about storing arguments as a sequence, then only the form needs to process them into an array and runtime can just pass it through directly as an array?

This hasn't been addressed yet.

To be honest, I'm not sure this should even be exposed in the UI. We don't allow to set/change the callback, also for security reasons, so this should just display the arguments as well.

lisotton made their first commit to this issue’s fork.

lisotton’s picture

Status: Needs work » Needs review

I changed to use a sequence instead of a string and changed the form to show the arguments as read-only, like it is done for the callback.

I agree that there is no point to allow change the parameters, if the callback is not allowed to be changed from the UI.

ronaldmulero’s picture

MR !40 diff works for me using ultimate_cron 8.x-2.0-beta1
Thanks @lisotton!

...
module: my_module
callback: my_module_function
callback_arguments:
  - this
  - that
  - the_other
...
lisotton’s picture

Status: Needs review » Reviewed & tested by the community

Changing to RTBC as per @ronaldmulero comment.

johnle’s picture

Version: 8.x-2.x-dev » 8.x-2.0-beta1
StatusFileSize
new22.8 KB

Posting the latest patch from the latest MR posted using ultimate_cron 8.x-2.0-beta1.

johnle’s picture

Sorry, that patch was incorrect, here is the correct one created directly from the diff in that MR.

liam morland’s picture

Version: 8.x-2.0-beta1 » 8.x-2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll