From e8b5a4f91c8a6e230a6cfe13c43dc9ddce31e253 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 28 Jul 2012 12:02:06 +0200 Subject: fix E_STRICT errors FS#2427 This commit fixes all E_STRICT messages shown when running the test suite. There might be more problems not covered by tests, yet. For compatibility reasons with plugins, E_STRICT errors are still supressed. --- inc/SafeFN.class.php | 12 ++++++------ inc/events.php | 2 +- inc/parser/metadata.php | 41 ----------------------------------------- inc/parser/renderer.php | 2 +- inc/parserutils.php | 2 +- inc/plugin.php | 2 +- 6 files changed, 10 insertions(+), 51 deletions(-) (limited to 'inc') diff --git a/inc/SafeFN.class.php b/inc/SafeFN.class.php index ab05b9eae..b9e4a2b2a 100644 --- a/inc/SafeFN.class.php +++ b/inc/SafeFN.class.php @@ -44,7 +44,7 @@ class SafeFN { * * @author Christopher Smith */ - public function encode($filename) { + public static function encode($filename) { return self::unicode_to_safe(utf8_to_unicode($filename)); } @@ -73,15 +73,15 @@ class SafeFN { * * @author Christopher Smith */ - public function decode($filename) { + public static function decode($filename) { return unicode_to_utf8(self::safe_to_unicode(strtolower($filename))); } - public function validate_printable_utf8($printable_utf8) { + public static function validate_printable_utf8($printable_utf8) { return !preg_match('#[\x01-\x1f]#',$printable_utf8); } - public function validate_safe($safe) { + public static function validate_safe($safe) { return !preg_match('#[^'.self::$plain.self::$post_indicator.self::$pre_indicator.']#',$safe); } @@ -93,7 +93,7 @@ class SafeFN { * * @author Christopher Smith */ - private function unicode_to_safe($unicode) { + private static function unicode_to_safe($unicode) { $safe = ''; $converted = false; @@ -126,7 +126,7 @@ class SafeFN { * * @author Christopher Smith */ - private function safe_to_unicode($safe) { + private static function safe_to_unicode($safe) { $unicode = array(); $split = preg_split('#(?=['.self::$post_indicator.self::$pre_indicator.'])#',$safe,-1,PREG_SPLIT_NO_EMPTY); diff --git a/inc/events.php b/inc/events.php index 4e81f85c8..f7b1a7a16 100644 --- a/inc/events.php +++ b/inc/events.php @@ -132,7 +132,7 @@ class Doku_Event_Handler { $pluginlist = plugin_list('action'); foreach ($pluginlist as $plugin_name) { - $plugin =& plugin_load('action',$plugin_name); + $plugin = plugin_load('action',$plugin_name); if ($plugin !== null) $plugin->register($this); } diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 8bfdc3b9c..8638ffa6a 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -133,27 +133,6 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function strong_open(){} - function strong_close(){} - - function emphasis_open(){} - function emphasis_close(){} - - function underline_open(){} - function underline_close(){} - - function monospace_open(){} - function monospace_close(){} - - function subscript_open(){} - function subscript_close(){} - - function superscript_open(){} - function superscript_close(){} - - function deleted_open(){} - function deleted_close(){} - /** * Callback for footnote start syntax * @@ -218,14 +197,6 @@ class Doku_Renderer_metadata extends Doku_Renderer { if ($this->capture) $this->doc .= $text; } - function php($text){} - - function phpblock($text){} - - function html($text){} - - function htmlblock($text){} - function preformatted($text){ if ($this->capture) $this->doc .= $text; } @@ -393,18 +364,6 @@ class Doku_Renderer_metadata extends Doku_Renderer { $params['refresh']; } - function table_open($maxcols = NULL, $numrows = NULL){} - function table_close(){} - - function tablerow_open(){} - function tablerow_close(){} - - function tableheader_open($colspan = 1, $align = NULL, $rowspan = 1){} - function tableheader_close(){} - - function tablecell_open($colspan = 1, $align = NULL, $rowspan = 1){} - function tablecell_close(){} - //---------------------------------------------------------- // Utils diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 0923e6896..2c78f220a 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -62,7 +62,7 @@ class Doku_Renderer extends DokuWiki_Plugin { //handle plugin rendering function plugin($name,$data){ - $plugin =& plugin_load('syntax',$name); + $plugin = plugin_load('syntax',$name); if($plugin != null){ $plugin->render($this->getFormat(),$this,$data); } diff --git a/inc/parserutils.php b/inc/parserutils.php index 20f992ba2..58920cbea 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -570,7 +570,7 @@ function p_get_parsermodes(){ $obj = null; foreach($pluginlist as $p){ /** @var DokuWiki_Syntax_Plugin $obj */ - if(!$obj =& plugin_load('syntax',$p)) continue; //attempt to load plugin into $obj + if(!$obj = plugin_load('syntax',$p)) continue; //attempt to load plugin into $obj $PARSER_MODES[$obj->getType()][] = "plugin_$p"; //register mode type //add to modes $modes[] = array( diff --git a/inc/plugin.php b/inc/plugin.php index d2fe3818d..b0518346d 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -191,7 +191,7 @@ class DokuWiki_Plugin { */ function loadHelper($name, $msg){ if (!plugin_isdisabled($name)){ - $obj =& plugin_load('helper',$name); + $obj = plugin_load('helper',$name); }else{ $obj = null; } -- cgit v1.2.3 From 8449cc9d82848df24eb88a73dd81d7e048933287 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Wed, 31 Oct 2012 16:51:54 +0100 Subject: added event PAGEUTILS_ID_HIDEPAGE --- inc/pageutils.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'inc') diff --git a/inc/pageutils.php b/inc/pageutils.php index 55cc081a1..853d3fb4d 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -538,6 +538,14 @@ function getCacheName($data,$ext=''){ function isHiddenPage($id){ global $conf; global $ACT; + + $data = array( + 'id' => $id, + 'hidden' => false + ); + trigger_event('PAGEUTILS_ID_HIDEPAGE', $id); + + if ($data['hidden']) return true; if(empty($conf['hidepages'])) return false; if($ACT == 'admin') return false; -- cgit v1.2.3 From fb55b51ef82bc3066173e7547500d9e79c410e34 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Mon, 5 Nov 2012 10:57:42 +0100 Subject: changed PAGEUTILS_ID_HIDEPAGE to has BEFORE/AFTER --- inc/pageutils.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'inc') diff --git a/inc/pageutils.php b/inc/pageutils.php index 853d3fb4d..3bb10883f 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -536,23 +536,25 @@ function getCacheName($data,$ext=''){ * @author Andreas Gohr */ function isHiddenPage($id){ - global $conf; - global $ACT; - $data = array( 'id' => $id, 'hidden' => false ); - trigger_event('PAGEUTILS_ID_HIDEPAGE', $id); + trigger_event('PAGEUTILS_ID_HIDEPAGE', $data, '_isHiddenPage'); + return $data['hidden']; +} - if ($data['hidden']) return true; - if(empty($conf['hidepages'])) return false; - if($ACT == 'admin') return false; +function _isHiddenPage(&$data) { + global $conf; + global $ACT; - if(preg_match('/'.$conf['hidepages'].'/ui',':'.$id)){ - return true; + if ($data['hidden']) return; + if(empty($conf['hidepages'])) return; + if($ACT == 'admin') return; + + if(preg_match('/'.$conf['hidepages'].'/ui',':'.$data['id'])){ + $data['hidden'] = true; } - return false; } /** -- cgit v1.2.3 From bfd975d26ab51152ac6a256827ffda93b15df48b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 6 Nov 2012 20:58:38 +0100 Subject: fix regression bug in HTTPClient FS#2621 In the recent refactoring of the HTTPClient, a problem with certain systems was reintroduced. On these systems a select() call always waits for a timeout on the first call before working properly on the second call. This patch reintroduces the shorter timeouts with usleep rate limiting again. Since this bug is not reproducible on other systems it can't be unit tested unfortunately. --- inc/HTTPClient.php | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'inc') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index a25846c31..c4cfcbf7c 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -509,15 +509,17 @@ class HTTPClient { if(feof($socket)) throw new HTTPClientException("Socket disconnected while writing $message"); - // wait for stream ready or timeout - self::selecttimeout($this->timeout - $time_used, $sec, $usec); - if(@stream_select($sel_r, $sel_w, $sel_e, $sec, $usec) !== false){ - // write to stream - $nbytes = fwrite($socket, substr($data,$written,4096)); - if($nbytes === false) - throw new HTTPClientException("Failed writing to socket while sending $message", -100); - $written += $nbytes; + // wait for stream ready or timeout (1sec) + if(@stream_select($sel_r,$sel_w,$sel_e,1) === false){ + usleep(1000); + continue; } + + // write to stream + $nbytes = fwrite($socket, substr($data,$written,4096)); + if($nbytes === false) + throw new HTTPClientException("Failed writing to socket while sending $message", -100); + $written += $nbytes; } } @@ -556,15 +558,17 @@ class HTTPClient { } if ($to_read > 0) { - // wait for stream ready or timeout - self::selecttimeout($this->timeout - $time_used, $sec, $usec); - if(@stream_select($sel_r, $sel_w, $sel_e, $sec, $usec) !== false){ - $bytes = fread($socket, $to_read); - if($bytes === false) - throw new HTTPClientException("Failed reading from socket while reading $message", -100); - $r_data .= $bytes; - $to_read -= strlen($bytes); + // wait for stream ready or timeout (1sec) + if(@stream_select($sel_r,$sel_w,$sel_e,1) === false){ + usleep(1000); + continue; } + + $bytes = fread($socket, $to_read); + if($bytes === false) + throw new HTTPClientException("Failed reading from socket while reading $message", -100); + $r_data .= $bytes; + $to_read -= strlen($bytes); } } while ($to_read > 0 && strlen($r_data) < $nbytes); return $r_data; @@ -595,11 +599,13 @@ class HTTPClient { if(feof($socket)) throw new HTTPClientException("Premature End of File (socket) while reading $message"); - // wait for stream ready or timeout - self::selecttimeout($this->timeout - $time_used, $sec, $usec); - if(@stream_select($sel_r, $sel_w, $sel_e, $sec, $usec) !== false){ - $r_data = fgets($socket, 1024); + // wait for stream ready or timeout (1sec) + if(@stream_select($sel_r,$sel_w,$sel_e,1) === false){ + usleep(1000); + continue; } + + $r_data = fgets($socket, 1024); } while (!preg_match('/\n$/',$r_data)); return $r_data; } @@ -629,14 +635,6 @@ class HTTPClient { return ((float)$usec + (float)$sec); } - /** - * Calculate seconds and microseconds - */ - static function selecttimeout($time, &$sec, &$usec){ - $sec = floor($time); - $usec = (int)(($time - $sec) * 1000000); - } - /** * convert given header string to Header array * -- cgit v1.2.3 From 63d9b82068e796869bf6ff648623acd33be27ebe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Nov 2012 00:28:12 +0100 Subject: avoid multiple paralell update checks we now touch the messages before the actual update happens. this should lower the chance of more than one update check running at a time. --- inc/infoutils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/infoutils.php b/inc/infoutils.php index 7ceeae8f1..dfd6554e7 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -25,12 +25,12 @@ function checkUpdateMessages(){ // check if new messages needs to be fetched if($lm < time()-(60*60*24) || $lm < @filemtime(DOKU_INC.DOKU_SCRIPT)){ + @touch($cf); dbglog("checkUpdatesMessages(): downloading messages.txt"); $http = new DokuHTTPClient(); - $http->timeout = 8; + $http->timeout = 12; $data = $http->get(DOKU_MESSAGEURL.$updateVersion); io_saveFile($cf,$data); - @touch($cf); }else{ dbglog("checkUpdatesMessages(): messages.txt up to date"); $data = io_readFile($cf); -- cgit v1.2.3 From a731ed1d6736ca405b3559adfd9500affcc59412 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 8 Nov 2012 22:48:07 +0100 Subject: added PCRE UTF-8 checks to do=check FS#2636 --- inc/infoutils.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'inc') diff --git a/inc/infoutils.php b/inc/infoutils.php index dfd6554e7..0dc7092ad 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -176,6 +176,13 @@ function check(){ msg('mb_string extension not available - PHP only replacements will be used',0); } + if (!preg_match("/^.$/u", "ñ")) { + msg('PHP is missing UTF-8 support in Perl-Compatible Regular Expressions (PCRE)', -1); + } + if (!preg_match("/^\pL$/u", "ñ")) { + msg('PHP is missing Unicode properties support in Perl-Compatible Regular Expressions (PCRE)', -1); + } + $loc = setlocale(LC_ALL, 0); if(!$loc){ msg('No valid locale is set for your PHP setup. You should fix this',-1); -- cgit v1.2.3