Index: trunk/phase3/includes/Revision.php |
— | — | @@ -110,7 +110,9 @@ |
111 | 111 | 'minor_edit' => $row->ar_minor_edit, |
112 | 112 | 'text_id' => isset( $row->ar_text_id ) ? $row->ar_text_id : null, |
113 | 113 | 'deleted' => $row->ar_deleted, |
114 | | - 'len' => $row->ar_len); |
| 114 | + 'len' => $row->ar_len, |
| 115 | + 'sha1' => $row->ar_sha1 |
| 116 | + ); |
115 | 117 | if ( isset( $row->ar_text ) && !$row->ar_text_id ) { |
116 | 118 | // Pre-1.5 ar_text row |
117 | 119 | $attribs['text'] = self::getRevisionText( $row, 'ar_' ); |
— | — | @@ -301,7 +303,8 @@ |
302 | 304 | 'rev_minor_edit', |
303 | 305 | 'rev_deleted', |
304 | 306 | 'rev_len', |
305 | | - 'rev_parent_id' |
| 307 | + 'rev_parent_id', |
| 308 | + 'rev_sha1' |
306 | 309 | ); |
307 | 310 | } |
308 | 311 | |
— | — | @@ -357,6 +360,12 @@ |
358 | 361 | $this->mSize = intval( $row->rev_len ); |
359 | 362 | } |
360 | 363 | |
| 364 | + if ( !isset( $row->rev_sha1 ) ) { |
| 365 | + $this->mSha1 = null; |
| 366 | + } else { |
| 367 | + $this->mSha1 = $row->rev_sha1; |
| 368 | + } |
| 369 | + |
361 | 370 | if( isset( $row->page_latest ) ) { |
362 | 371 | $this->mCurrent = ( $row->rev_id == $row->page_latest ); |
363 | 372 | $this->mTitle = Title::newFromRow( $row ); |
— | — | @@ -375,7 +384,7 @@ |
376 | 385 | } |
377 | 386 | } elseif( is_array( $row ) ) { |
378 | 387 | // Build a new revision to be saved... |
379 | | - global $wgUser; |
| 388 | + global $wgUser; // ugh |
380 | 389 | |
381 | 390 | $this->mId = isset( $row['id'] ) ? intval( $row['id'] ) : null; |
382 | 391 | $this->mPage = isset( $row['page'] ) ? intval( $row['page'] ) : null; |
— | — | @@ -387,6 +396,7 @@ |
388 | 397 | $this->mDeleted = isset( $row['deleted'] ) ? intval( $row['deleted'] ) : 0; |
389 | 398 | $this->mSize = isset( $row['len'] ) ? intval( $row['len'] ) : null; |
390 | 399 | $this->mParentId = isset( $row['parent_id'] ) ? intval( $row['parent_id'] ) : null; |
| 400 | + $this->mSha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null; |
391 | 401 | |
392 | 402 | // Enforce spacing trimming on supplied text |
393 | 403 | $this->mComment = isset( $row['comment'] ) ? trim( strval( $row['comment'] ) ) : null; |
— | — | @@ -899,8 +909,12 @@ |
900 | 910 | 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ), |
901 | 911 | 'rev_deleted' => $this->mDeleted, |
902 | 912 | '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 |
905 | 919 | ), __METHOD__ |
906 | 920 | ); |
907 | 921 | |
— | — | @@ -913,6 +927,15 @@ |
914 | 928 | } |
915 | 929 | |
916 | 930 | /** |
| 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 | + /** |
917 | 940 | * Lazy-load the revision's text. |
918 | 941 | * Currently hardcoded to the 'text' table storage engine. |
919 | 942 | * |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1662,7 +1662,8 @@ |
1663 | 1663 | 'ar_flags' => '\'\'', // MySQL's "strict mode"... |
1664 | 1664 | 'ar_len' => 'rev_len', |
1665 | 1665 | 'ar_page_id' => 'page_id', |
1666 | | - 'ar_deleted' => $bitfield |
| 1666 | + 'ar_deleted' => $bitfield, |
| 1667 | + 'ar_sha1' => 'rev_sha1' |
1667 | 1668 | ), array( |
1668 | 1669 | 'page_id' => $id, |
1669 | 1670 | 'page_id = rev_page' |
Index: trunk/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | $res = $dbr->select( 'archive', |
126 | 126 | array( |
127 | 127 | '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' |
129 | 129 | ), |
130 | 130 | array( 'ar_namespace' => $this->title->getNamespace(), |
131 | 131 | 'ar_title' => $this->title->getDBkey() ), |
— | — | @@ -464,7 +464,8 @@ |
465 | 465 | 'ar_text_id', |
466 | 466 | 'ar_deleted', |
467 | 467 | 'ar_page_id', |
468 | | - 'ar_len' ), |
| 468 | + 'ar_len', |
| 469 | + 'ar_sha1' ), |
469 | 470 | /* WHERE */ array( |
470 | 471 | 'ar_namespace' => $this->title->getNamespace(), |
471 | 472 | 'ar_title' => $this->title->getDBkey(), |