Merge "Fix phan errors by improving documentation (#10)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 7 Apr 2019 09:13:15 +0000 (09:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 7 Apr 2019 09:13:15 +0000 (09:13 +0000)
1  2 
includes/libs/rdbms/database/Database.php

@@@ -104,7 -104,7 +104,7 @@@ abstract class Database implements IDat
        /** @var callable Deprecation logging callback */
        protected $deprecationLogger;
  
-       /** @var resource|null Database connection */
+       /** @var object|resource|null Database connection */
        protected $conn = null;
        /** @var bool */
        protected $opened = false;
         */
        protected function assertIsWritableMaster() {
                if ( $this->getLBInfo( 'replica' ) === true ) {
 -                      throw new DBUnexpectedError(
 +                      throw new DBReadOnlyRoleError(
                                $this,
                                'Write operations are not allowed on replica database connections.'
                        );
  
                $flags = (int)$flags; // b/c; this field used to be a bool
                $ignoreErrors = $this->hasFlags( $flags, self::QUERY_SILENCE_ERRORS );
 -              $pseudoPermanent = $this->hasFlags( $flags, self::QUERY_PSEUDO_PERMANENT );
  
                $priorTransaction = $this->trxLevel;
                $priorWritesPending = $this->writesOrCallbacksPending();
                        $this->assertIsWritableMaster();
                        # Do not treat temporary table writes as "meaningful writes" that need committing.
                        # Profile them as reads. Integration tests can override this behavior via $flags.
 +                      $pseudoPermanent = $this->hasFlags( $flags, self::QUERY_PSEUDO_PERMANENT );
                        $tableType = $this->registerTempTableWrite( $sql, $pseudoPermanent );
                        $isEffectiveWrite = ( $tableType !== self::TEMP_NORMAL );
 +                      # DBConnRef uses QUERY_REPLICA_ROLE to enforce the replica role for raw SQL queries
 +                      if ( $isEffectiveWrite && $this->hasFlags( $flags, self::QUERY_REPLICA_ROLE ) ) {
 +                              throw new DBReadOnlyRoleError( $this, "Cannot write; target role is DB_REPLICA" );
 +                      }
                } else {
                        $isEffectiveWrite = false;
                }