r95929 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95928‎ | r95929 | r95930 >
Date:01:32, 1 September 2011
Author:kaldari
Status:ok
Tags:fundraising 
Comment:
fix for a concurrency issue when logging
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -850,7 +850,7 @@
851851 return;
852852 }
853853
854 - $initialBannerSettings = CentralNoticeDB::getBannerSettings( $name );
 854+ $initialBannerSettings = CentralNoticeDB::getBannerSettings( $name, true );
855855
856856 $dbr = wfGetDB( DB_SLAVE );
857857 $res = $dbr->select( 'cn_templates', 'tmp_name',
@@ -892,7 +892,7 @@
893893 }
894894
895895 $bannerId = SpecialNoticeTemplate::getTemplateId( $name );
896 - $finalBannerSettings = CentralNoticeDB::getBannerSettings( $name );
 896+ $finalBannerSettings = CentralNoticeDB::getBannerSettings( $name, true );
897897 $this->logBannerChange( 'modified', $bannerId, $initialBannerSettings, $finalBannerSettings, $contentChanged);
898898
899899 return;
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -243,14 +243,20 @@
244244 /**
245245 * Return settings for a banner
246246 * @param $bannerName string name of banner
 247+ * @param $logging boolean whether or not request is for logging (optional)
247248 * @return an array of banner settings
248249 */
249 - static function getBannerSettings( $bannerName ) {
 250+ static function getBannerSettings( $bannerName, $logging = false ) {
250251 global $wgCentralDBname;
251252
252253 $banner = array();
253254
254 - $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
 255+ // If logging, read from the master database to avoid concurrency problems
 256+ if ( $logging ) {
 257+ $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname );
 258+ } else {
 259+ $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
 260+ }
255261
256262 $row = $dbr->selectRow( 'cn_templates',
257263 array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r98908MFT r95686, r95929, r96496awjrichards20:46, 4 October 2011
r98910MFT r95929awjrichards20:50, 4 October 2011

Status & tagging log