Refactoring handling of the rev_delete database field, which is not
needed to select, when the suppress option is set.
Also added a new const, to avoid a comment about that things should be
15 ...
Change-Id: Ia5bcb835172bf6c10e2e872555fc67e91806ebe1
const DELETED_USER = 4;
const DELETED_RESTRICTED = 8;
const SUPPRESSED_USER = 12; // convenience
const DELETED_USER = 4;
const DELETED_RESTRICTED = 8;
const SUPPRESSED_USER = 12; // convenience
+ const SUPPRESSED_ALL = 15; // convenience
// Audience options for accessors
const FOR_PUBLIC = 1;
// Audience options for accessors
const FOR_PUBLIC = 1;
// Bitfields to further suppress the content
if ( $this->suppress ) {
// Bitfields to further suppress the content
if ( $this->suppress ) {
- $bitfield = 0;
- // This should be 15...
- $bitfield |= Revision::DELETED_TEXT;
- $bitfield |= Revision::DELETED_COMMENT;
- $bitfield |= Revision::DELETED_USER;
- $bitfield |= Revision::DELETED_RESTRICTED;
+ $bitfield = Revision::SUPPRESSED_ALL;
} else {
$bitfield = 'oi_deleted';
}
} else {
$bitfield = 'oi_deleted';
}
'fa_deleted_timestamp' => $encTimestamp,
'fa_deleted_reason' => $encReason,
'fa_deleted' => $this->suppress ? $bitfield : 0,
'fa_deleted_timestamp' => $encTimestamp,
'fa_deleted_reason' => $encReason,
'fa_deleted' => $this->suppress ? $bitfield : 0,
'fa_name' => 'img_name',
'fa_archive_name' => 'NULL',
'fa_size' => 'img_size',
'fa_name' => 'img_name',
'fa_archive_name' => 'NULL',
'fa_size' => 'img_size',
+ $fields = Revision::selectFields();
+ $bitfield = false;
+
// Bitfields to further suppress the content
if ( $suppress ) {
// Bitfields to further suppress the content
if ( $suppress ) {
- $bitfield = 0;
- // This should be 15...
- $bitfield |= Revision::DELETED_TEXT;
- $bitfield |= Revision::DELETED_COMMENT;
- $bitfield |= Revision::DELETED_USER;
- $bitfield |= Revision::DELETED_RESTRICTED;
- $deletionFields = [ $dbw->addQuotes( $bitfield ) . ' AS deleted' ];
- } else {
- $deletionFields = [ 'rev_deleted AS deleted' ];
+ $bitfield = Revision::SUPPRESSED_ALL;
+ $fields = array_diff( $fields, [ 'rev_deleted' ] );
}
// For now, shunt the revision data into the archive table.
}
// For now, shunt the revision data into the archive table.
// the rev_deleted field, which is reserved for this purpose.
// Get all of the page revisions
// the rev_deleted field, which is reserved for this purpose.
// Get all of the page revisions
- $fields = array_diff( Revision::selectFields(), [ 'rev_deleted' ] );
$res = $dbw->select(
'revision',
$res = $dbw->select(
'revision',
- array_merge( $fields, $deletionFields ),
[ 'rev_page' => $id ],
__METHOD__,
'FOR UPDATE'
[ 'rev_page' => $id ],
__METHOD__,
'FOR UPDATE'
'ar_flags' => '',
'ar_len' => $row->rev_len,
'ar_page_id' => $id,
'ar_flags' => '',
'ar_len' => $row->rev_len,
'ar_page_id' => $id,
- 'ar_deleted' => $row->deleted,
+ 'ar_deleted' => $suppress ? $bitfield : $row->rev_deleted,
'ar_sha1' => $row->rev_sha1,
];
if ( $wgContentHandlerUseDB ) {
'ar_sha1' => $row->rev_sha1,
];
if ( $wgContentHandlerUseDB ) {