0

I'm using single file to put it as cron in my system. The main idea of doing that is to prevent the cron working 24/7.

I have these lines in my file

if(isActivePlugin('plugin', 'first_plugin')) {
    if($expire_one <= $time) {
        $db->query("UPDATE table SET column='0'");
        $db->query("UPDATE table_2 SET column='0' WHERE column='1'");
        exit(); 
    }
}
if(isActivePlugin('plugin', 'second_plugin')) {
    if($expire_twoo <= $time) {
        $db->query("UPDATE table SET column='0'");
        $db->query("UPDATE table_3 SET column='0' WHERE column='1'");
        exit(); 
    }
}

But the second one never works and does not check & update the database. Even if I remove the plugin check it still doesn't work.

Noah
  • 1,528
  • 12
  • 19
zay7sev
  • 129
  • 4

1 Answers1

1

The call to exit() in your first if statement is likely the problem. You probably don't want to skip deactivating the second plugin just because you had to deactivate the first plugin.

Generally it is a bad idea to have multiple exit points from a script (or return statements from a function).

See Should a function have only one return statement? for other strategies

Community
  • 1
  • 1
Noah
  • 1,528
  • 12
  • 19