r89005 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89004‎ | r89005 | r89006 >
Date:22:42, 27 May 2011
Author:catrope
Status:ok
Tags:
Comment:
Refactor MessageBlobStore::updateModule() to remove the multi-language update behavior. Instead of updating all language's blobs at once, it now only updates the requested language. This, in combination with the bug fixed in r89001, was what caused the UploadWizard timeouts on the cluster
Modified paths:
  • /trunk/phase3/includes/MessageBlobStore.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MessageBlobStore.php
@@ -117,49 +117,37 @@
118118 }
119119
120120 /**
121 - * Update all message blobs for a given module.
 121+ * Update the message blob for a given module in a given language
122122 *
123123 * @param $name String: module name
124124 * @param $module ResourceLoaderModule object
125 - * @param $lang String: language code (optional)
126 - * @return Mixed: if $lang is set, the new message blob for that language is
127 - * returned if present. Otherwise, null is returned.
 125+ * @param $lang String: language code
 126+ * @return String Regenerated message blob, or null if there was no blob for the given module/language pair
128127 */
129 - public static function updateModule( $name, ResourceLoaderModule $module, $lang = null ) {
130 - $retval = null;
131 -
132 - // Find all existing blobs for this module
 128+ public static function updateModule( $name, ResourceLoaderModule $module, $lang ) {
133129 $dbw = wfGetDB( DB_MASTER );
134 - $res = $dbw->select( 'msg_resource',
135 - array( 'mr_lang', 'mr_blob' ),
136 - array( 'mr_resource' => $name ),
 130+ $row = $dbw->selectRow( 'msg_resource', 'mr_blob',
 131+ array( 'mr_resource' => $name, 'mr_lang' => $lang ),
137132 __METHOD__
138133 );
139 -
140 - // Build the new msg_resource rows
141 - $newRows = array();
142 - $now = $dbw->timestamp();
143 - // Save the last-processed old and new blobs for later
144 - $oldBlob = $newBlob = null;
145 -
146 - foreach ( $res as $row ) {
147 - $oldBlob = $row->mr_blob;
148 - $newBlob = self::generateMessageBlob( $module, $row->mr_lang );
149 -
150 - if ( $row->mr_lang === $lang ) {
151 - $retval = $newBlob;
152 - }
153 - $newRows[] = array(
154 - 'mr_resource' => $name,
155 - 'mr_lang' => $row->mr_lang,
156 - 'mr_blob' => $newBlob,
157 - 'mr_timestamp' => $now
158 - );
 134+ if ( !$row ) {
 135+ return null;
159136 }
160137
 138+ // Save the old and new blobs for later
 139+ $oldBlob = $row->mr_blob;
 140+ $newBlob = self::generateMessageBlob( $module, $lang );
 141+
 142+ $newRow = array(
 143+ 'mr_resource' => $name,
 144+ 'mr_lang' => $lang,
 145+ 'mr_blob' => $newBlob,
 146+ 'mr_timestamp' => $dbw->timestamp()
 147+ );
 148+
161149 $dbw->replace( 'msg_resource',
162150 array( array( 'mr_resource', 'mr_lang' ) ),
163 - $newRows, __METHOD__
 151+ $newRow, __METHOD__
164152 );
165153
166154 // Figure out which messages were added and removed
@@ -192,7 +180,7 @@
193181 );
194182 }
195183
196 - return $retval;
 184+ return $newBlob;
197185 }
198186
199187 /**

Sign-offs

UserFlagDate
Nikerabbitinspected12:50, 14 June 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r922891.17wmf1: Redoing r92287, merging r89003, r89005 into 1.17wmf1reedy19:28, 15 July 2011
r92330REL1_18 MFT r88750, r88870, r88871, r89003, r89005, r89114, r89115, r89129, r...reedy22:56, 15 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89001Fix issue on the live site causing RL requests for ext.uploadWizard to consis...catrope22:09, 27 May 2011

Status & tagging log