r111486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111485‎ | r111486 | r111487 >
Date:21:02, 14 February 2012
Author:aaron
Status:ok (Comments)
Tags:
Comment:
(bug 34285) - Make use of rev_sha1 per-wiki configurable.
Modified paths:
  • /branches/wmf/1.19wmf1/includes/Export.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes/Revision.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes/WikiPage.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/includes/Export.php
@@ -487,7 +487,7 @@
488488 }
489489 }
490490
491 - if ( $row->rev_sha1 ) {
 491+ if ( isset( $row->rev_sha1 ) ) {
492492 $out .= " " . Xml::element('sha1', null, strval($row->rev_sha1) ) . "\n";
493493 } else {
494494 $out .= " <sha1/>\n";
Index: branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php
@@ -102,7 +102,10 @@
103103 $this->addFieldsIf( 'ar_comment', $fld_comment || $fld_parsedcomment );
104104 $this->addFieldsIf( 'ar_minor_edit', $fld_minor );
105105 $this->addFieldsIf( 'ar_len', $fld_len );
106 - $this->addFieldsIf( 'ar_sha1', $fld_sha1 );
 106+ global $wmfUseRevSha1Columns;
 107+ if ( !empty( $wmfUseRevSha1Columns ) ) {
 108+ $this->addFieldsIf( 'ar_sha1', $fld_sha1 );
 109+ }
107110
108111 if ( $fld_content ) {
109112 $this->addTables( 'text' );
@@ -236,7 +239,7 @@
237240 $rev['len'] = $row->ar_len;
238241 }
239242 if ( $fld_sha1 ) {
240 - if ( $row->ar_sha1 != '' ) {
 243+ if ( isset( $row->ar_sha1 ) && $row->ar_sha1 != '' ) {
241244 $rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 );
242245 } else {
243246 $rev['sha1'] = '';
Index: branches/wmf/1.19wmf1/includes/Revision.php
@@ -323,7 +323,7 @@
324324 * a new revision.
325325 */
326326 public static function selectFields() {
327 - return array(
 327+ $fields = array(
328328 'rev_id',
329329 'rev_page',
330330 'rev_text_id',
@@ -334,9 +334,13 @@
335335 'rev_minor_edit',
336336 'rev_deleted',
337337 'rev_len',
338 - 'rev_parent_id',
339 - 'rev_sha1'
 338+ 'rev_parent_id'
340339 );
 340+ global $wmfUseRevSha1Columns;
 341+ if ( !empty( $wmfUseRevSha1Columns ) ) {
 342+ $fields[] = 'rev_sha1';
 343+ }
 344+ return $fields;
341345 }
342346
343347 /**
@@ -979,26 +983,29 @@
980984 $rev_id = isset( $this->mId )
981985 ? $this->mId
982986 : $dbw->nextSequenceValue( 'revision_rev_id_seq' );
983 - $dbw->insert( 'revision',
984 - array(
985 - 'rev_id' => $rev_id,
986 - 'rev_page' => $this->mPage,
987 - 'rev_text_id' => $this->mTextId,
988 - 'rev_comment' => $this->mComment,
989 - 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
990 - 'rev_user' => $this->mUser,
991 - 'rev_user_text' => $this->mUserText,
992 - 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
993 - 'rev_deleted' => $this->mDeleted,
994 - 'rev_len' => $this->mSize,
995 - 'rev_parent_id' => is_null( $this->mParentId )
996 - ? $this->getPreviousRevisionId( $dbw )
997 - : $this->mParentId,
998 - 'rev_sha1' => is_null( $this->mSha1 )
999 - ? Revision::base36Sha1( $this->mText )
1000 - : $this->mSha1
1001 - ), __METHOD__
 987+ $data = array(
 988+ 'rev_id' => $rev_id,
 989+ 'rev_page' => $this->mPage,
 990+ 'rev_text_id' => $this->mTextId,
 991+ 'rev_comment' => $this->mComment,
 992+ 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0,
 993+ 'rev_user' => $this->mUser,
 994+ 'rev_user_text' => $this->mUserText,
 995+ 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
 996+ 'rev_deleted' => $this->mDeleted,
 997+ 'rev_len' => $this->mSize,
 998+ 'rev_parent_id' => is_null( $this->mParentId )
 999+ ? $this->getPreviousRevisionId( $dbw )
 1000+ : $this->mParentId
10021001 );
 1002+
 1003+ global $wmfUseRevSha1Columns;
 1004+ if ( !empty( $wmfUseRevSha1Columns ) ) {
 1005+ $data['rev_sha1'] = is_null( $this->mSha1 )
 1006+ ? Revision::base36Sha1( $this->mText )
 1007+ : $this->mSha1;
 1008+ }
 1009+ $dbw->insert( 'revision', $data, __METHOD__ );
10031010
10041011 $this->mId = !is_null( $rev_id ) ? $rev_id : $dbw->insertId();
10051012
@@ -1096,7 +1103,7 @@
10971104
10981105 $current = $dbw->selectRow(
10991106 array( 'page', 'revision' ),
1100 - array( 'page_latest', 'rev_text_id', 'rev_len', 'rev_sha1' ),
 1107+ self::selectFields(),
11011108 array(
11021109 'page_id' => $pageId,
11031110 'page_latest=rev_id',
@@ -1111,7 +1118,7 @@
11121119 'text_id' => $current->rev_text_id,
11131120 'parent_id' => $current->page_latest,
11141121 'len' => $current->rev_len,
1115 - 'sha1' => $current->rev_sha1
 1122+ 'sha1' => isset( $current->rev_sha1 ) ? $current->rev_sha1 : null
11161123 ) );
11171124 } else {
11181125 $revision = null;
Index: branches/wmf/1.19wmf1/includes/WikiPage.php
@@ -1993,25 +1993,30 @@
19941994 //
19951995 // In the future, we may keep revisions and mark them with
19961996 // the rev_deleted field, which is reserved for this purpose.
 1997+ $data = array(
 1998+ 'ar_namespace' => 'page_namespace',
 1999+ 'ar_title' => 'page_title',
 2000+ 'ar_comment' => 'rev_comment',
 2001+ 'ar_user' => 'rev_user',
 2002+ 'ar_user_text' => 'rev_user_text',
 2003+ 'ar_timestamp' => 'rev_timestamp',
 2004+ 'ar_minor_edit' => 'rev_minor_edit',
 2005+ 'ar_rev_id' => 'rev_id',
 2006+ 'ar_parent_id' => 'rev_parent_id',
 2007+ 'ar_text_id' => 'rev_text_id',
 2008+ 'ar_text' => '\'\'', // Be explicit to appease
 2009+ 'ar_flags' => '\'\'', // MySQL's "strict mode"...
 2010+ 'ar_len' => 'rev_len',
 2011+ 'ar_page_id' => 'page_id',
 2012+ 'ar_deleted' => $bitfield
 2013+ );
 2014+ global $wmfUseRevSha1Columns;
 2015+ if ( !empty( $wmfUseRevSha1Columns ) ) {
 2016+ $data['ar_sha1'] = 'rev_sha1';
 2017+ }
19972018 $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
 2019+ $data,
19982020 array(
1999 - 'ar_namespace' => 'page_namespace',
2000 - 'ar_title' => 'page_title',
2001 - 'ar_comment' => 'rev_comment',
2002 - 'ar_user' => 'rev_user',
2003 - 'ar_user_text' => 'rev_user_text',
2004 - 'ar_timestamp' => 'rev_timestamp',
2005 - 'ar_minor_edit' => 'rev_minor_edit',
2006 - 'ar_rev_id' => 'rev_id',
2007 - 'ar_parent_id' => 'rev_parent_id',
2008 - 'ar_text_id' => 'rev_text_id',
2009 - 'ar_text' => '\'\'', // Be explicit to appease
2010 - 'ar_flags' => '\'\'', // MySQL's "strict mode"...
2011 - 'ar_len' => 'rev_len',
2012 - 'ar_page_id' => 'page_id',
2013 - 'ar_deleted' => $bitfield,
2014 - 'ar_sha1' => 'rev_sha1'
2015 - ), array(
20162021 'page_id' => $id,
20172022 'page_id = rev_page'
20182023 ), __METHOD__

Sign-offs

UserFlagDate
Reedyinspected22:09, 14 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r112949fixed r111486, which caused bug 34890aaron13:04, 3 March 2012

Comments

#Comment by Reedy (talk | contribs)   22:08, 14 February 2012

Obviously wmfUseRevSha1Columns isn't actually defined anywhere (register_globals), it will be unconditionally set in WMF usage, and is only temporary, so we don't care too much about it

#Comment by Aaron Schulz (talk | contribs)   22:10, 14 February 2012

Why don't use register_globals anyway. Or at least, by God, I hope we don't.

#Comment by Aaron Schulz (talk | contribs)   22:19, 14 February 2012
  • We dont

Status & tagging log