From 24d81a7d03bb415d2d6ab0e43af62fd46c154707 Mon Sep 17 00:00:00 2001 From: jeroendedauw Date: Mon, 14 May 2012 12:00:12 +0200 Subject: [PATCH] poked at adding diff stuff but gave up and just left some todos Change-Id: Idb436ef18a61dcef031f6f231fd7823c9e8d3bf0 --- includes/Content.php | 25 +++++++++++++++++++++++++ includes/WikiPage.php | 17 +++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/includes/Content.php b/includes/Content.php index 9f6b4d61ff..d094b55cd5 100644 --- a/includes/Content.php +++ b/includes/Content.php @@ -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. * diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 2f54c7c501..16e97f21a3 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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' ); -- 2.20.1