- $l1hit = true;
- }
-
- # Try memcached
- if ( $message === false ) {
- $titleObj = Title::newFromText( $key );
- $title = $titleObj->getDBkey();
- $mcKey = "$wgDBname:MediaWiki:title:$title";
- $message = $wgMemc->get( $mcKey );
+
+ # If there's nothing in memcached, load all the messages from the database
+ if ( !$messageCache ) {
+ # Other threads don't need to load the messages if another thread is doing it.
+ $wgMemc->set( $memcKey, "loading", time() + 60 );
+
+ $sql = "SELECT cur_title,cur_text FROM cur WHERE cur_namespace=" . NS_MEDIAWIKI;
+ $res = wfQuery( $sql, DB_READ, $fname );
+ for ( $row = wfFetchObject( $res ); $row; $row = wfFetchObject( $res ) ) {
+ $messageCache[$row->cur_title] = $row->cur_text;
+ }
+ # Save in memcached
+ $wgMemc->set( $memcKey, $messageCache, time() + 3600 );
+ }
+ if ( is_array( $messageCache ) && array_key_exists( $title, $messageCache ) ) {
+ $message = $messageCache[$title];
+ }