From aeaa72ff8b97f20b255cc6dca2e871173750952e Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 25 Oct 2012 09:51:23 +0200 Subject: [PATCH] (Bug 41370) protect aginst content-less revisions getAutoDeletereason did not gracefully deal with revisions that would return null as their content (e.g. for deleted revisions). Change-Id: I4976f2d09b8666ca1bccebea346af37ee77b09f7 --- includes/content/ContentHandler.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 9c4c3afc94..8e8de4b1ec 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -802,20 +802,21 @@ abstract class ContentHandler { $content = $rev->getContent(); $blank = false; - $this->checkModelID( $content->getModel() ); - // If the page is blank, use the text from the previous revision, // which can only be blank if there's a move/import/protect dummy // revision involved - if ( $content->getSize() == 0 ) { + if ( !$content || $content->isEmpty() ) { $prev = $rev->getPrevious(); - if ( $prev ) { - $content = $prev->getContent(); + if ( $prev ) { + $rev = $prev; + $content = $rev->getContent(); $blank = true; } } + $this->checkModelID( $rev->getContentModel() ); + // Find out if there was only one contributor // Only scan the last 20 revisions $res = $dbw->select( 'revision', 'rev_user_text', @@ -871,7 +872,7 @@ abstract class ContentHandler { } // Max content length = max comment length - length of the comment (excl. $1) - $text = $content->getTextForSummary( 255 - ( strlen( $reason ) - 2 ) ); + $text = $content ? $content->getTextForSummary( 255 - ( strlen( $reason ) - 2 ) ) : ''; // Now replace the '$1' placeholder $reason = str_replace( '$1', $text, $reason ); -- 2.20.1