Merge "deleteEqualMessages: Exclude messages that are empty by default"
[lhc/web/wiklou.git] / includes / db / DatabaseUtility.php
index c0bdba6..de58bab 100644 (file)
@@ -1,4 +1,26 @@
 <?php
+/**
+ * This file contains database-related utility classes.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Database
+ */
+
 /**
  * Utility class.
  * @ingroup Database
@@ -10,6 +32,9 @@ class DBObject {
                $this->mData = $data;
        }
 
+       /**
+        * @return bool
+        */
        function isLOB() {
                return false;
        }
@@ -113,7 +138,7 @@ class ResultWrapper implements Iterator {
 
        /**
         * Fetch the next row from the given result object, in associative array
-        * form.  Fields are retrieved with $row['fieldname'].
+        * form. Fields are retrieved with $row['fieldname'].
         *
         * @return Array
         * @throws DBUnexpectedError Thrown if the database returns an error
@@ -155,6 +180,9 @@ class ResultWrapper implements Iterator {
                $this->currentRow = null;
        }
 
+       /**
+        * @return int
+        */
        function current() {
                if ( is_null( $this->currentRow ) ) {
                        $this->next();
@@ -162,16 +190,25 @@ class ResultWrapper implements Iterator {
                return $this->currentRow;
        }
 
+       /**
+        * @return int
+        */
        function key() {
                return $this->pos;
        }
 
+       /**
+        * @return int
+        */
        function next() {
                $this->pos++;
                $this->currentRow = $this->fetchObject();
                return $this->currentRow;
        }
 
+       /**
+        * @return bool
+        */
        function valid() {
                return $this->current() !== false;
        }
@@ -182,15 +219,18 @@ class ResultWrapper implements Iterator {
  * doesn't go anywhere near an actual database.
  */
 class FakeResultWrapper extends ResultWrapper {
-       var $result     = array();
-       var $db         = null; // And it's going to stay that way :D
-       var $pos        = 0;
+       var $result = array();
+       var $db = null; // And it's going to stay that way :D
+       var $pos = 0;
        var $currentRow = null;
 
        function __construct( $array ) {
                $this->result = $array;
        }
 
+       /**
+        * @return int
+        */
        function numRows() {
                return count( $this->result );
        }
@@ -202,14 +242,19 @@ class FakeResultWrapper extends ResultWrapper {
                        $this->currentRow = false;
                }
                $this->pos++;
-               return $this->currentRow;
+               if ( is_object( $this->currentRow ) ) {
+                       return get_object_vars( $this->currentRow );
+               } else {
+                       return $this->currentRow;
+               }
        }
 
        function seek( $row ) {
                $this->pos = $row;
        }
 
-       function free() {}
+       function free() {
+       }
 
        // Callers want to be able to access fields with $this->fieldName
        function fetchObject() {
@@ -241,7 +286,7 @@ class LikeMatch {
        /**
         * Store a string into a LikeMatch marker object.
         *
-        * @param String $s
+        * @param string $s
         */
        public function __construct( $s ) {
                $this->str = $s;
@@ -256,3 +301,9 @@ class LikeMatch {
                return $this->str;
        }
 }
+
+/**
+ * An object representing a master or slave position in a replicated setup.
+ */
+interface DBMasterPos {
+}