r93401 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93400‎ | r93401 | r93402 >
Date:17:36, 28 July 2011
Author:kipcool
Status:deferred
Tags:
Comment:
simpler queries
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/languages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/languages.php
@@ -90,37 +90,19 @@
9191 /* Use a simpler query if the user's language is English. */
9292 /* getLanguageIdForCode( 'en' ) = 85 */
9393
94 -// alternative query, slower?
95 -// if ( $lang_code == 'en' || !( $lang_id = getLanguageIdForCode( $lang_code ) ) )
96 -// return 'SELECT language.language_id AS row_id,language_names.language_name' .
97 -// ' FROM language' .
98 -// ' JOIN language_names ON language.language_id = language_names.language_id' .
99 -// ' WHERE language_names.name_language_id = 85' ;
100 -// /* Fall back on English in cases where a language name is not present in the
101 -// user's preferred language. */
102 -// else
103 -// return 'SELECT language.language_id AS row_id,COALESCE(ln1.language_name,ln2.language_name) AS language_name' .
104 -// ' FROM language' .
105 -// ' LEFT JOIN language_names AS ln1 ON language.language_id = ln1.language_id AND ln1.name_language_id = ' . $lang_id .
106 -// ' JOIN language_names AS ln2 ON language.language_id = ln2.language_id AND ln2.name_language_id = 85' ;
107 -
10894 if ( $lang_code == 'en' || !( $lang_id = getLanguageIdForCode( $lang_code ) ) )
109 - return 'SELECT language.language_id AS row_id,language_names.language_name' .
110 - ' FROM language' .
111 - ' JOIN language_names ON language.language_id = language_names.language_id' .
112 - ' WHERE language_names.name_language_id = 85' ;
 95+ return 'SELECT language_id AS row_id, language_name' .
 96+ ' FROM language_names' .
 97+ ' WHERE name_language_id = 85' ;
11398 /* Fall back on English in cases where a language name is not present in the
11499 user's preferred language. */
115100 else
116 - return 'SELECT language.language_id AS row_id, language_names.language_name AS language_name' .
117 - ' FROM language' .
118 - ' JOIN language_names ON language.language_id = language_names.language_id' .
119 - ' WHERE language_names.name_language_id = ' . $lang_id .
120 - ' OR ( language_names.name_language_id = 85 ' .
121 - ' AND language.language_id NOT IN ( SELECT language_id FROM language_names WHERE language_names.name_language_id = ' . $lang_id .
 101+ return 'SELECT language_id AS row_id, language_name' .
 102+ ' FROM language_names' .
 103+ ' WHERE name_language_id = ' . $lang_id .
 104+ ' OR ( name_language_id = 85 ' .
 105+ ' AND language_id NOT IN ( SELECT language_id FROM language_names WHERE name_language_id = ' . $lang_id .
122106 ' ) ) ' ;
123 -
124 -
125107 }
126108
127109 function getLanguageIdForName( $name ) {

Status & tagging log