r70203 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70202‎ | r70203 | r70204 >
Date:19:56, 30 July 2010
Author:skizzerz
Status:ok (Comments)
Tags:
Comment:
* (bug 24425) Use Database::replace instead of delete/insert in SqlBagOStuff::set to avoid query errors about duplicate keynames.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/BagOStuff.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/BagOStuff.php
@@ -307,8 +307,9 @@
308308 }
309309 try {
310310 $db->begin();
311 - $db->delete( 'objectcache', array( 'keyname' => $key ), __METHOD__ );
312 - $db->insert( 'objectcache',
 311+ // (bug 24425) use a replace if the db supports it instead of
 312+ // delete/insert to avoid clashes with conflicting keynames
 313+ $db->replace( 'objectcache', array( 'keyname' ),
313314 array(
314315 'keyname' => $key,
315316 'value' => $db->encodeBlob( $this->serialize( $value ) ),
Index: trunk/phase3/RELEASE-NOTES
@@ -258,6 +258,8 @@
259259 useful error message.
260260 * Uploading to a protected title will allow the user to choose a new name
261261 instead of showing an error page
 262+* (bug 24425) Use Database::replace instead of delete/insert in SqlBagOStuff::set
 263+ to avoid query errors about duplicate keynames.
262264
263265 === API changes in 1.17 ===
264266 * (bug 22738) Allow filtering by action type on query=logevent.

Comments

#Comment by Simetrical (talk | contribs)   19:08, 2 August 2010

Hurrah. I've seen this bug before, thanks for fixing.

#Comment by Nikerabbit (talk | contribs)   14:47, 3 August 2010

Thanks from me too. How come you didn't report this bug before?

And... I still think that those comments are more confusing than helpful for anyone reading the code. It's even wrong because it's about race condition rather than what the key name is.

Status & tagging log