Adding a getDB function to ApiBase...
authorSam Reed <reedy@users.mediawiki.org>
Sun, 11 Dec 2011 20:32:37 +0000 (20:32 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 11 Dec 2011 20:32:37 +0000 (20:32 +0000)
Not all subclasses will need/want it. It does however make it easier to pretend non ApiQuery derivatives actually are...

includes/api/ApiBase.php

index c2cd22b..2129052 100644 (file)
@@ -1498,6 +1498,13 @@ abstract class ApiBase extends ContextSource {
                return $this->mDBTime;
        }
 
+       /**
+        * @return DatabaseBase
+        */
+       public function getDB() {
+               return wfGetDB( DB_SLAVE, 'api' );
+       }
+
        /**
         * Debugging function that prints a value and an optional backtrace
         * @param $value mixed Value to print