aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorumherirrender <umherirrender_de.wp@web.de>2015-10-08 21:26:56 +0200
committerumherirrender <umherirrender_de.wp@web.de>2015-10-09 16:12:21 +0200
commit54e0ef00ddc94ad129f5ec531f61af2ddbe778a3 (patch)
tree9d920af0e05fe35cfb5258f5608682d6ac3df611
parentb2222eacf7050acabe7d0172e1822c67a2fdfa7e (diff)
downloadmediawikicore-54e0ef00ddc94ad129f5ec531f61af2ddbe778a3.tar.gz
mediawikicore-54e0ef00ddc94ad129f5ec531f61af2ddbe778a3.zip
Set correct parentid on import
When importing over an existing page the parentid is set to the latest rev id of the page, which makes the size diff in history unusable. The import constructs the Revision object without a parentid and than Revision::getPreviousRevisionId is using the page_latest field to propagate the missing parentid. Avoid this bad propagate by select the previous revision id depending on timestamp before construct of the Revision object. Bug: T114806 Change-Id: Iee44d5a74de459f733ea62373cdbe9911e77083f
-rw-r--r--includes/Import.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/includes/Import.php b/includes/Import.php
index 60d4a1f8422e..33ab4eacedd3 100644
--- a/includes/Import.php
+++ b/includes/Import.php
@@ -1606,6 +1606,20 @@ class WikiRevision {
}
}
+ // Select previous version to make size diffs correct
+ $prevId = $dbw->selectField( 'revision', 'rev_id',
+ array(
+ 'rev_page' => $pageId,
+ 'rev_timestamp <= ' . $dbw->timestamp( $this->timestamp ),
+ ),
+ __METHOD__,
+ array( 'ORDER BY' => array(
+ 'rev_timestamp DESC',
+ 'rev_id DESC', // timestamp is not unique per page
+ )
+ )
+ );
+
# @todo FIXME: Use original rev_id optionally (better for backups)
# Insert the row
$revision = new Revision( array(
@@ -1620,6 +1634,7 @@ class WikiRevision {
'user_text' => $userText,
'timestamp' => $this->timestamp,
'minor_edit' => $this->minor,
+ 'parent_id' => $prevId,
) );
$revision->insertOn( $dbw );
$changed = $page->updateIfNewerOn( $dbw, $revision );