From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- inc/infoutils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index f9ba11560..9c297a28d 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -296,6 +296,7 @@ define('MSG_ADMINS_ONLY',4); */ function msg($message,$lvl=0,$line='',$file='',$allow=MSG_PUBLIC){ global $MSG, $MSG_shown; + $errors = array(); $errors[-1] = 'error'; $errors[0] = 'info'; $errors[1] = 'success'; @@ -452,7 +453,7 @@ function dbg_backtrace(){ }elseif(is_array($arg)){ $params[] = '[Array]'; }elseif(is_null($arg)){ - $param[] = '[NULL]'; + $params[] = '[NULL]'; }else{ $params[] = (string) '"'.$arg.'"'; } -- cgit v1.2.3 From 86c04d87ee7a9a39ec8838fd53e3797f51949719 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Sat, 11 Oct 2014 12:06:30 +1100 Subject: Fix for update messages never completely going away The existing logic for messages.txt requires some valid update response (ending in %) to the messages update check before it clears the current messages. However update.dokuwiki.org appears to return an empty string response if everything is up to date. (ie http://update.dokuwiki.org/check/46.1 ) As a result if there are update messages in messages.txt they don't automatically go away after updating to the current version. The only time they change is when a newer release comes out. The upgrade plugin has logic in it to force a re-download of messages.txt, but currently this just re-downloads the old update messages. This change explicitly allows for "" as a valid "no messages" indicator (distinct from false, which is the HTTP error indicator.) --- inc/infoutils.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index f9ba11560..e2b64d3ca 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -29,18 +29,19 @@ function checkUpdateMessages(){ dbglog("checkUpdateMessages(): downloading messages.txt"); $http = new DokuHTTPClient(); $http->timeout = 12; - $data = $http->get(DOKU_MESSAGEURL.$updateVersion); - if(substr(trim($data), -1) != '%') { - // this doesn't look like one of our messages, maybe some WiFi login interferred - $data = ''; - }else { - io_saveFile($cf,$data); + $resp = $http->get(DOKU_MESSAGEURL.$updateVersion); + if(is_string($resp) && ($resp == "" || substr(trim($resp), -1) == '%')) { + // basic sanity check that this is either an empty string response (ie "no messages") + // or it looks like one of our messages, not WiFi login or other interposed response + io_saveFile($cf,$resp); + } else { + dbglog("checkUpdateMessages(): unexpected HTTP response received"); } }else{ dbglog("checkUpdateMessages(): messages.txt up to date"); - $data = io_readFile($cf); } + $data = io_readFile($cf); // show messages through the usual message mechanism $msgs = explode("\n%\n",$data); foreach($msgs as $msg){ -- cgit v1.2.3 From 37b21a1b15c01de8390be3af74d1cf08f4676313 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 14 Oct 2014 19:55:45 +0200 Subject: use its own cache file per versions this ensures there will be never, ever an outdated update message shown after upgrade. --- inc/infoutils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index e2b64d3ca..8fe344093 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -20,13 +20,13 @@ function checkUpdateMessages(){ if(!$conf['updatecheck']) return; if($conf['useacl'] && !$INFO['ismanager']) return; - $cf = $conf['cachedir'].'/messages.txt'; + $cf = getCacheName($updateVersion, '.updmsg'); $lm = @filemtime($cf); // check if new messages needs to be fetched if($lm < time()-(60*60*24) || $lm < @filemtime(DOKU_INC.DOKU_SCRIPT)){ @touch($cf); - dbglog("checkUpdateMessages(): downloading messages.txt"); + dbglog("checkUpdateMessages(): downloading messages to ".$cf); $http = new DokuHTTPClient(); $http->timeout = 12; $resp = $http->get(DOKU_MESSAGEURL.$updateVersion); @@ -38,7 +38,7 @@ function checkUpdateMessages(){ dbglog("checkUpdateMessages(): unexpected HTTP response received"); } }else{ - dbglog("checkUpdateMessages(): messages.txt up to date"); + dbglog("checkUpdateMessages(): messages up to date"); } $data = io_readFile($cf); -- cgit v1.2.3 From 001d05eda158fd1c33cd0e6580a28241af69226c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 14 Oct 2014 21:32:54 +0200 Subject: new PHP minimum requirement is now 5.3.3 that's the version in Debian old stable --- inc/infoutils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 8fe344093..06e03e90f 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -114,13 +114,13 @@ function check(){ if ($INFO['isadmin'] || $INFO['ismanager']){ msg('DokuWiki version: '.getVersion(),1); - if(version_compare(phpversion(),'5.2.0','<')){ - msg('Your PHP version is too old ('.phpversion().' vs. 5.2.0+ needed)',-1); + if(version_compare(phpversion(),'5.3.3','<')){ + msg('Your PHP version is too old ('.phpversion().' vs. 5.3.3+ needed)',-1); }else{ msg('PHP version '.phpversion(),1); } } else { - if(version_compare(phpversion(),'5.2.0','<')){ + if(version_compare(phpversion(),'5.3.3','<')){ msg('Your PHP version is too old',-1); } } -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- inc/infoutils.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 399963176..fe312d13f 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -58,7 +58,7 @@ function checkUpdateMessages(){ function getVersionData(){ $version = array(); //import version string - if(@file_exists(DOKU_INC.'VERSION')){ + if(file_exists(DOKU_INC.'VERSION')){ //official release $version['date'] = trim(io_readfile(DOKU_INC.'VERSION')); $version['type'] = 'Release'; @@ -141,20 +141,20 @@ function check(){ if(is_writable($conf['changelog'])){ msg('Changelog is writable',1); }else{ - if (@file_exists($conf['changelog'])) { + if (file_exists($conf['changelog'])) { msg('Changelog is not writable',-1); } } - if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { + if (isset($conf['changelog_old']) && file_exists($conf['changelog_old'])) { msg('Old changelog exists', 0); } - if (@file_exists($conf['changelog'].'_failed')) { + if (file_exists($conf['changelog'].'_failed')) { msg('Importing old changelog failed', -1); - } else if (@file_exists($conf['changelog'].'_importing')) { + } else if (file_exists($conf['changelog'].'_importing')) { msg('Importing old changelog now.', 0); - } else if (@file_exists($conf['changelog'].'_import_ok')) { + } else if (file_exists($conf['changelog'].'_import_ok')) { msg('Old changelog imported', 1); if (!plugin_isdisabled('importoldchangelog')) { msg('Importoldchangelog plugin not disabled after import', -1); -- cgit v1.2.3