Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callable supplied as array generates error when being added #94

Closed
phinor opened this issue Nov 7, 2019 · 0 comments
Closed

Callable supplied as array generates error when being added #94

phinor opened this issue Nov 7, 2019 · 0 comments

Comments

@phinor
Copy link

phinor commented Nov 7, 2019

Environment

PHP 7.2
composer require peppeocchi/php-cron-scheduler:^3.0

How to Reproduce

$scheduler = new \GO\Scheduler()
$scheduler->call(['MyClass', 'staticMethod']);

Expected Behaviour

The method MyClass::staticMethod() is called every minute.

Observed Behaviour

An error is generated: spl_object_hash() expects parameter 1 to be object, array given on line 162 of Job.php

Possible Solutions

Adjust the if-statement from lines 158 to 163 to read:

if (is_string($command)) {
    $this->id = md5($command);
} elseif (is_array($command)) {
    $this->id = md5(serialize($command));
} else {
    /* @var object $command */
    $this->id = spl_object_hash($command);
}
@phinor phinor changed the title Callable supplied as array is not added when adding job Callable supplied as array generates error when being added Nov 7, 2019
phinor pushed a commit to phinor/php-cron-scheduler that referenced this issue Nov 8, 2019
peppeocchi added a commit that referenced this issue Feb 6, 2020
Fixes #94 by checking for an array parameter when creating a new Job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant