Armor against bad titles
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Dec 2003 00:42:31 +0000 (00:42 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Dec 2003 00:42:31 +0000 (00:42 +0000)
includes/SearchUpdate.php

index 03978be..8777138 100644 (file)
@@ -3,26 +3,30 @@
 
 class SearchUpdate {
 
-       /* private */ var $mId, $mNamespace, $mTitle, $mText;
+       /* private */ var $mId = 0, $mNamespace, $mTitle, $mText;
        /* private */ var $mTitleWords;
 
        function SearchUpdate( $id, $title, $text = false )
        {
-               $this->mId = $id;
-               $this->mText = $text;
-
                $nt = Title::newFromText( $title );
-               $this->mNamespace = $nt->getNamespace();
-               $this->mTitle = $nt->getText(); # Discard namespace
+               if( $nt ) {
+                       $this->mId = $id;
+                       $this->mText = $text;
+
+                       $this->mNamespace = $nt->getNamespace();
+                       $this->mTitle = $nt->getText(); # Discard namespace
 
-               $this->mTitleWords = $this->mTextWords = array();
+                       $this->mTitleWords = $this->mTextWords = array();
+               } else {
+                       wfDebug( "SearchUpdate object created with invalid title '$title'\n" );
+               }
        }
 
        function doUpdate()
        {
                global $wgDBminWordLen, $wgLang, $wgDisableSearchUpdate;
 
-               if( $wgDisableSearchUpdate ) {
+               if( $wgDisableSearchUpdate || !$this->mId ) {
                        return false;
                }
                $lc = SearchEngine::legalSearchChars() . "&#;";