Database.php:
authorYuri Astrakhan <yurik@users.mediawiki.org>
Sat, 22 Apr 2006 02:12:59 +0000 (02:12 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Sat, 22 Apr 2006 02:12:59 +0000 (02:12 +0000)
* Proper handling of LIST_OR in makeList()
LinkBatch.php:
* Added isEmpty() and getSize() functions.
Query.php:
* Implemented double-redirects query (disabled until caching is done)
* Implemented backlinks query.
* Rewrote page info generator to allow both titles and pageIds to be specified.
* Security check for read-access.
* Output filtering prevents exposure of the internal data.
* Added transactional consistency (not sure its needed here)

includes/Database.php
includes/LinkBatch.php

index 2c45046..55d5f96 100644 (file)
@@ -1078,8 +1078,10 @@ class Database {
 
        /**
         * Makes a wfStrencoded list from an array
-        * $mode: LIST_COMMA         - comma separated, no field names
+        * $mode:
+        *        LIST_COMMA         - comma separated, no field names
         *        LIST_AND           - ANDed WHERE clause (without the WHERE)
+        *        LIST_OR            - ORed WHERE clause (without the WHERE)
         *        LIST_SET           - comma separated with field names, like a SET clause
         *        LIST_NAMES         - comma separated field names
         */
@@ -1104,7 +1106,7 @@ class Database {
                        }
                        if ( ($mode == LIST_AND || $mode == LIST_OR) && is_numeric( $field ) ) {
                                $list .= "($value)";
-                       } elseif ( $mode == LIST_AND && is_array ($value) ) {
+                       } elseif ( ($mode == LIST_AND || $mode == LIST_OR) && is_array ($value) ) {
                                $list .= $field." IN (".$this->makeList($value).") ";
                        } else {
                                if ( $mode == LIST_AND || $mode == LIST_OR || $mode == LIST_SET ) {
index 8dfbc82..e0f0f6f 100644 (file)
@@ -46,6 +46,20 @@ class LinkBatch {
                $this->data = $array;
        }
 
+       /**
+        * Returns true if no pages have been added, false otherwise.
+        */
+       function isEmpty() {
+               return ($this->getSize() == 0);
+       }
+
+       /**
+        * Returns the size of the batch.
+        */
+       function getSize() {
+               return count( $this->data );
+       }
+
        /**
         * Do the query and add the results to the LinkCache object
         * Return an array mapping PDBK to ID
@@ -100,7 +114,7 @@ class LinkBatch {
                $fname = 'LinkBatch::doQuery';
                $namespaces = array();
 
-               if ( !count( $this->data ) ) {
+               if ( $this->isEmpty() ) {
                        return false;
                }
                wfProfileIn( $fname );