            $WHERE[] = ['NOT' => ['name' => $locks]];
         }

         // Build query for frequency and allowed hour
         $WHERE[] = ['OR' => [
            ['AND' => [
               ['hourmin'   => ['<', $DB->quoteName('hourmax')]],
               'hourmin'   => ['<=', $hour],
               'hourmax'   => ['>', $hour]
            ]],
            ['AND' => [
               'hourmin'   => ['>', $DB->quoteName('hourmax')],
               'OR'        => [
                  'hourmin'   => ['<=', $hour],
                  'hourmax'   => ['>', $hour]
               ]
            ]]
         ]];
         $WHERE[] = ['OR' => [
            'lastrun'   => null,
            new \QueryExpression('unix_timestamp(' . $DB->quoteName('lastrun') . ') + ' . $DB->quoteName('frequency') . ' <= unix_timestamp(now())')
         ]];
      }

      $iterator = $DB->request([
         'SELECT' => [
            '*',
            new \QueryExpression("LOCATE('Plugin', " . $DB->quoteName('itemtype') . ") AS ISPLUGIN")
         ],
         'FROM'   => $this->getTable(),
         'WHERE'  => $WHERE,
         // Core task before plugins
         'ORDER'  => [
            'ISPLUGIN',
            new \QueryExpression('unix_timestamp(' . $DB->quoteName('lastrun') . ')+' . $DB->quoteName('frequency') . '')
         ]
      ]);

      if (count($iterator)) {
         $this->fields = $iterator->next();
         return true;
      }
      return false;
   }
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.