Testing AJAX watch/unwatch, with E_STRICT error_reporting:
authorNick Jenkins <nickj@users.mediawiki.org>
Tue, 9 Jan 2007 07:05:34 +0000 (07:05 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Tue, 9 Jan 2007 07:05:34 +0000 (07:05 +0000)
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 '<err#>' 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 '<err#>' 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
includes/AjaxFunctions.php
includes/Title.php

index a64f56d..89062f8 100644 (file)
@@ -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);
index 3e74a19..eee2a1a 100644 (file)
@@ -135,7 +135,7 @@ function wfSajaxSearch( $term ) {
  * @param $watch String 'w' to watch, 'u' to unwatch
  * @return String '<w#>' or '<u#>' on successful watch or unwatch, respectively, or '<err#>' on error (invalid XML in case we want to add HTML sometime)
  */
-function wfAjaxWatch($pageID, $watch) {
+function wfAjaxWatch($pageID = "", $watch = "") {
        if(wfReadOnly())
                return '<err#>'; // redirect to action=(un)watch, which will display the database lock message
 
index fab0654..1c858de 100644 (file)
@@ -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' ),