rdbms: restrict more unsafe IDatabase methods in DBConnRef
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 21 Mar 2019 23:17:25 +0000 (16:17 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 21 Mar 2019 23:17:25 +0000 (16:17 -0700)
Change-Id: I1933da825e6b20b4ec742e0aa39d63e9a75f9a1c

includes/libs/rdbms/database/DBConnRef.php

index 4fdac81..5d80f83 100644 (file)
@@ -74,11 +74,13 @@ class DBConnRef implements IDatabase {
        }
 
        public function tablePrefix( $prefix = null ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
+               // Disallow things that might confuse the LoadBalancer tracking
+               throw new DBUnexpectedError( $this, "Database selection is disallowed to enable reuse." );
        }
 
        public function dbSchema( $schema = null ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
+               // Disallow things that might confuse the LoadBalancer tracking
+               throw new DBUnexpectedError( $this, "Database selection is disallowed to enable reuse." );
        }
 
        public function getLBInfo( $name = null ) {
@@ -86,11 +88,13 @@ class DBConnRef implements IDatabase {
        }
 
        public function setLBInfo( $name, $value = null ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
+               // Disallow things that might confuse the LoadBalancer tracking
+               throw new DBUnexpectedError( $this, "Changing LB info is disallowed to enable reuse." );
        }
 
        public function setLazyMasterHandle( IDatabase $conn ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
+               // Disallow things that might confuse the LoadBalancer tracking
+               throw new DBUnexpectedError( $this, "Database injection is disallowed to enable reuse." );
        }
 
        public function implicitGroupby() {