From: daniel Date: Thu, 25 Oct 2012 07:51:23 +0000 (+0200) Subject: (Bug 41370) protect aginst content-less revisions X-Git-Tag: 1.31.0-rc.0~21863^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22config_fonctions%22%2C%20%22image_process=%24process%22%29%20.%20%22?a=commitdiff_plain;h=aeaa72ff8b97f20b255cc6dca2e871173750952e;p=lhc%2Fweb%2Fwiklou.git (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 --- 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 );