From b200f096adeed15af03b2872e9d9b6d4d881b368 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 24 Apr 2012 18:00:05 +0200 Subject: [PATCH] minor bugs and docu --- includes/ContentHandler.php | 7 ++++--- includes/WikiPage.php | 36 ++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index 5f45c6c21c..6e33c91477 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -614,11 +614,12 @@ abstract class ContentHandler { * Get the Content object that needs to be saved in order to undo all revisions * between $undo and $undoafter. Revisions must belong to the same page, * must exist and must not be deleted - * @param $undo Revision - * @param $undoafter null|Revision Must be an earlier revision than $undo + * @param $current Revision the current text + * @param $undo Revision the revision to undo + * @param $undoafter Revision Must be an earlier revision than $undo * @return mixed string on success, false on failure */ - public function getUndoContent( Revision $current, Revision $undo, Revision $undoafter = null ) { + public function getUndoContent( Revision $current, Revision $undo, Revision $undoafter ) { $cur_content = $current->getContent(); if ( empty( $cur_content ) ) { diff --git a/includes/WikiPage.php b/includes/WikiPage.php index d0362484b2..40040e26ec 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1166,25 +1166,29 @@ class WikiPage extends Page { * @param $undo Revision * @param $undoafter Revision Must be an earlier revision than $undo * @return mixed string on success, false on failure - * @deprecated since 1.20: use ContentHandler::getUndoContent() instead. + * @deprecated since 1.20: use ContentHandler::getUndoContent() instead. */ public function getUndoText( Revision $undo, Revision $undoafter = null ) { #FIXME: replace usages. wfDeprecated( __METHOD__, '1.20' ); - $this->loadLastEdit(); + $this->loadLastEdit(); - if ( $this->mLastRevision ) { - $handler = ContentHandler::getForTitle( $this->getTitle() ); - $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter ); + if ( $this->mLastRevision ) { + if ( is_null( $undoafter ) ) { + $undoafter = $undo->getPrevious(); + } - if ( !$undone ) { - return false; - } else { - return ContentHandler::getContentText( $undone ); - } - } + $handler = $this->getContentHandler(); + $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter ); - return false; + if ( !$undone ) { + return false; + } else { + return ContentHandler::getContentText( $undone ); + } + } + + return false; } /** @@ -2633,8 +2637,8 @@ class WikiPage extends Page { /** * Return an applicable autosummary if one exists for the given edit. - * @param $oldtext String: the previous text of the page. - * @param $newtext String: The submitted text of the page. + * @param $oldtext String|null: the previous text of the page. + * @param $newtext String|null: The submitted text of the page. * @param $flags Int bitmask: a bitmask of flags submitted for the edit. * @return string An appropriate autosummary, or an empty string. * @deprecated since 1.20, use ContentHandler::getAutosummary() instead @@ -2643,8 +2647,8 @@ class WikiPage extends Page { # NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't. $handler = ContentHandler::getForModelName( CONTENT_MODEL_WIKITEXT ); - $oldContent = $oldtext ? $handler->unserializeContent( $oldtext ) : null; - $newContent = $newtext ? $handler->unserializeContent( $newtext ) : null; + $oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext ); + $newContent = is_null( $newtext ) ? null : $handler->unserializeContent( $newtext ); return $handler->getAutosummary( $oldContent, $newContent, $flags ); } -- 2.20.1