Issue:DPLMain calls private Title function prefix()

From FollowTheScore
Revision as of 21:18, 16 March 2012 by Maiden taiwan (talk | contribs) (moved Issue:DPLMain calls private function Title::prefix to Issue:DPLMain calls private Title function prefix(): colons are messing up Special:Call)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Description: DPLMain calls Title::prefix which is private as of MediaWiki 1.18.0
Extension / Version: DPL   /   2.0
Type / Status: Bug   /   open

Problem

This fatal error in DPL 2.0 and MediaWiki 1.18.0:

PHP Fatal error:  Call to private method Title::prefix()
from context 'DPLMain' in /var/www/html/w/extensions/DynamicPageList/DPLMain.php on line 2631

is caused by this line of code:

 if ($bShowNamespace) $sTitleText = str_replace( '_', ' ', $title->prefix($sTitleText) );

because the Title::prefix() method is now private. I suspect you should be calling Title::getPrefixedDBkey() if you want underscores, or Title::getPrefixedText if you want space characters.

Patch against DPL 2.0

The svn revision numbers below are ours, not yours.

--- DPLMain.php (revision 18287)
+++ DPLMain.php (revision 18288)
@@ -2628,7 +2628,7 @@
     
             //chop off title if "too long"
                        if( isset($iTitleMaxLen) && (strlen($sTitleText) > $iTitleMaxLen) )  $sTitleText = substr($sTitleText, 0, $iTitleMaxLen) . '...';
-            if ($bShowNamespace) $sTitleText = str_replace( '_', ' ', $title->prefix($sTitleText) );
+            if ($bShowNamespace) $sTitleText = str_replace( '_', ' ', self::prefix($title, $sTitleText) );
             if ($bShowCurID && isset($row->page_id)) {
                                //$articleLink = '<html>'.$sk->makeKnownLinkObj($title, htmlspecialchars($sTitleText),'curid='.$row->page_id).'</html>';
                                $articleLink = '[{{fullurl:'.$title->getText().'|curid='.$row->page_id.'}} '.htmlspecialchars($sTitleText).']';
@@ -2950,6 +2950,18 @@
 
        // auxiliary functions ===============================================================================
 
+       // Copy of Title::prefix(), now private
+       private static function prefix($title, $name) {
+               $p = '';
+               if ( $title->getInterwiki() != '') {
+                       $p = $title->getInterwiki() . ':';
+               }
+
+               if ( 0 != $title->getNamespace() ) {
+                       $p .= $title->getNsText() . ':';
+               }
+               return $p . $name;
+       }
 
        // get a list of valid page names; returns true if valid args found
        private static function getPageNameList($cmd, $text, &$aLinks, &$bSelectionCriteriaFound, $logger, $mustExist=true) {

Reply