(bug 21796) Fix null dereference on Special:Undelete.
authorSzymon Świerkosz <beau@adres.pl>
Sat, 31 Mar 2012 15:26:50 +0000 (17:26 +0200)
committerSzymon Świerkosz <beau@adres.pl>
Tue, 3 Apr 2012 15:38:13 +0000 (17:38 +0200)
This change allows to display deleted pages correctly without dereferencing
a null. It is still impossible to view or undelete a page with an invalid
title, so the title is a shown as plain text.

Change-Id: Ib82d385eb174dac5e559736920cdb21303291ad2

includes/specials/SpecialUndelete.php

index e8f3df7..06b578d 100644 (file)
@@ -745,14 +745,20 @@ class SpecialUndelete extends SpecialPage {
                $out->addHTML( "<ul>\n" );
                foreach ( $result as $row ) {
                        $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
-                       $link = Linker::linkKnown(
-                               $undelete,
-                               htmlspecialchars( $title->getPrefixedText() ),
-                               array(),
-                               array( 'target' => $title->getPrefixedText() )
-                       );
+                       if ( $title !== null ) {
+                               $item = Linker::linkKnown(
+                                       $undelete,
+                                       htmlspecialchars( $title->getPrefixedText() ),
+                                       array(),
+                                       array( 'target' => $title->getPrefixedText() )
+                               );
+                       } else {
+                               // The title is no longer valid, show as text
+                               $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+                               $item = htmlspecialchars( $title->getPrefixedText() );
+                       }
                        $revs = $this->msg( 'undeleterevisions' )->numParams( $row->count )->parse();
-                       $out->addHTML( "<li>{$link} ({$revs})</li>\n" );
+                       $out->addHTML( "<li>{$item} ({$revs})</li>\n" );
                }
                $result->free();
                $out->addHTML( "</ul>\n" );