r102328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102327‎ | r102328 | r102329 >
Date:21:19, 7 November 2011
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Added deletion of previous cached value, when using caching for #get_web_data - patch from Angelf
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -506,7 +506,9 @@
507507 }
508508 if ( $page != '' ) {
509509 $dbw = wfGetDB( DB_MASTER );
510 - // insert contents into the cache table
 510+ // Delete the old entry, if one exists.
 511+ $dbw->delete( $edgCacheTable, array( 'url' => substr( $url, 0, 254 )));
 512+ // Insert contents into the cache table.
511513 $dbw->insert( $edgCacheTable, array( 'url' => substr( $url, 0, 254 ), 'result' => $page, 'req_time' => time() ) );
512514 return $page;
513515 }

Comments

#Comment by Nikerabbit (talk | contribs)   09:41, 8 November 2011

Or you could just use replace().

#Comment by Yaron Koren (talk | contribs)   15:43, 8 November 2011

Thanks for the suggestion - although I just looked up replace(), and it doesn't look like it would make things any simpler... it looks like you need to call select() before replace(), so it would still be two DB calls.

#Comment by Nikerabbit (talk | contribs)   15:57, 8 November 2011

Only on systems which do not have native replace, like mysql has.

#Comment by Yaron Koren (talk | contribs)   16:38, 8 November 2011

Hi - maybe I'm missing something. The replace() function takes in a parameter called $rows, which I assume has to be result of a select() call, no?

#Comment by Nikerabbit (talk | contribs)   19:32, 8 November 2011

It's the data you want to insert, like in insert, but you have to also provide the unique index for non-mysql databases to know what to delete.

#Comment by Yaron Koren (talk | contribs)   20:02, 8 November 2011

I don't know - doing a delete, then an insert, still seems to me conceptually simpler. But definitely feel free to change it.

Status & tagging log