https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111486

Revision: 111486
Author:   aaron
Date:     2012-02-14 21:02:27 +0000 (Tue, 14 Feb 2012)
Log Message:
-----------
(bug 34285) - Make use of rev_sha1 per-wiki configurable.

Modified Paths:
--------------
    branches/wmf/1.19wmf1/includes/Export.php
    branches/wmf/1.19wmf1/includes/Revision.php
    branches/wmf/1.19wmf1/includes/WikiPage.php
    branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php

Modified: branches/wmf/1.19wmf1/includes/Export.php
===================================================================
--- branches/wmf/1.19wmf1/includes/Export.php   2012-02-14 20:56:14 UTC (rev 
111485)
+++ branches/wmf/1.19wmf1/includes/Export.php   2012-02-14 21:02:27 UTC (rev 
111486)
@@ -487,7 +487,7 @@
                        }
                }
                
-               if ( $row->rev_sha1 ) {
+               if ( isset( $row->rev_sha1 ) ) {
                        $out .= "      " . Xml::element('sha1', null, 
strval($row->rev_sha1) ) . "\n";
                } else {
                        $out .= "      <sha1/>\n";

Modified: branches/wmf/1.19wmf1/includes/Revision.php
===================================================================
--- branches/wmf/1.19wmf1/includes/Revision.php 2012-02-14 20:56:14 UTC (rev 
111485)
+++ branches/wmf/1.19wmf1/includes/Revision.php 2012-02-14 21:02:27 UTC (rev 
111486)
@@ -323,7 +323,7 @@
         * a new revision.
         */
        public static function selectFields() {
-               return array(
+               $fields = array(
                        'rev_id',
                        'rev_page',
                        'rev_text_id',
@@ -334,9 +334,13 @@
                        'rev_minor_edit',
                        'rev_deleted',
                        'rev_len',
-                       'rev_parent_id',
-                       'rev_sha1'
+                       'rev_parent_id'
                );
+               global $wmfUseRevSha1Columns;
+               if ( !empty( $wmfUseRevSha1Columns ) ) {
+                       $fields[] = 'rev_sha1';
+               }
+               return $fields;
        }
 
        /**
@@ -979,26 +983,29 @@
                $rev_id = isset( $this->mId )
                        ? $this->mId
                        : $dbw->nextSequenceValue( 'revision_rev_id_seq' );
-               $dbw->insert( 'revision',
-                       array(
-                               'rev_id'         => $rev_id,
-                               'rev_page'       => $this->mPage,
-                               'rev_text_id'    => $this->mTextId,
-                               'rev_comment'    => $this->mComment,
-                               'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
-                               'rev_user'       => $this->mUser,
-                               'rev_user_text'  => $this->mUserText,
-                               'rev_timestamp'  => $dbw->timestamp( 
$this->mTimestamp ),
-                               'rev_deleted'    => $this->mDeleted,
-                               'rev_len'        => $this->mSize,
-                               'rev_parent_id'  => is_null( $this->mParentId )
-                                       ? $this->getPreviousRevisionId( $dbw )
-                                       : $this->mParentId,
-                               'rev_sha1'       => is_null( $this->mSha1 )
-                                       ? Revision::base36Sha1( $this->mText )
-                                       : $this->mSha1
-                       ), __METHOD__
+               $data = array(
+                       'rev_id'         => $rev_id,
+                       'rev_page'       => $this->mPage,
+                       'rev_text_id'    => $this->mTextId,
+                       'rev_comment'    => $this->mComment,
+                       'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
+                       'rev_user'       => $this->mUser,
+                       'rev_user_text'  => $this->mUserText,
+                       'rev_timestamp'  => $dbw->timestamp( $this->mTimestamp 
),
+                       'rev_deleted'    => $this->mDeleted,
+                       'rev_len'        => $this->mSize,
+                       'rev_parent_id'  => is_null( $this->mParentId )
+                               ? $this->getPreviousRevisionId( $dbw )
+                               : $this->mParentId
                );
+               
+               global $wmfUseRevSha1Columns;
+               if ( !empty( $wmfUseRevSha1Columns ) ) {
+                       $data['rev_sha1'] = is_null( $this->mSha1 )
+                               ? Revision::base36Sha1( $this->mText )
+                               : $this->mSha1;
+               }
+               $dbw->insert( 'revision', $data, __METHOD__ );
 
                $this->mId = !is_null( $rev_id ) ? $rev_id : $dbw->insertId();
 
@@ -1096,7 +1103,7 @@
 
                $current = $dbw->selectRow(
                        array( 'page', 'revision' ),
-                       array( 'page_latest', 'rev_text_id', 'rev_len', 
'rev_sha1' ),
+                       self::selectFields(),
                        array(
                                'page_id' => $pageId,
                                'page_latest=rev_id',
@@ -1111,7 +1118,7 @@
                                'text_id'    => $current->rev_text_id,
                                'parent_id'  => $current->page_latest,
                                'len'        => $current->rev_len,
-                               'sha1'       => $current->rev_sha1
+                               'sha1'       => isset( $current->rev_sha1 ) ? 
$current->rev_sha1 : null
                                ) );
                } else {
                        $revision = null;

Modified: branches/wmf/1.19wmf1/includes/WikiPage.php
===================================================================
--- branches/wmf/1.19wmf1/includes/WikiPage.php 2012-02-14 20:56:14 UTC (rev 
111485)
+++ branches/wmf/1.19wmf1/includes/WikiPage.php 2012-02-14 21:02:27 UTC (rev 
111486)
@@ -1993,25 +1993,30 @@
                //
                // In the future, we may keep revisions and mark them with
                // the rev_deleted field, which is reserved for this purpose.
+               $data = array(
+                       'ar_namespace'  => 'page_namespace',
+                       'ar_title'      => 'page_title',
+                       'ar_comment'    => 'rev_comment',
+                       'ar_user'       => 'rev_user',
+                       'ar_user_text'  => 'rev_user_text',
+                       'ar_timestamp'  => 'rev_timestamp',
+                       'ar_minor_edit' => 'rev_minor_edit',
+                       'ar_rev_id'     => 'rev_id',
+                       'ar_parent_id'  => 'rev_parent_id',
+                       'ar_text_id'    => 'rev_text_id',
+                       'ar_text'       => '\'\'', // Be explicit to appease
+                       'ar_flags'      => '\'\'', // MySQL's "strict mode"...
+                       'ar_len'        => 'rev_len',
+                       'ar_page_id'    => 'page_id',
+                       'ar_deleted'    => $bitfield
+               );
+               global $wmfUseRevSha1Columns;
+               if ( !empty( $wmfUseRevSha1Columns ) ) {
+                       $data['ar_sha1'] = 'rev_sha1';
+               }
                $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
+                       $data, 
                        array(
-                               'ar_namespace'  => 'page_namespace',
-                               'ar_title'      => 'page_title',
-                               'ar_comment'    => 'rev_comment',
-                               'ar_user'       => 'rev_user',
-                               'ar_user_text'  => 'rev_user_text',
-                               'ar_timestamp'  => 'rev_timestamp',
-                               'ar_minor_edit' => 'rev_minor_edit',
-                               'ar_rev_id'     => 'rev_id',
-                               'ar_parent_id'  => 'rev_parent_id',
-                               'ar_text_id'    => 'rev_text_id',
-                               'ar_text'       => '\'\'', // Be explicit to 
appease
-                               'ar_flags'      => '\'\'', // MySQL's "strict 
mode"...
-                               'ar_len'        => 'rev_len',
-                               'ar_page_id'    => 'page_id',
-                               'ar_deleted'    => $bitfield,
-                               'ar_sha1'       => 'rev_sha1'
-                       ), array(
                                'page_id' => $id,
                                'page_id = rev_page'
                        ), __METHOD__

Modified: branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php
===================================================================
--- branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php  2012-02-14 
20:56:14 UTC (rev 111485)
+++ branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php  2012-02-14 
21:02:27 UTC (rev 111486)
@@ -102,7 +102,10 @@
                $this->addFieldsIf( 'ar_comment', $fld_comment || 
$fld_parsedcomment );
                $this->addFieldsIf( 'ar_minor_edit', $fld_minor );
                $this->addFieldsIf( 'ar_len', $fld_len );
-               $this->addFieldsIf( 'ar_sha1', $fld_sha1 );
+               global $wmfUseRevSha1Columns;
+               if ( !empty( $wmfUseRevSha1Columns ) ) {
+                       $this->addFieldsIf( 'ar_sha1', $fld_sha1 );
+               }
 
                if ( $fld_content ) {
                        $this->addTables( 'text' );
@@ -236,7 +239,7 @@
                                $rev['len'] = $row->ar_len;
                        }
                        if ( $fld_sha1 ) {
-                               if ( $row->ar_sha1 != '' ) {
+                               if ( isset( $row->ar_sha1 ) && $row->ar_sha1 != 
'' ) {
                                        $rev['sha1'] = wfBaseConvert( 
$row->ar_sha1, 36, 16, 40 );
                                } else {
                                        $rev['sha1'] = '';


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to