Made DB ignoreErrors() method protected
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 8 Mar 2015 15:06:29 +0000 (08:06 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 21 Jul 2015 21:18:04 +0000 (14:18 -0700)
* This should *only* ever be used internal for error suppression,
  such as in the exception reporting methods. Having it public
  means callers have to worry (in theory) about whether the
  DB handles errors one way or a totally different way even
  though there is really only meant to be one.

Change-Id: I5916830d1bd53ee948308f394e55c17dd515ad33

RELEASE-NOTES-1.26
includes/db/Database.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/db/ORMTableTest.php

index 46ffe36..ec6bca5 100644 (file)
@@ -128,6 +128,7 @@ changes to languages because of Phabricator reports.
 * $wgSpecialPageGroups was removed (deprecated in 1.21).
 * SpecialPageFactory::setGroup was removed (deprecated in 1.21).
 * SpecialPageFactory::getGroup was removed (deprecated in 1.21).
+* DatabaseBase::ignoreErrors() is now protected.
 
 == Compatibility ==
 
index d7acb42..2ee4545 100644 (file)
@@ -230,7 +230,7 @@ abstract class DatabaseBase implements IDatabase {
         * @param null|bool $ignoreErrors
         * @return bool The previous value of the flag.
         */
-       public function ignoreErrors( $ignoreErrors = null ) {
+       protected function ignoreErrors( $ignoreErrors = null ) {
                return wfSetBit( $this->mFlags, DBO_IGNORE, $ignoreErrors );
        }
 
index 0ce056f..43d8ce8 100644 (file)
@@ -204,9 +204,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        while ( $this->db->trxLevel() > 0 ) {
                                $this->db->rollback();
                        }
-
-                       // don't ignore DB errors
-                       $this->db->ignoreErrors( false );
                }
 
                DeferredUpdates::clearPendingUpdates();
@@ -233,9 +230,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        while ( $this->db->trxLevel() > 0 ) {
                                $this->db->rollback();
                        }
-
-                       // don't ignore DB errors
-                       $this->db->ignoreErrors( false );
                }
 
                // Restore mw globals
index 338d931..764560d 100644 (file)
@@ -68,25 +68,6 @@ class ORMTableTest extends MediaWikiTestCase {
                $this->assertInstanceOf( $class, $class::singleton() );
                $this->assertTrue( $class::singleton() === $class::singleton() );
        }
-
-       /**
-        * @since 1.21
-        */
-       public function testIgnoreErrorsOverride() {
-               $table = $this->getTable();
-
-               $db = $table->getReadDbConnection();
-               $db->ignoreErrors( true );
-
-               try {
-                       $table->rawSelect( "this is invalid" );
-                       $this->fail( "An invalid query should trigger a DBQueryError even if ignoreErrors is enabled." );
-               } catch ( DBQueryError $ex ) {
-                       $this->assertTrue( true, "just making phpunit happy" );
-               }
-
-               $db->ignoreErrors( false );
-       }
 }
 
 /**