minor bugs and docu
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 24 Apr 2012 16:00:05 +0000 (18:00 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 24 Apr 2012 16:00:05 +0000 (18:00 +0200)
includes/ContentHandler.php
includes/WikiPage.php

index 5f45c6c..6e33c91 100644 (file)
@@ -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 ) ) {
index d036248..40040e2 100644 (file)
@@ -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 );
        }