poked at adding diff stuff but gave up and just left some todos
authorjeroendedauw <jeroendedauw@gmail.com>
Mon, 14 May 2012 10:00:12 +0000 (12:00 +0200)
committerjeroendedauw <jeroendedauw@gmail.com>
Mon, 14 May 2012 10:00:12 +0000 (12:00 +0200)
Change-Id: Idb436ef18a61dcef031f6f231fd7823c9e8d3bf0

includes/Content.php
includes/WikiPage.php

index 9f6b4d6..d094b55 100644 (file)
@@ -197,6 +197,31 @@ abstract class Content {
                return $this->getSize() == 0;
        }
 
+       /**
+        * Returns if the content is valid.
+        * It needs to be valid before it can be saved.
+        *
+        * @since WD.1
+        *
+        * @return boolean
+        */
+       public function isValid() {
+               // TODO
+               return true;
+       }
+
+       /**
+        * Diff the content object with what is currently stored in the database.
+        * If it is not currently stored, it will be diffed with an empty object.
+        *
+        * @since WD.diff
+        *
+        * @return ContentDiff
+        */
+       public function diffToDatabase() {
+               // TODO
+       }
+
        /**
         * Returns true if this Content objects is conceptually equivalent to the given Content object.
         *
index 2f54c7c..16e97f2 100644 (file)
@@ -1525,6 +1525,11 @@ class WikiPage extends Page {
                        $changed = !$content->equals( $old_content );
 
                        if ( $changed ) {
+                               // TODO: validate!
+                               if ( $content->isValid() ) {
+
+                               }
+
                                $dbw->begin( __METHOD__ );
                                $revisionId = $revision->insertOn( $dbw );
 
@@ -1586,9 +1591,17 @@ class WikiPage extends Page {
                                return $status;
                        }
 
+                       // TODO: create content diff to pass to update objects that might need it
+
                        # Update links tables, site stats, etc.
-                       $this->doEditUpdates( $revision, $user, array( 'changed' => $changed,
-                               'oldcountable' => $oldcountable ) );
+                       $this->doEditUpdates(
+                               $revision,
+                               $user,
+                               array(
+                                       'changed' => $changed,
+                                       'oldcountable' => $oldcountable
+                               )
+                       );
 
                        if ( !$changed ) {
                                $status->warning( 'edit-no-change' );