[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Remove wfSetBit()/wfSetVar() calls in DatabaseBase

2016-09-15 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Remove wfSetBit()/wfSetVar() calls in DatabaseBase
..


Remove wfSetBit()/wfSetVar() calls in DatabaseBase

Change-Id: I4f1269d3a4e26c766f181208942042fdf768e0af
---
M includes/db/Database.php
M includes/db/DatabaseMssql.php
2 files changed, 28 insertions(+), 10 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/Database.php b/includes/db/Database.php
index 917bc91..3597b7c 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -412,18 +412,25 @@
 *   - false to disable debugging
 *   - omitted or null to do nothing
 *
-* @return bool|null Previous value of the flag
+* @return bool Previous value of the flag
+* @deprecated since 1.28; use setFlag()
 */
public function debug( $debug = null ) {
-   return wfSetBit( $this->mFlags, DBO_DEBUG, $debug );
+   $res = $this->getFlag( DBO_DEBUG );
+   if ( $debug !== null ) {
+   $debug ? $this->setFlag( DBO_DEBUG ) : 
$this->clearFlag( DBO_DEBUG );
+   }
+
+   return $res;
}
 
public function bufferResults( $buffer = null ) {
-   if ( is_null( $buffer ) ) {
-   return !(bool)( $this->mFlags & DBO_NOBUFFER );
-   } else {
-   return !wfSetBit( $this->mFlags, DBO_NOBUFFER, !$buffer 
);
+   $res = !$this->getFlag( DBO_NOBUFFER );
+   if ( $buffer !== null ) {
+   $buffer ? $this->clearFlag( DBO_NOBUFFER ) : 
$this->setFlag( DBO_NOBUFFER );
}
+
+   return $res;
}
 
/**
@@ -439,7 +446,12 @@
 * @return bool The previous value of the flag.
 */
protected function ignoreErrors( $ignoreErrors = null ) {
-   return wfSetBit( $this->mFlags, DBO_IGNORE, $ignoreErrors );
+   $res = $this->getFlag( DBO_IGNORE );
+   if ( $ignoreErrors !== null ) {
+   $ignoreErrors ? $this->setFlag( DBO_IGNORE ) : 
$this->clearFlag( DBO_IGNORE );
+   }
+
+   return $res;
}
 
public function trxLevel() {
@@ -451,11 +463,17 @@
}
 
public function tablePrefix( $prefix = null ) {
-   return wfSetVar( $this->mTablePrefix, $prefix );
+   $old = $this->mTablePrefix;
+   $this->mTablePrefix = $prefix;
+
+   return $old;
}
 
public function dbSchema( $schema = null ) {
-   return wfSetVar( $this->mSchema, $schema );
+   $old = $this->mSchema;
+   $this->mSchema = $schema;
+
+   return $old;
}
 
/**
diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php
index 59c8952..4ffafde 100644
--- a/includes/db/DatabaseMssql.php
+++ b/includes/db/DatabaseMssql.php
@@ -165,7 +165,7 @@
 * @throws DBUnexpectedError
 */
protected function doQuery( $sql ) {
-   if ( $this->debug() ) {
+   if ( $this->getFlag( DBO_DEBUG ) ) {
wfDebug( "SQL: [$sql]\n" );
}
$this->offset = 0;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4f1269d3a4e26c766f181208942042fdf768e0af
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 
Gerrit-Reviewer: Aaron Schulz 
Gerrit-Reviewer: Krinkle 
Gerrit-Reviewer: Parent5446 
Gerrit-Reviewer: Skizzerz 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Remove wfSetBit()/wfSetVar() calls in DatabaseBase

2016-09-15 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

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

Change subject: Remove wfSetBit()/wfSetVar() calls in DatabaseBase
..

Remove wfSetBit()/wfSetVar() calls in DatabaseBase

Change-Id: I4f1269d3a4e26c766f181208942042fdf768e0af
---
M includes/db/Database.php
M includes/db/DatabaseMssql.php
2 files changed, 29 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/93/310893/1

diff --git a/includes/db/Database.php b/includes/db/Database.php
index 917bc91..615b1ec 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -412,18 +412,25 @@
 *   - false to disable debugging
 *   - omitted or null to do nothing
 *
-* @return bool|null Previous value of the flag
+* @return bool Previous value of the flag
+* @deprecated since 1.28; use setFlag()
 */
public function debug( $debug = null ) {
-   return wfSetBit( $this->mFlags, DBO_DEBUG, $debug );
+   $res = $this->getFlag( DBO_DEBUG );
+   $this->mFlags = $debug
+   ? ( $this->mFlags | DBO_DEBUG )
+   : ( $this->mFlags ^ DBO_DEBUG );
+
+   return $res;
}
 
public function bufferResults( $buffer = null ) {
-   if ( is_null( $buffer ) ) {
-   return !(bool)( $this->mFlags & DBO_NOBUFFER );
-   } else {
-   return !wfSetBit( $this->mFlags, DBO_NOBUFFER, !$buffer 
);
-   }
+   $res = !$this->getFlag( DBO_NOBUFFER );
+   $this->mFlags = $buffer
+   ? ( $this->mFlags ^ DBO_NOBUFFER )
+   : ( $this->mFlags | DBO_NOBUFFER );
+
+   return $res;
}
 
/**
@@ -439,7 +446,12 @@
 * @return bool The previous value of the flag.
 */
protected function ignoreErrors( $ignoreErrors = null ) {
-   return wfSetBit( $this->mFlags, DBO_IGNORE, $ignoreErrors );
+   $res = $this->getFlag( DBO_IGNORE );
+   $this->mFlags = $ignoreErrors
+   ? ( $this->mFlags | DBO_IGNORE )
+   : ( $this->mFlags ^ DBO_IGNORE );
+
+   return $res;
}
 
public function trxLevel() {
@@ -451,11 +463,17 @@
}
 
public function tablePrefix( $prefix = null ) {
-   return wfSetVar( $this->mTablePrefix, $prefix );
+   $old = $this->mTablePrefix;
+   $this->mTablePrefix = $prefix;
+
+   return $old;
}
 
public function dbSchema( $schema = null ) {
-   return wfSetVar( $this->mSchema, $schema );
+   $old = $this->mSchema;
+   $this->mSchema = $schema;
+
+   return $old;
}
 
/**
diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php
index 59c8952..4ffafde 100644
--- a/includes/db/DatabaseMssql.php
+++ b/includes/db/DatabaseMssql.php
@@ -165,7 +165,7 @@
 * @throws DBUnexpectedError
 */
protected function doQuery( $sql ) {
-   if ( $this->debug() ) {
+   if ( $this->getFlag( DBO_DEBUG ) ) {
wfDebug( "SQL: [$sql]\n" );
}
$this->offset = 0;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f1269d3a4e26c766f181208942042fdf768e0af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 

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