Index: branches/REL1_18/phase3/tests/phpunit/includes/db/DatabaseTest.php |
— | — | @@ -90,34 +90,6 @@ |
91 | 91 | $sql ); |
92 | 92 | } |
93 | 93 | |
94 | | - function testMakeNotInList() { |
95 | | - $this->assertEquals( |
96 | | - "field IN ('0','1')", |
97 | | - $this->db->makeList( array( |
98 | | - 'field' => array( 0, 1 ) |
99 | | - ), LIST_AND ) |
100 | | - ); |
101 | | - $this->assertEquals( |
102 | | - "field NOT IN ('0','1')", |
103 | | - $this->db->makeList( array( |
104 | | - 'field!' => array( 0, 1 ) |
105 | | - ), LIST_AND ) |
106 | | - ); |
107 | | - |
108 | | - // make sure an array with only one value use = or != |
109 | | - $this->assertEquals( |
110 | | - "field = '777'", |
111 | | - $this->db->makeList( array( |
112 | | - 'field' => array( 777 ) |
113 | | - ), LIST_AND ) |
114 | | - ); |
115 | | - $this->assertEquals( |
116 | | - "field != '888'", |
117 | | - $this->db->makeList( array( |
118 | | - 'field!' => array( 888 ) |
119 | | - ), LIST_AND ) |
120 | | - ); |
121 | | - } |
122 | 94 | } |
123 | 95 | |
124 | 96 | |
Index: branches/REL1_18/phase3/includes/db/Database.php |
— | — | @@ -1670,15 +1670,6 @@ |
1671 | 1671 | * - LIST_SET: comma separated with field names, like a SET clause |
1672 | 1672 | * - LIST_NAMES: comma separated field names |
1673 | 1673 | * |
1674 | | - * In LIST_AND or LIST_OR modes, you can suffix a field with an exclamation |
1675 | | - * mark to generate a 'NOT IN' structure. |
1676 | | - * |
1677 | | - * Example: |
1678 | | - * $db->makeList( array( 'field!' => array( 1,2,3 ) ); |
1679 | | - * |
1680 | | - * outputs: |
1681 | | - * 'field' NOT IN ('1', '2', '3' ); |
1682 | | - |
1683 | 1674 | * @return string |
1684 | 1675 | */ |
1685 | 1676 | function makeList( $a, $mode = LIST_COMMA ) { |
— | — | @@ -1702,13 +1693,6 @@ |
1703 | 1694 | $first = false; |
1704 | 1695 | } |
1705 | 1696 | |
1706 | | - // Support 'NOT IN' by suffixing fieldname with an exclamation mark |
1707 | | - $not = false; |
1708 | | - if( substr($field,-1) == '!' ) { |
1709 | | - $not = true; |
1710 | | - $field = substr($field, 0, -1 ); |
1711 | | - } |
1712 | | - |
1713 | 1697 | if ( ( $mode == LIST_AND || $mode == LIST_OR ) && is_numeric( $field ) ) { |
1714 | 1698 | $list .= "($value)"; |
1715 | 1699 | } elseif ( ( $mode == LIST_SET ) && is_numeric( $field ) ) { |
— | — | @@ -1721,12 +1705,9 @@ |
1722 | 1706 | // Don't necessarily assume the single key is 0; we don't |
1723 | 1707 | // enforce linear numeric ordering on other arrays here. |
1724 | 1708 | $value = array_values( $value ); |
1725 | | - |
1726 | | - $operator = $not ? ' != ' : ' = '; |
1727 | | - $list .= $field . $operator . $this->addQuotes( $value[0] ); |
| 1709 | + $list .= $field . " = " . $this->addQuotes( $value[0] ); |
1728 | 1710 | } else { |
1729 | | - $operator = $not ? ' NOT IN ' : ' IN '; |
1730 | | - $list .= $field . $operator . "(" . $this->makeList( $value ) . ")"; |
| 1711 | + $list .= $field . " IN (" . $this->makeList( $value ) . ") "; |
1731 | 1712 | } |
1732 | 1713 | } elseif ( $value === null ) { |
1733 | 1714 | if ( $mode == LIST_AND || $mode == LIST_OR ) { |
Property changes on: branches/REL1_18/phase3/includes/db/Database.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1734 | 1715 | Merged /trunk/phase3/includes/db/Database.php:r96930 |
Index: branches/REL1_18/phase3/includes/specials/SpecialRecentchanges.php |
— | — | @@ -325,24 +325,25 @@ |
326 | 326 | |
327 | 327 | # Namespace filtering |
328 | 328 | if( $opts['namespace'] !== '' ) { |
329 | | - $namespaces[] = $opts['namespace']; |
| 329 | + $selectedNS = $dbr->addQuotes( $opts['namespace'] ); |
| 330 | + $operator = $opts['invert'] ? '!=' : '='; |
| 331 | + $boolean = $opts['invert'] ? 'AND' : 'OR'; |
330 | 332 | |
331 | | - $inversionSuffix = $opts['invert'] ? '!' : ''; |
332 | | - |
333 | | - if( $opts['associated'] ) { |
334 | | - # namespace association (bug 2429) |
335 | | - $namespaces[] = MWNamespace::getAssociated( $opts['namespace'] ); |
| 333 | + # namespace association (bug 2429) |
| 334 | + if( !$opts['associated'] ) { |
| 335 | + $condition = "rc_namespace $operator $selectedNS"; |
| 336 | + } else { |
| 337 | + # Also add the associated namespace |
| 338 | + $associatedNS = $dbr->addQuotes( |
| 339 | + MWNamespace::getAssociated( $opts['namespace'] ) |
| 340 | + ); |
| 341 | + $condition = "(rc_namespace $operator $selectedNS " |
| 342 | + . $boolean |
| 343 | + . " rc_namespace $operator $associatedNS)"; |
336 | 344 | } |
337 | 345 | |
338 | | - $condition = $dbr->makeList( |
339 | | - array( 'rc_namespace' . $inversionSuffix |
340 | | - => $namespaces ), |
341 | | - LIST_AND |
342 | | - ); |
343 | | - |
344 | 346 | $conds[] = $condition; |
345 | 347 | } |
346 | | - |
347 | 348 | return $conds; |
348 | 349 | } |
349 | 350 | |