Skip to content

Is the ENABLED flag being honored? #98

Closed

Description

@BillBuilt

I have some jobs that have ENABLED=0 and the jobs are still being ran. Checking the code, I don't see where the ENABLED parameter is being checked before execution. Since our jobs are read from a MySQL database, I can easily filter out any with ENABLED=0 but I just wanted to confirm if this was an issue or if I was missing something here.

Thanks

Activity

  1. hellogerard commented on Feb 13, 2018

    @hellogerard
    Member

    No, it should work. The line is here:

    if (!$this->config['enabled']) {
    . If it's not, then this is a bug.

  2. BillBuilt commented on Feb 13, 2018

    @BillBuilt
    Author

    Hi. Thanks for replying. I was just following the code from when i issue $jobby->run(); Based on the example in jobby-pdo.php.

    I don't see where it calls shouldRun() or does any $config['enabled'] check. Should I be using a different class other than $jobby = new \Jobby\Jobby(); ?

    \Jobby\Jobby::run() defers to \Jobby\Jobby::runUnix(). I cannot find where this parameters is checked in any of that.

    Thanks again!

  3. BillBuilt commented on Mar 15, 2018

    @BillBuilt
    Author

    I was capitalizing as a way of focusing on the issue, not literally in the code. Consider the following example from the jobby-pdo.php example file:

    $jobbiesStmt = $dbh->query("SELECT * FROM $dbhJobbiesTableName");
    $jobbies = $jobbiesStmt->fetchAll(PDO::FETCH_ASSOC);
    $jobby = new \Jobby\Jobby();
    foreach ($jobbies as $job) {
    // Filter out each value, which is not set (for example, "maxRuntime" is not defined in the job).
    $job = array_filter($job);
    try {
    $job['closure'] = $serializer->unserialize($job['command']);
    unset($job['command']);
    } catch (SuperClosure\Exception\ClosureUnserializationException $e) {
    }
    $jobName = $job['name'];
    unset($job['name']);
    $jobby->add($jobName, $job);
    }
    $jobby->run();

    I had to change the select to:

    $jobbiesStmt = $dbh->query("SELECT * FROM $dbhJobbiesTableName WHERE enabled = 1");

    in order to keep disabled tasks from running, as it would seem that the enabled flag was not being checked properly elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions