Index: trunk/phase3/maintenance/ora/tables.sql |
— | — | @@ -638,3 +638,11 @@ |
639 | 639 | RETURN (x + y - BITAND(x, y)); |
640 | 640 | END; |
641 | 641 | /*$mw$*/ |
| 642 | + |
| 643 | +/*$mw$*/ |
| 644 | +CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS |
| 645 | +BEGIN |
| 646 | + RETURN (4294967295 - x); |
| 647 | +END; |
| 648 | +/*$mw$*/ |
| 649 | + |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -697,13 +697,13 @@ |
698 | 698 | $user = $this->getUser(); |
699 | 699 | $pageId = $this->getId(); |
700 | 700 | |
701 | | - $hideBit = Revision::DELETED_USER; // username hidden? |
| 701 | + $deletedBit = $dbr->bitAnd('rev_deleted', Revision::DELETED_USER); // username hidden? |
702 | 702 | |
703 | 703 | $sql = "SELECT {$userTable}.*, MAX(rev_timestamp) as timestamp |
704 | 704 | FROM $revTable LEFT JOIN $userTable ON rev_user = user_id |
705 | 705 | WHERE rev_page = $pageId |
706 | 706 | AND rev_user != $user |
707 | | - AND rev_deleted & $hideBit = 0 |
| 707 | + AND $deletedBit = 0 |
708 | 708 | GROUP BY rev_user, rev_user_text, user_real_name |
709 | 709 | ORDER BY timestamp DESC"; |
710 | 710 | |
— | — | @@ -2213,7 +2213,7 @@ |
2214 | 2214 | // Find out if there was only one contributor |
2215 | 2215 | // Only scan the last 20 revisions |
2216 | 2216 | $res = $dbw->select( 'revision', 'rev_user_text', |
2217 | | - array( 'rev_page' => $this->getID(), 'rev_deleted & '.Revision::DELETED_USER.'=0' ), |
| 2217 | + array( 'rev_page' => $this->getID(), $dbw->bitAnd('rev_deleted', Revision::DELETED_USER) . ' = 0' ), |
2218 | 2218 | __METHOD__, |
2219 | 2219 | array( 'LIMIT' => 20 ) |
2220 | 2220 | ); |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -1001,6 +1001,7 @@ |
1002 | 1002 | return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail ); |
1003 | 1003 | } |
1004 | 1004 | |
| 1005 | + /* redundand ... will remove after confirming bitwise operations functionality |
1005 | 1006 | public function makeList( $a, $mode = LIST_COMMA ) { |
1006 | 1007 | if ( !is_array( $a ) ) { |
1007 | 1008 | throw new DBUnexpectedError( $this, 'DatabaseOracle::makeList called with incorrect parameters' ); |
— | — | @@ -1032,7 +1033,21 @@ |
1033 | 1034 | |
1034 | 1035 | return parent::makeList($a2, $mode); |
1035 | 1036 | } |
| 1037 | + */ |
1036 | 1038 | |
| 1039 | + function bitNot($field) { |
| 1040 | + //expecting bit-fields smaller than 4bytes |
| 1041 | + return 'BITNOT('.$bitField.')'; |
| 1042 | + } |
| 1043 | + |
| 1044 | + function bitAnd($fieldLeft, $fieldRight) { |
| 1045 | + return 'BITAND('$fieldLeft.', '.$fieldRight.')'; |
| 1046 | + } |
| 1047 | + |
| 1048 | + function bitOr($fieldLeft, $fieldRight) { |
| 1049 | + return 'BITOR('$fieldLeft.', '.$fieldRight.')'; |
| 1050 | + } |
| 1051 | + |
1037 | 1052 | public function setTimeout( $timeout ) { |
1038 | 1053 | // @todo fixme no-op |
1039 | 1054 | } |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -1441,6 +1441,22 @@ |
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
| 1445 | + * Bitwise operations |
| 1446 | + */ |
| 1447 | + |
| 1448 | + function bitNot($field) { |
| 1449 | + return '~'.$bitField; |
| 1450 | + } |
| 1451 | + |
| 1452 | + function bitAnd($fieldLeft, $fieldRight) { |
| 1453 | + return $fieldLeft.'&'.$fieldRight; |
| 1454 | + } |
| 1455 | + |
| 1456 | + function bitOr($fieldLeft, $fieldRight) { |
| 1457 | + return $fieldLeft.'|'.$fieldRight; |
| 1458 | + } |
| 1459 | + |
| 1460 | + /** |
1445 | 1461 | * Change the current database |
1446 | 1462 | */ |
1447 | 1463 | function selectDB( $db ) { |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -1411,7 +1411,7 @@ |
1412 | 1412 | array( 'oi_archive_name' ), |
1413 | 1413 | array( 'oi_name' => $this->file->getName(), |
1414 | 1414 | 'oi_archive_name IN (' . $dbw->makeList( array_keys($oldRels) ) . ')', |
1415 | | - 'oi_deleted & ' . File::DELETED_FILE => File::DELETED_FILE ), |
| 1415 | + $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE ), |
1416 | 1416 | __METHOD__ ); |
1417 | 1417 | while( $row = $dbw->fetchObject( $res ) ) { |
1418 | 1418 | $privateFiles[$row->oi_archive_name] = 1; |
Index: trunk/phase3/includes/filerepo/LocalRepo.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | $inuse = $dbw->selectField( 'oldimage', '1', |
52 | 52 | array( 'oi_sha1' => $sha1, |
53 | 53 | "oi_archive_name LIKE '%.{$ext}'", |
54 | | - 'oi_deleted & '.File::DELETED_FILE => File::DELETED_FILE ), |
| 54 | + $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE ), |
55 | 55 | __METHOD__, array( 'FOR UPDATE' ) ); |
56 | 56 | } |
57 | 57 | if ( !$inuse ) { |
Index: trunk/phase3/includes/Export.php |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | wfProfileIn( $fname ); |
157 | 157 | $this->author_list = "<contributors>"; |
158 | 158 | //rev_deleted |
159 | | - $nothidden = '(rev_deleted & '.Revision::DELETED_USER.') = 0'; |
| 159 | + $nothidden = '('.$this->db->bitAnd('rev_deleted', Revision::DELETED_USER) . ') = 0'; |
160 | 160 | |
161 | 161 | $sql = "SELECT DISTINCT rev_user_text,rev_user FROM {$page},{$revision} |
162 | 162 | WHERE page_id=rev_page AND $nothidden AND " . $cond ; |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -681,7 +681,7 @@ |
682 | 682 | $this->mConds['log_user'] = $userid; |
683 | 683 | // Paranoia: avoid brute force searches (bug 17342) |
684 | 684 | if( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
685 | | - $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0'; |
| 685 | + $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0'; |
686 | 686 | } |
687 | 687 | $this->user = $usertitle->getText(); |
688 | 688 | } |
— | — | @@ -725,7 +725,7 @@ |
726 | 726 | } |
727 | 727 | // Paranoia: avoid brute force searches (bug 17342) |
728 | 728 | if( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
729 | | - $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0'; |
| 729 | + $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0'; |
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php |
— | — | @@ -120,10 +120,10 @@ |
121 | 121 | |
122 | 122 | // Paranoia: avoid brute force searches (bug 17342) |
123 | 123 | if (!is_null($title)) { |
124 | | - $this->addWhere('log_deleted & ' . LogPage::DELETED_ACTION . ' = 0'); |
| 124 | + $this->addWhere($db->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0'); |
125 | 125 | } |
126 | 126 | if (!is_null($user)) { |
127 | | - $this->addWhere('log_deleted & ' . LogPage::DELETED_USER . ' = 0'); |
| 127 | + $this->addWhere($db->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0'); |
128 | 128 | } |
129 | 129 | |
130 | 130 | $count = 0; |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -120,6 +120,7 @@ |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
| 124 | + $db = $this->getDB(); |
124 | 125 | $this->addTables('revision'); |
125 | 126 | $this->addFields(Revision::selectFields()); |
126 | 127 | $this->addTables('page'); |
— | — | @@ -219,11 +220,11 @@ |
220 | 221 | $this->addWhereFld('rev_user_text', $params['user']); |
221 | 222 | } elseif (!is_null($params['excludeuser'])) { |
222 | 223 | $this->addWhere('rev_user_text != ' . |
223 | | - $this->getDB()->addQuotes($params['excludeuser'])); |
| 224 | + $db->addQuotes($params['excludeuser'])); |
224 | 225 | } |
225 | 226 | if(!is_null($params['user']) || !is_null($params['excludeuser'])) { |
226 | 227 | // Paranoia: avoid brute force searches (bug 17342) |
227 | | - $this->addWhere('rev_deleted & ' . Revision::DELETED_USER . ' = 0'); |
| 228 | + $this->addWhere($db->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0'); |
228 | 229 | } |
229 | 230 | } |
230 | 231 | elseif ($revCount > 0) { |
— | — | @@ -283,7 +284,6 @@ |
284 | 285 | $count = 0; |
285 | 286 | $res = $this->select(__METHOD__); |
286 | 287 | |
287 | | - $db = $this->getDB(); |
288 | 288 | while ($row = $db->fetchObject($res)) { |
289 | 289 | |
290 | 290 | if (++ $count > $limit) { |
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | } |
164 | 164 | |
165 | 165 | if(!$wgUser->isAllowed('hideuser')) |
166 | | - $this->addWhere('rev_deleted & ' . Revision::DELETED_USER . ' = 0'); |
| 166 | + $this->addWhere($this->getDB()->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0'); |
167 | 167 | // We only want pages by the specified users. |
168 | 168 | if($this->prefixMode) |
169 | 169 | $this->addWhere("rev_user_text LIKE '" . $this->getDB()->escapeLike($this->userprefix) . "%'"); |
Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -411,7 +411,7 @@ |
412 | 412 | $conds = array_merge( $userCond, $this->getNamespaceCond() ); |
413 | 413 | // Paranoia: avoid brute force searches (bug 17342) |
414 | 414 | if( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
415 | | - $conds[] = 'rev_deleted & ' . Revision::DELETED_USER . ' = 0'; |
| 415 | + $conds[] = $this->mDb->bitAnd('rev_deleted', Revision::DELETED_USER) . ' = 0'; |
416 | 416 | } |
417 | 417 | $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' ); |
418 | 418 | |
Index: trunk/phase3/includes/specials/SpecialDeletedContributions.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | $conds = array_merge( $userCond, $this->getNamespaceCond() ); |
33 | 33 | // Paranoia: avoid brute force searches (bug 17792) |
34 | 34 | if( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
35 | | - $conds[] = 'ar_deleted & ' . Revision::DELETED_USER . ' = 0'; |
| 35 | + $conds[] = $this->mDb->bitAnd('ar_deleted', Revision::DELETED_USER) . ' = 0'; |
36 | 36 | } |
37 | 37 | return array( |
38 | 38 | 'tables' => array( 'archive' ), |