saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/92443


Change subject: Really populate ar_len this time
......................................................................

Really populate ar_len this time

Change I0f685aa5ea48468279475b487a627ff73c70d5cd attempted
to populate ar_len, but it fails with:

SELECT
        rev_id,
        rev_page,
        rev_text_id,
        rev_timestamp,
        rev_comment,
        rev_user_text,
        rev_user,
        /* ... */
        rev_len,
        rev_parent_id,
        rev_sha1,
        rev_content_format,
        rev_content_model
FROM "archive"   WHERE (= 200) AND (ar_len IS NULL)

Change-Id: I18fab8012b9d59adde637607931c7a5ea6adf2a1
---
M includes/Revision.php
M maintenance/populateRevisionLength.php
2 files changed, 38 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/43/92443/1

diff --git a/includes/Revision.php b/includes/Revision.php
index 233eac0..c06cf5e 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -434,6 +434,40 @@
        }
 
        /**
+        * Return the list of archive fields that should be selected to create
+        * a revision pulled from the archive attic (via newFromArchiveRow)
+        * @return array
+        */
+       public static function selectArchiveFields() {
+               global $wgContentHandlerUseDB;
+
+               $fields = array(
+                       'ar_page_id',
+                       'ar_rev_id',
+                       'ar_comment',
+                       'ar_user',
+                       'ar_user_text',
+                       'ar_timestamp',
+                       'ar_minor_edit',
+                       'ar_text_id',
+                       'ar_text',
+                       'ar_deleted',
+                       'ar_len',
+                       'ar_sha1',
+                       'ar_namespace',
+                       'ar_title',
+               );
+
+               if ( $wgContentHandlerUseDB ) {
+                       $fields[] = 'ar_content_format';
+                       $fields[] = 'ar_content_model';
+               }
+
+               return $fields;
+       }
+
+
+       /**
         * Return the list of text fields that should be selected to read the
         * revision text
         * @return array
diff --git a/maintenance/populateRevisionLength.php 
b/maintenance/populateRevisionLength.php
index 4acc579..769e1a7 100644
--- a/maintenance/populateRevisionLength.php
+++ b/maintenance/populateRevisionLength.php
@@ -53,10 +53,10 @@
                }
 
                $this->output( "Populating rev_len column\n" );
-               $rev = $this->doLenUpdates( 'revision', 'rev_id', 'rev' );
+               $rev = $this->doLenUpdates( 'revision', 'rev_id', 'rev', 
Revision::selectFields() );
 
                $this->output( "Populating ar_len column\n" );
-               $ar = $this->doLenUpdates( 'archive', 'ar_id', 'ar' );
+               $ar = $this->doLenUpdates( 'archive', 'ar_id', 'ar', 
Revision::selectArchiveFields() );
 
                $this->output( "rev_len and ar_len population complete [$rev 
revision rows, $ar archive rows].\n" );
                return true;
@@ -68,7 +68,7 @@
         * @param $prefix
         * @return int
         */
-       protected function doLenUpdates( $table, $idCol, $prefix ) {
+       protected function doLenUpdates( $table, $idCol, $prefix, $fields ) {
                $db = $this->getDB( DB_MASTER );
                $start = $db->selectField( $table, "MIN($idCol)", false, 
__METHOD__ );
                $end = $db->selectField( $table, "MAX($idCol)", false, 
__METHOD__ );
@@ -81,9 +81,8 @@
                $blockStart = intval( $start );
                $blockEnd = intval( $start ) + $this->mBatchSize - 1;
                $count = 0;
-               $fields = Revision::selectFields();
                while ( $blockStart <= $end ) {
-                       $this->output( "...doing rev_id from $blockStart to 
$blockEnd\n" );
+                       $this->output( "...doing {$idCol} from $blockStart to 
$blockEnd\n" );
                        $res = $db->select(
                                $table,
                                $fields,

-- 
To view, visit https://gerrit.wikimedia.org/r/92443
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I18fab8012b9d59adde637607931c7a5ea6adf2a1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to