[MediaWiki-commits] [Gerrit] Fix DAO brokenness with respect to auto-increment fields - change (mediawiki...OAuth)

2015-11-25 Thread Anomie (Code Review)
Anomie has uploaded a new change for review.

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

Change subject: Fix DAO brokenness with respect to auto-increment fields
..

Fix DAO brokenness with respect to auto-increment fields

The auto-increment field's value needs to be updated on insert, not on
update.

Not touching the fact that correct operation really requires a call to
$dbw->nextSequenceValue(), since this extension currently only seems to
support MySQL and SQLite and neither of those care.

Change-Id: I26c18729297db4c70f0f4f8501a44fe0689913e9
---
M backend/MWOAuthDAO.php
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth 
refs/changes/87/255487/1

diff --git a/backend/MWOAuthDAO.php b/backend/MWOAuthDAO.php
index 2da10a2..70d2180 100644
--- a/backend/MWOAuthDAO.php
+++ b/backend/MWOAuthDAO.php
@@ -167,10 +167,6 @@
array( $idColumn => $uniqueId ),
__METHOD__
);
-   $afield = static::getAutoIncrField();
-   if ( $afield !== null ) { // update field for 
auto-increment field
-   $this->$afield = $dbw->insertId();
-   }
$this->daoPending = false;
return $dbw->affectedRows() > 0;
} else {
@@ -179,11 +175,16 @@
}
} else {
$this->logger->debug( get_class( $this ) . ': 
performing DB update; new object.' );
+   $afield = static::getAutoIncrField();
+   // TODO: $this->$afield = $dbw->nextSequenceValue( ??? )
$dbw->insert(
static::getTable(),
$this->getRowArray( $dbw ),
__METHOD__
);
+   if ( $afield !== null ) { // update field for 
auto-increment field
+   $this->$afield = $dbw->insertId();
+   }
$this->daoPending = false;
return true;
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26c18729297db4c70f0f4f8501a44fe0689913e9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Anomie 

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


[MediaWiki-commits] [Gerrit] Fix DAO brokenness with respect to auto-increment fields - change (mediawiki...OAuth)

2015-11-25 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Fix DAO brokenness with respect to auto-increment fields
..


Fix DAO brokenness with respect to auto-increment fields

The auto-increment field's value needs to be updated on insert, not on
update.

Not touching the fact that correct operation really requires a call to
$dbw->nextSequenceValue(), since this extension currently only seems to
support MySQL and SQLite and neither of those care.

Change-Id: I26c18729297db4c70f0f4f8501a44fe0689913e9
---
M backend/MWOAuthDAO.php
1 file changed, 5 insertions(+), 4 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  Gergő Tisza: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/backend/MWOAuthDAO.php b/backend/MWOAuthDAO.php
index 2da10a2..70d2180 100644
--- a/backend/MWOAuthDAO.php
+++ b/backend/MWOAuthDAO.php
@@ -167,10 +167,6 @@
array( $idColumn => $uniqueId ),
__METHOD__
);
-   $afield = static::getAutoIncrField();
-   if ( $afield !== null ) { // update field for 
auto-increment field
-   $this->$afield = $dbw->insertId();
-   }
$this->daoPending = false;
return $dbw->affectedRows() > 0;
} else {
@@ -179,11 +175,16 @@
}
} else {
$this->logger->debug( get_class( $this ) . ': 
performing DB update; new object.' );
+   $afield = static::getAutoIncrField();
+   // TODO: $this->$afield = $dbw->nextSequenceValue( ??? )
$dbw->insert(
static::getTable(),
$this->getRowArray( $dbw ),
__METHOD__
);
+   if ( $afield !== null ) { // update field for 
auto-increment field
+   $this->$afield = $dbw->insertId();
+   }
$this->daoPending = false;
return true;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I26c18729297db4c70f0f4f8501a44fe0689913e9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Anomie 
Gerrit-Reviewer: Aaron Schulz 
Gerrit-Reviewer: CSteipp 
Gerrit-Reviewer: Gergő Tisza 
Gerrit-Reviewer: jenkins-bot <>

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