Index: trunk/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: trunk/phase3/includes/db/Database.php |
— | — | @@ -1712,15 +1712,6 @@ |
1713 | 1713 | * - LIST_SET: comma separated with field names, like a SET clause |
1714 | 1714 | * - LIST_NAMES: comma separated field names |
1715 | 1715 | * |
1716 | | - * In LIST_AND or LIST_OR modes, you can suffix a field with an exclamation |
1717 | | - * mark to generate a 'NOT IN' structure. |
1718 | | - * |
1719 | | - * Example: |
1720 | | - * $db->makeList( array( 'field!' => array( 1,2,3 ) ); |
1721 | | - * |
1722 | | - * outputs: |
1723 | | - * 'field' NOT IN ('1', '2', '3' ); |
1724 | | - |
1725 | 1716 | * @return string |
1726 | 1717 | */ |
1727 | 1718 | function makeList( $a, $mode = LIST_COMMA ) { |
— | — | @@ -1744,13 +1735,6 @@ |
1745 | 1736 | $first = false; |
1746 | 1737 | } |
1747 | 1738 | |
1748 | | - // Support 'NOT IN' by suffixing fieldname with an exclamation mark |
1749 | | - $not = false; |
1750 | | - if( substr($field,-1) == '!' ) { |
1751 | | - $not = true; |
1752 | | - $field = substr($field, 0, -1 ); |
1753 | | - } |
1754 | | - |
1755 | 1739 | if ( ( $mode == LIST_AND || $mode == LIST_OR ) && is_numeric( $field ) ) { |
1756 | 1740 | $list .= "($value)"; |
1757 | 1741 | } elseif ( ( $mode == LIST_SET ) && is_numeric( $field ) ) { |
— | — | @@ -1763,12 +1747,9 @@ |
1764 | 1748 | // Don't necessarily assume the single key is 0; we don't |
1765 | 1749 | // enforce linear numeric ordering on other arrays here. |
1766 | 1750 | $value = array_values( $value ); |
1767 | | - |
1768 | | - $operator = $not ? ' != ' : ' = '; |
1769 | | - $list .= $field . $operator . $this->addQuotes( $value[0] ); |
| 1751 | + $list .= $field . " = " . $this->addQuotes( $value[0] ); |
1770 | 1752 | } else { |
1771 | | - $operator = $not ? ' NOT IN ' : ' IN '; |
1772 | | - $list .= $field . $operator . "(" . $this->makeList( $value ) . ")"; |
| 1753 | + $list .= $field . " IN (" . $this->makeList( $value ) . ") "; |
1773 | 1754 | } |
1774 | 1755 | } elseif ( $value === null ) { |
1775 | 1756 | if ( $mode == LIST_AND || $mode == LIST_OR ) { |
Index: trunk/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 | |