From bd881794196659501add5cbb72360e5643e76edf Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 30 Sep 2017 11:19:46 +0000 Subject: [PATCH] Add additional checks for the worker --- boot.php | 5 +++++ doc/htconfig.md | 1 + include/dba.php | 18 ++++++++++++++++++ include/poller.php | 4 +++- mod/admin.php | 9 +++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 419a634fa2..ba692405a6 100644 --- a/boot.php +++ b/boot.php @@ -1086,6 +1086,11 @@ function proc_run($cmd) { $parameters = json_encode($argv); $found = dba::exists('workerqueue', array('parameter' => $parameters, 'done' => false)); + // Quit if there was a database error - a precaution for the update process to 3.5.3 + if (dba::errorNo() != 0) { + return; + } + if (!$found) { dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority)); } diff --git a/doc/htconfig.md b/doc/htconfig.md index d3d4dad6ef..cbb76a38c3 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -47,6 +47,7 @@ Example: To set the directory value please add this line to your .htconfig.php: * **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10. * **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers * **ignore_cache** (Boolean) - For development only. Disables the item cache. +* **ipv4_resolve** (Boolean) - Resolve IPV4 addresses only. Don't resolve to IPV6. Default value is false. * **like_no_comment** (Boolean) - Don't update the "commented" value of an item when it is liked. * **local_block** (Boolean) - Used in conjunction with "block_public". * **local_search** (Boolean) - Blocks search for users who are not logged in to prevent crawlers from blocking your system. diff --git a/include/dba.php b/include/dba.php index bc38029351..a10f18aba7 100644 --- a/include/dba.php +++ b/include/dba.php @@ -1259,6 +1259,24 @@ class dba { return $data; } + /** + * @brief Returns the error number of the last query + * + * @return string Error number (0 if no error) + */ + public static function errorNo() { + return self::$dbo->errorno; + } + + /** + * @brief Returns the error message of the last query + * + * @return string Error message ('' if no error) + */ + public static function errorMessage() { + return self::$dbo->error; + } + /** * @brief Closes the current statement * diff --git a/include/poller.php b/include/poller.php index aa8763af33..312347d71a 100644 --- a/include/poller.php +++ b/include/poller.php @@ -248,7 +248,9 @@ function poller_execute($queue) { poller_exec_function($queue, $funcname, $argv); $stamp = (float)microtime(true); - dba::update('workerqueue', array('done' => true), array('id' => $queue["id"])); + if (dba::update('workerqueue', array('done' => true), array('id' => $queue["id"]))) { + Config::set('system', 'last_poller_execution', datetime_convert()); + } $poller_db_duration = (microtime(true) - $stamp); } else { logger("Function ".$funcname." does not exist"); diff --git a/mod/admin.php b/mod/admin.php index 49596578b8..2fb2fea830 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -626,6 +626,15 @@ function admin_page_summary(App $a) { $warningtext[] = t('The database update failed. Please run "php include/dbstructure.php update" from the command line and have a look at the errors that might appear.'); } + $last_worker_call = Config::get('system', 'last_poller_execution', false); + if (!$last_worker_call) { + $showwarning = true; + $warningtext[] = t('The worker was never executed. Please check your database structure!'); + } elseif ((strtotime(datetime_convert()) - strtotime($last_worker_call)) > 60 * 60) { + $showwarning = true; + $warningtext[] = sprintf(t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.'), $last_worker_call); + } + $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`"); $accounts = array( array(t('Normal Account'), 0),