From 39318e299ee36f4c14314b38238390e9b6e007bc Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 30 Oct 2013 20:25:10 -0700 Subject: allow mailsent update locking to unlock after 24 hours. Also don't even try to do a DB update if the build number is 0. Something else will likely fail and likely in some horrible way, but we shouldn't try and update the DB - something is clearly wrong with it. --- boot.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index e97d59f87..aa56aff3d 100755 --- a/boot.php +++ b/boot.php @@ -1174,7 +1174,7 @@ function is_ajax() { function check_config(&$a) { $build = get_config('system','db_version'); - if(! x($build)) + if(! intval($build)) $build = set_config('system','db_version',DB_UPDATE_VERSION); $saved = get_config('system','urlverify'); @@ -1207,6 +1207,10 @@ function check_config(&$a) { if($build != DB_UPDATE_VERSION) { $stored = intval($build); + if(! $stored) { + logger('Critical: check_config unable to determine database schema version'); + return; + } $current = intval(DB_UPDATE_VERSION); if(($stored < $current) && file_exists('install/update.php')) { @@ -1242,10 +1246,13 @@ function check_config(&$a) { // Prevent sending hundreds of thousands of emails by creating // a lockfile. view/tpl/smarty3 is the only place we can // guarantee the server can write to. - if (file_exists('view/tpl/smarty3/mailsent')) + $lockfile = 'view/tpl/smarty3/mailsent'; + + if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) return; + @unlink($lockfile); //send the administrator an e-mail - file_put_contents('view/tpl/smarty3/mailsent', $x); + file_put_contents($lockfile, $x); $email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_msg = replace_macros($email_tpl, array( -- cgit v1.2.3