Index: branches/wmf/1.19wmf1/includes/Export.php |
— | — | @@ -487,7 +487,7 @@ |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | | - if ( $row->rev_sha1 ) { |
| 491 | + if ( isset( $row->rev_sha1 ) ) { |
492 | 492 | $out .= " " . Xml::element('sha1', null, strval($row->rev_sha1) ) . "\n"; |
493 | 493 | } else { |
494 | 494 | $out .= " <sha1/>\n"; |
Index: branches/wmf/1.19wmf1/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -102,7 +102,10 @@ |
103 | 103 | $this->addFieldsIf( 'ar_comment', $fld_comment || $fld_parsedcomment ); |
104 | 104 | $this->addFieldsIf( 'ar_minor_edit', $fld_minor ); |
105 | 105 | $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 | + } |
107 | 110 | |
108 | 111 | if ( $fld_content ) { |
109 | 112 | $this->addTables( 'text' ); |
— | — | @@ -236,7 +239,7 @@ |
237 | 240 | $rev['len'] = $row->ar_len; |
238 | 241 | } |
239 | 242 | if ( $fld_sha1 ) { |
240 | | - if ( $row->ar_sha1 != '' ) { |
| 243 | + if ( isset( $row->ar_sha1 ) && $row->ar_sha1 != '' ) { |
241 | 244 | $rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 ); |
242 | 245 | } else { |
243 | 246 | $rev['sha1'] = ''; |
Index: branches/wmf/1.19wmf1/includes/Revision.php |
— | — | @@ -323,7 +323,7 @@ |
324 | 324 | * a new revision. |
325 | 325 | */ |
326 | 326 | public static function selectFields() { |
327 | | - return array( |
| 327 | + $fields = array( |
328 | 328 | 'rev_id', |
329 | 329 | 'rev_page', |
330 | 330 | 'rev_text_id', |
— | — | @@ -334,9 +334,13 @@ |
335 | 335 | 'rev_minor_edit', |
336 | 336 | 'rev_deleted', |
337 | 337 | 'rev_len', |
338 | | - 'rev_parent_id', |
339 | | - 'rev_sha1' |
| 338 | + 'rev_parent_id' |
340 | 339 | ); |
| 340 | + global $wmfUseRevSha1Columns; |
| 341 | + if ( !empty( $wmfUseRevSha1Columns ) ) { |
| 342 | + $fields[] = 'rev_sha1'; |
| 343 | + } |
| 344 | + return $fields; |
341 | 345 | } |
342 | 346 | |
343 | 347 | /** |
— | — | @@ -979,26 +983,29 @@ |
980 | 984 | $rev_id = isset( $this->mId ) |
981 | 985 | ? $this->mId |
982 | 986 | : $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 |
1002 | 1001 | ); |
| 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__ ); |
1003 | 1010 | |
1004 | 1011 | $this->mId = !is_null( $rev_id ) ? $rev_id : $dbw->insertId(); |
1005 | 1012 | |
— | — | @@ -1096,7 +1103,7 @@ |
1097 | 1104 | |
1098 | 1105 | $current = $dbw->selectRow( |
1099 | 1106 | array( 'page', 'revision' ), |
1100 | | - array( 'page_latest', 'rev_text_id', 'rev_len', 'rev_sha1' ), |
| 1107 | + self::selectFields(), |
1101 | 1108 | array( |
1102 | 1109 | 'page_id' => $pageId, |
1103 | 1110 | 'page_latest=rev_id', |
— | — | @@ -1111,7 +1118,7 @@ |
1112 | 1119 | 'text_id' => $current->rev_text_id, |
1113 | 1120 | 'parent_id' => $current->page_latest, |
1114 | 1121 | 'len' => $current->rev_len, |
1115 | | - 'sha1' => $current->rev_sha1 |
| 1122 | + 'sha1' => isset( $current->rev_sha1 ) ? $current->rev_sha1 : null |
1116 | 1123 | ) ); |
1117 | 1124 | } else { |
1118 | 1125 | $revision = null; |
Index: branches/wmf/1.19wmf1/includes/WikiPage.php |
— | — | @@ -1993,25 +1993,30 @@ |
1994 | 1994 | // |
1995 | 1995 | // In the future, we may keep revisions and mark them with |
1996 | 1996 | // 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 | + } |
1997 | 2018 | $dbw->insertSelect( 'archive', array( 'page', 'revision' ), |
| 2019 | + $data, |
1998 | 2020 | 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( |
2016 | 2021 | 'page_id' => $id, |
2017 | 2022 | 'page_id = rev_page' |
2018 | 2023 | ), __METHOD__ |