Clarify comment on $wgRateLimits.
[lhc/web/wiklou.git] / includes / Database.php
index e0969f2..f611f8e 100644 (file)
@@ -35,6 +35,22 @@ class DBObject {
        }
 };
 
+/**
+ * Utility class
+ * @addtogroup Database
+ *
+ * This allows us to distinguish a blob from a normal string and an array of strings
+ */
+class Blob {
+       private $mData;
+       function __construct($data) {
+               $this->mData = $data;
+       }
+       function fetch() {
+               return $this->mData;
+       }
+};
+
 /**
  * Utility class.
  * @addtogroup Database
@@ -214,7 +230,7 @@ border=\"0\" ALT=\"Google\"></A>
 
                        $cache = new HTMLFileCache( $t );
                        if( $cache->isFileCached() ) {
-                               // FIXME: $msg is not defined on the next line.
+                               // @todo, FIXME: $msg is not defined on the next line.
                                $msg = '<p style="color: red"><b>'.$msg."<br />\n" .
                                        $cachederror . "</b></p>\n";
 
@@ -440,6 +456,14 @@ class Database {
                return true;
        }
 
+       /**
+        * Returns true if this database does an implicit order by when the column has an index
+        * For example: SELECT page_title FROM page LIMIT 1
+        */
+       function implicitOrderby() {
+               return true;
+       }
+
        /**
         * Returns true if this database can do a native search on IP columns
         * e.g. this works as expected: .. WHERE rc_ip = '127.42.12.102/32';
@@ -1540,7 +1564,15 @@ class Database {
                        } elseif ( ($mode == LIST_SET) && is_numeric( $field ) ) {
                                $list .= "$value";
                        } elseif ( ($mode == LIST_AND || $mode == LIST_OR) && is_array($value) ) {
-                               $list .= $field." IN (".$this->makeList($value).") ";
+                               if( count( $value ) == 0 ) {
+                                       // Empty input... or should this throw an error?
+                                       $list .= '0';
+                               } elseif( count( $value ) == 1 ) {
+                                       // Special-case single values, as IN isn't terribly efficient
+                                       $list .= $field." = ".$this->addQuotes( $value[0] );
+                               } else {
+                                       $list .= $field." IN (".$this->makeList($value).") ";
+                               }
                        } elseif( is_null($value) ) {
                                if ( $mode == LIST_AND || $mode == LIST_OR ) {
                                        $list .= "$field IS ";
@@ -1582,7 +1614,7 @@ class Database {
                global $wgSharedDB;
                # Skip quoted literals
                if ( $name{0} != '`' ) {
-                       if ( $this->mTablePrefix !== '' &&  strpos( '.', $name ) === false ) {
+                       if ( $this->mTablePrefix !== '' &&  strpos( $name, '.' ) === false ) {
                                $name = "{$this->mTablePrefix}$name";
                        }
                        if ( isset( $wgSharedDB ) && "{$this->mTablePrefix}user" == $name ) {
@@ -2278,6 +2310,13 @@ class Database {
                return $this->tableName( $matches[1] );
        }
 
+       /*
+        * Build a concatenation list to feed into a SQL query
+       */
+       function buildConcat( $stringList ) {
+               return 'CONCAT(' . implode( ',', $stringList ) . ')';
+       }
+
 }
 
 /**