r96932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96931‎ | r96932 | r96933 >
Date:00:33, 13 September 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
REL1_18: MFT r96930
Modified paths:
  • /branches/REL1_18/phase3/includes/db/Database.php (modified) (history)
  • /branches/REL1_18/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /branches/REL1_18/phase3/tests/phpunit/includes/db/DatabaseTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/tests/phpunit/includes/db/DatabaseTest.php
@@ -90,34 +90,6 @@
9191 $sql );
9292 }
9393
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 - }
12294 }
12395
12496
Index: branches/REL1_18/phase3/includes/db/Database.php
@@ -1670,15 +1670,6 @@
16711671 * - LIST_SET: comma separated with field names, like a SET clause
16721672 * - LIST_NAMES: comma separated field names
16731673 *
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 -
16831674 * @return string
16841675 */
16851676 function makeList( $a, $mode = LIST_COMMA ) {
@@ -1702,13 +1693,6 @@
17031694 $first = false;
17041695 }
17051696
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 -
17131697 if ( ( $mode == LIST_AND || $mode == LIST_OR ) && is_numeric( $field ) ) {
17141698 $list .= "($value)";
17151699 } elseif ( ( $mode == LIST_SET ) && is_numeric( $field ) ) {
@@ -1721,12 +1705,9 @@
17221706 // Don't necessarily assume the single key is 0; we don't
17231707 // enforce linear numeric ordering on other arrays here.
17241708 $value = array_values( $value );
1725 -
1726 - $operator = $not ? ' != ' : ' = ';
1727 - $list .= $field . $operator . $this->addQuotes( $value[0] );
 1709+ $list .= $field . " = " . $this->addQuotes( $value[0] );
17281710 } else {
1729 - $operator = $not ? ' NOT IN ' : ' IN ';
1730 - $list .= $field . $operator . "(" . $this->makeList( $value ) . ")";
 1711+ $list .= $field . " IN (" . $this->makeList( $value ) . ") ";
17311712 }
17321713 } elseif ( $value === null ) {
17331714 if ( $mode == LIST_AND || $mode == LIST_OR ) {
Property changes on: branches/REL1_18/phase3/includes/db/Database.php
___________________________________________________________________
Modified: svn:mergeinfo
17341715 Merged /trunk/phase3/includes/db/Database.php:r96930
Index: branches/REL1_18/phase3/includes/specials/SpecialRecentchanges.php
@@ -325,24 +325,25 @@
326326
327327 # Namespace filtering
328328 if( $opts['namespace'] !== '' ) {
329 - $namespaces[] = $opts['namespace'];
 329+ $selectedNS = $dbr->addQuotes( $opts['namespace'] );
 330+ $operator = $opts['invert'] ? '!=' : '=';
 331+ $boolean = $opts['invert'] ? 'AND' : 'OR';
330332
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)";
336344 }
337345
338 - $condition = $dbr->makeList(
339 - array( 'rc_namespace' . $inversionSuffix
340 - => $namespaces ),
341 - LIST_AND
342 - );
343 -
344346 $conds[] = $condition;
345347 }
346 -
347348 return $conds;
348349 }
349350

Follow-up revisions

RevisionCommit summaryAuthorDate
r96952REL1_18 MFT r96950reedy11:03, 13 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96930Revert r87992 and followups r87998, r89028 (Support abstraction for 'NOT IN' ...demon00:19, 13 September 2011

Comments

#Comment by Siebrand (talk | contribs)   09:12, 13 September 2011

Probably throws notices as it's master r96930.

#Comment by Siebrand (talk | contribs)   18:14, 13 September 2011

Follow-up rev missing.

#Comment by Reedy (talk | contribs)   18:15, 13 September 2011

r96952

Added now

Status & tagging log