Пример #1
0
    /**
     * Runs the cron.
     *
     * Triggers {@link \Mibew\EventDispatcher\Events::CRON_RUN} event.
     *
     * @param Request $request Incoming request.
     * @return string Rendered page content.
     */
    public function runAction(Request $request)
    {
        $cron_key = $request->query->get('cron_key', '');

        // Check cron security key
        if ($cron_key != Settings::get('cron_key')) {
            // Return an empty response
            return '';
        }

        // Determine use or not quiet mode
        $quiet = $request->query->has('q');

        set_time_limit(0);

        // Remove stale cached items
        $this->getCache()->purge();

        // Run cron jobs of the core
        calculate_thread_statistics();
        calculate_operator_statistics();
        calculate_page_statistics();

        // Trigger cron event
        $dispatcher = EventDispatcher::getInstance();
        $dispatcher->triggerEvent(Events::CRON_RUN);

        // Update time of last cron run
        Settings::set('_last_cron_run', time());

        if (!$quiet) {
            // TODO: May be localize it
            return 'All cron jobs done.';
        }
    }
Пример #2
0
 /**
  * Performs all periodical actions.
  *
  * @return boolean True if all periodical actions are done and false
  * otherwise.
  */
 public function run()
 {
     try {
         set_time_limit(0);
         // Update time of last cron run
         Settings::set('_last_cron_run', time());
         // Remove stale cached items
         $this->cache->purge();
         // Run cron jobs of the core
         calculate_thread_statistics();
         calculate_operator_statistics();
         calculate_page_statistics();
         // Trigger cron event
         $dispatcher = EventDispatcher::getInstance();
         $dispatcher->triggerEvent(Events::CRON_RUN);
         if (Settings::get('autocheckupdates') == '1') {
             // Run the update checker
             $update_checker = $this->getUpdateChecker();
             if (!$update_checker->run()) {
                 $this->errors = array_merge($this->errors, $update_checker->getErrors());
                 return false;
             }
         }
     } catch (\Exception $e) {
         $this->log[] = $e->getMessage();
         return false;
     }
     return true;
 }
Пример #3
0
 /**
  * Performs all periodical actions.
  *
  * @return boolean True if all periodical actions are done and false
  * otherwise.
  */
 public function run()
 {
     try {
         set_time_limit(0);
         // Remove stale cached items
         $this->cache->purge();
         // Run cron jobs of the core
         calculate_thread_statistics();
         calculate_operator_statistics();
         calculate_page_statistics();
         // Trigger cron event
         $dispatcher = EventDispatcher::getInstance();
         $dispatcher->triggerEvent(Events::CRON_RUN);
         // Update time of last cron run
         Settings::set('_last_cron_run', time());
     } catch (\Exception $e) {
         $this->log[] = $e->getMessage();
         return false;
     }
     return true;
 }