r94290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94289‎ | r94290 | r94291 >
Date:21:54, 11 August 2011
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
Follow-up r94289: code changes to fill the new fields on insertion and select them
Modified paths:
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Revision.php
@@ -110,7 +110,9 @@
111111 'minor_edit' => $row->ar_minor_edit,
112112 'text_id' => isset( $row->ar_text_id ) ? $row->ar_text_id : null,
113113 'deleted' => $row->ar_deleted,
114 - 'len' => $row->ar_len);
 114+ 'len' => $row->ar_len,
 115+ 'sha1' => $row->ar_sha1
 116+ );
115117 if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
116118 // Pre-1.5 ar_text row
117119 $attribs['text'] = self::getRevisionText( $row, 'ar_' );
@@ -301,7 +303,8 @@
302304 'rev_minor_edit',
303305 'rev_deleted',
304306 'rev_len',
305 - 'rev_parent_id'
 307+ 'rev_parent_id',
 308+ 'rev_sha1'
306309 );
307310 }
308311
@@ -357,6 +360,12 @@
358361 $this->mSize = intval( $row->rev_len );
359362 }
360363
 364+ if ( !isset( $row->rev_sha1 ) ) {
 365+ $this->mSha1 = null;
 366+ } else {
 367+ $this->mSha1 = $row->rev_sha1;
 368+ }
 369+
361370 if( isset( $row->page_latest ) ) {
362371 $this->mCurrent = ( $row->rev_id == $row->page_latest );
363372 $this->mTitle = Title::newFromRow( $row );
@@ -375,7 +384,7 @@
376385 }
377386 } elseif( is_array( $row ) ) {
378387 // Build a new revision to be saved...
379 - global $wgUser;
 388+ global $wgUser; // ugh
380389
381390 $this->mId = isset( $row['id'] ) ? intval( $row['id'] ) : null;
382391 $this->mPage = isset( $row['page'] ) ? intval( $row['page'] ) : null;
@@ -387,6 +396,7 @@
388397 $this->mDeleted = isset( $row['deleted'] ) ? intval( $row['deleted'] ) : 0;
389398 $this->mSize = isset( $row['len'] ) ? intval( $row['len'] ) : null;
390399 $this->mParentId = isset( $row['parent_id'] ) ? intval( $row['parent_id'] ) : null;
 400+ $this->mSha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null;
391401
392402 // Enforce spacing trimming on supplied text
393403 $this->mComment = isset( $row['comment'] ) ? trim( strval( $row['comment'] ) ) : null;
@@ -899,8 +909,12 @@
900910 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
901911 'rev_deleted' => $this->mDeleted,
902912 'rev_len' => $this->mSize,
903 - 'rev_parent_id' => is_null($this->mParentId) ?
904 - $this->getPreviousRevisionId( $dbw ) : $this->mParentId
 913+ 'rev_parent_id' => is_null( $this->mParentId )
 914+ ? $this->getPreviousRevisionId( $dbw )
 915+ : $this->mParentId,
 916+ 'rev_sha1' => is_null( $this->mSha1 )
 917+ ? Revision::base36Sha1( $this->mText )
 918+ : $this->mSha1
905919 ), __METHOD__
906920 );
907921
@@ -913,6 +927,15 @@
914928 }
915929
916930 /**
 931+ * Get the base 36 SHA-1 value for a string of text
 932+ * @param $text String
 933+ * @return String
 934+ */
 935+ public static function base36Sha1( $text ) {
 936+ return wfBaseConvert( sha1( $text ), 16, 36, 31 );
 937+ }
 938+
 939+ /**
917940 * Lazy-load the revision's text.
918941 * Currently hardcoded to the 'text' table storage engine.
919942 *
Index: trunk/phase3/includes/WikiPage.php
@@ -1662,7 +1662,8 @@
16631663 'ar_flags' => '\'\'', // MySQL's "strict mode"...
16641664 'ar_len' => 'rev_len',
16651665 'ar_page_id' => 'page_id',
1666 - 'ar_deleted' => $bitfield
 1666+ 'ar_deleted' => $bitfield,
 1667+ 'ar_sha1' => 'rev_sha1'
16671668 ), array(
16681669 'page_id' => $id,
16691670 'page_id = rev_page'
Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -124,7 +124,7 @@
125125 $res = $dbr->select( 'archive',
126126 array(
127127 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text',
128 - 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id'
 128+ 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1'
129129 ),
130130 array( 'ar_namespace' => $this->title->getNamespace(),
131131 'ar_title' => $this->title->getDBkey() ),
@@ -464,7 +464,8 @@
465465 'ar_text_id',
466466 'ar_deleted',
467467 'ar_page_id',
468 - 'ar_len' ),
 468+ 'ar_len',
 469+ 'ar_sha1' ),
469470 /* WHERE */ array(
470471 'ar_namespace' => $this->title->getNamespace(),
471472 'ar_title' => $this->title->getDBkey(),

Sign-offs

UserFlagDate
Catropeinspected10:32, 12 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r94541Revert r94289, r94290, r94294, r94333, r94345, r94362, r94370 -- core schema ...brion18:24, 15 August 2011
r94547Followup r94541 (reverts of r94289 undiscussed core schema change and followu...brion18:52, 15 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94289* Added rev_sha1 and ar_sha1 columns to revision/archive tables (useful for b......aaron21:52, 11 August 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   18:26, 15 August 2011

undiscussed core schema change, reverted in r94541.

#Comment by Duplicatebug (talk | contribs)   18:41, 15 August 2011

Only for documentation: You can fill rev_sha1 of the new revision in Revision::newNullRevision() with the existing value.

Status & tagging log