From b74d98523289aaf639a554adafc27f038f3a6a9b Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Tue, 9 Jan 2007 07:05:34 +0000 Subject: [PATCH] Testing AJAX watch/unwatch, with E_STRICT error_reporting: Prevent : * Strict Standards: Non-static method Title::newFromID() should not be called statically in includes/AjaxFunctions.php on line 147 [stopped AJAX watch/unwatch working for me, as I have errors being logged to the page output] E_STRICT warnings on truncated GET input (e.g. http://192.168.0.64/wiki/index.php?action=ajax&rs=wfAjaxWatch&rsargs[]=1 , rather than http://192.168.0.64/wiki/index.php?action=ajax&rs=wfAjaxWatch&rsargs[]=1&rsargs[]=u ), prevent by specifying default $watch value of "" (which should result in an error '' response, which is probably fine). * Strict Standards: Missing argument 2 for wfAjaxWatch() in includes/AjaxFunctions.php on line 138 * Strict Standards: Undefined variable: watch in includes/AjaxFunctions.php on line 142 E_STRICT warnings on another truncated GET input ( http://192.168.0.64/wiki/index.php?action=ajax&rs=wfAjaxWatch&rsargs= ), prevent by specifying default $pageID value of "" (which again should result in an error '' response because it's not numeric, which is probably fine). * Strict Standards: Missing argument 1 for wfAjaxWatch() in includes/AjaxFunctions.php on line 138 E_STRICT warning on bad GET input - "rs" as array, not as a string - (e.g. http://192.168.0.64/wiki/index.php?action=ajax&rs[]= ), adding explicit cast to string: * Strict Standards: htmlspecialchars() expects parameter 1 to be string, array given in includes/AjaxDispatcher.php on line 58 --- includes/AjaxDispatcher.php | 2 +- includes/AjaxFunctions.php | 2 +- includes/Title.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index a64f56d9e4..89062f8770 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -55,7 +55,7 @@ class AjaxDispatcher { if (! in_array( $this->func_name, $wgAjaxExportList ) ) { header( 'Status: 400 Bad Request', true, 400 ); - print "unknown function " . htmlspecialchars( $this->func_name ); + print "unknown function " . htmlspecialchars( (string) $this->func_name ); } else { try { $result = call_user_func_array($this->func_name, $this->args); diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 3e74a19b1c..eee2a1a4e6 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -135,7 +135,7 @@ function wfSajaxSearch( $term ) { * @param $watch String 'w' to watch, 'u' to unwatch * @return String '' or '' on successful watch or unwatch, respectively, or '' on error (invalid XML in case we want to add HTML sometime) */ -function wfAjaxWatch($pageID, $watch) { +function wfAjaxWatch($pageID = "", $watch = "") { if(wfReadOnly()) return ''; // redirect to action=(un)watch, which will display the database lock message diff --git a/includes/Title.php b/includes/Title.php index fab065473e..1c858de411 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -190,7 +190,7 @@ class Title { * @access public * @static */ - function newFromID( $id ) { + public static function newFromID( $id ) { $fname = 'Title::newFromID'; $dbr =& wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'page', array( 'page_namespace', 'page_title' ), -- 2.20.1