Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312459

Change subject: Remove unused Database::isView()/clearViewsCache() methods
......................................................................

Remove unused Database::isView()/clearViewsCache() methods

Also make getLazyMasterHandle() protected.

Change-Id: Id6b48ff976a800052c22e90b572695ab3b8beb7e
---
M includes/libs/rdbms/database/Database.php
M includes/libs/rdbms/database/DatabaseMysqlBase.php
M tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
3 files changed, 10 insertions(+), 64 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/59/312459/1

diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index f56f380..e3afb0e 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -209,12 +209,6 @@
        /** @var IDatabase|null Lazy handle to the master DB this server 
replicates from */
        private $lazyMasterHandle;
 
-       /**
-        * @since 1.22
-        * @var string[] Process cache of VIEWs names in the database
-        */
-       protected $allViews = null;
-
        /** @var float UNIX timestamp */
        protected $lastPing = 0.0;
 
@@ -494,7 +488,7 @@
         * @see setLazyMasterHandle()
         * @since 1.27
         */
-       public function getLazyMasterHandle() {
+       protected function getLazyMasterHandle() {
                return $this->lazyMasterHandle;
        }
 
@@ -2934,18 +2928,7 @@
        }
 
        /**
-        * Reset the views process cache set by listViews()
-        * @since 1.22
-        */
-       final public function clearViewsCache() {
-               $this->allViews = null;
-       }
-
-       /**
         * Lists all the VIEWs in the database
-        *
-        * For caching purposes the list of all views should be stored in
-        * $this->allViews. The process cache can be cleared with 
clearViewsCache()
         *
         * @param string $prefix Only show VIEWs with this prefix, eg. 
unit_test_
         * @param string $fname Name of calling function
@@ -2954,18 +2937,6 @@
         * @since 1.22
         */
        public function listViews( $prefix = null, $fname = __METHOD__ ) {
-               throw new RuntimeException( __METHOD__ . ' is not implemented 
in descendant class' );
-       }
-
-       /**
-        * Differentiates between a TABLE and a VIEW
-        *
-        * @param string $name Name of the database-structure to test.
-        * @throws RuntimeException
-        * @return bool
-        * @since 1.22
-        */
-       public function isView( $name ) {
                throw new RuntimeException( __METHOD__ . ' is not implemented 
in descendant class' );
        }
 
diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php 
b/includes/libs/rdbms/database/DatabaseMysqlBase.php
index 675bc87..c6a00d4 100644
--- a/includes/libs/rdbms/database/DatabaseMysqlBase.php
+++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php
@@ -1296,26 +1296,22 @@
         * @since 1.22
         */
        public function listViews( $prefix = null, $fname = __METHOD__ ) {
+               // The name of the column containing the name of the VIEW
+               $propertyName = 'Tables_in_' . $this->mDBname;
 
-               if ( !isset( $this->allViews ) ) {
-
-                       // The name of the column containing the name of the 
VIEW
-                       $propertyName = 'Tables_in_' . $this->mDBname;
-
-                       // Query for the VIEWS
-                       $result = $this->query( 'SHOW FULL TABLES WHERE 
TABLE_TYPE = "VIEW"' );
-                       $this->allViews = [];
-                       while ( ( $row = $this->fetchRow( $result ) ) !== false 
) {
-                               array_push( $this->allViews, 
$row[$propertyName] );
-                       }
+               // Query for the VIEWS
+               $result = $this->query( 'SHOW FULL TABLES WHERE TABLE_TYPE = 
"VIEW"' );
+               $allViews = [];
+               while ( ( $row = $this->fetchRow( $result ) ) !== false ) {
+                       array_push( $allViews, $row[$propertyName] );
                }
 
                if ( is_null( $prefix ) || $prefix === '' ) {
-                       return $this->allViews;
+                       return $allViews;
                }
 
                $filteredViews = [];
-               foreach ( $this->allViews as $viewName ) {
+               foreach ( $allViews as $viewName ) {
                        // Does the name of this VIEW start with the 
table-prefix?
                        if ( strpos( $viewName, $prefix ) === 0 ) {
                                array_push( $filteredViews, $viewName );
diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php 
b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
index 9480c2d..63c1846 100644
--- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
+++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
@@ -213,27 +213,6 @@
                        $db->listViews( '' ) );
        }
 
-       /**
-        * @covers DatabaseMysqlBase::isView
-        * @dataProvider provideViewExistanceChecks
-        */
-       function testIsView( $isView, $viewName ) {
-               $db = $this->getMockForViews();
-
-               switch ( $isView ) {
-                       case true:
-                               $this->assertTrue( $db->isView( $viewName ),
-                                       "$viewName should be considered a view" 
);
-                       break;
-
-                       case false:
-                               $this->assertFalse( $db->isView( $viewName ),
-                                       "$viewName has not been defined as a 
view" );
-                       break;
-               }
-
-       }
-
        function provideViewExistanceChecks() {
                return [
                        // format: whether it is a view, view name

-- 
To view, visit https://gerrit.wikimedia.org/r/312459
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6b48ff976a800052c22e90b572695ab3b8beb7e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to