RSS

(root)/drupal/6 : 11 : modules/locale/locale.install

Ā« back to all changes in this revision

Viewing changes to modules/locale/locale.install

David Strauss
2010-03-04 01:32:05
Revision ID: david@fourkitchens.com-20100304013205-rzm7nzx405tybf1o
Tags: DRUPAL-6-16
DrupalĀ 6.16

Show diffs side-by-side

added added

removed removed

1
1
<?php
2
 
// $Id: locale.install,v 1.27.2.1 2009/01/06 15:46:37 goba Exp $
 
2
// $Id: locale.install,v 1.27.2.3 2010/03/04 00:15:28 goba Exp $
3
3
 
4
4
/**
5
5
 * Implementation of hook_install().
164
164
 
165
165
/**
166
166
 * Change language setting variable of content types.
167
 
 * 
 
167
 *
168
168
 * Use language_content_type_<content_type> instead of language_<content_type>
169
169
 * so content types such as 'default', 'count' or 'negotiation' will not
170
170
 * interfere with language variables.
202
202
}
203
203
 
204
204
/**
 
205
 * Neutralize unsafe language names in the database.
 
206
 */
 
207
function locale_update_6006() {
 
208
  $ret = array();
 
209
  $matches = db_result(db_query("SELECT 1 FROM {languages} WHERE native LIKE '%<%' OR native LIKE '%>%' OR name LIKE '%<%' OR name LIKE '%>%'"));
 
210
  if ($matches) {
 
211
    $ret[] = update_sql("UPDATE {languages} SET name = REPLACE(name, '<', ''), native = REPLACE(native, '<', '')");
 
212
    $ret[] = update_sql("UPDATE {languages} SET name = REPLACE(name, '>', ''), native = REPLACE(native, '>', '')");
 
213
    drupal_set_message('The language name in English and the native language name values of all the existing custom languages of your site have been sanitized for security purposes. Visit the <a href="'. url('admin/settings/language') .'">Languages</a> page to check these and fix them if necessary.', 'warning');
 
214
  }
 
215
  // Check if some langcode values contain potentially dangerous characters and
 
216
  // warn the user if so. These are not fixed since they are referenced in other
 
217
  // tables (e.g. {node}).
 
218
  if (db_result(db_query("SELECT 1 FROM {languages} WHERE language LIKE '%<%' OR language LIKE '%>%' OR language LIKE '%\"%' OR language LIKE '%\\\\\%'"))) {
 
219
    drupal_set_message('Some of your custom language code values contain invalid characters. You should examine the <a href="'. url('admin/settings/language') .'">Languages</a> page. These must be fixed manually.', 'error');
 
220
  }
 
221
  return $ret;
 
222
}
 
223
 
 
224
/**
205
225
 * @} End of "defgroup updates-5.x-to-6.x"
206
226
 */
207
227
 
217
237
    }
218
238
  }
219
239
 
 
240
  // Clear variables.
 
241
  variable_del('language_default');
 
242
  variable_del('language_count');
 
243
  variable_del('language_content_type_default');
 
244
  variable_del('language_content_type_negotiation');
 
245
  variable_del('locale_cache_strings');
 
246
  variable_del('locale_js_directory');
 
247
  variable_del('javascript_parsed');
 
248
  variable_del('language_negotiation');
 
249
 
 
250
  foreach (node_get_types() as $type => $content_type) {
 
251
    variable_del("language_content_type_$type");
 
252
  }
 
253
 
 
254
  // Switch back to English: with a $language->language value different from
 
255
  // 'en' successive calls of t() might result in calling locale(), which in
 
256
  // turn might try to query the unexisting {locales_source} and
 
257
  // {locales_target} tables.
 
258
  drupal_init_language();
 
259
 
220
260
  // Remove tables.
221
261
  drupal_uninstall_schema('locale');
222
262
}
395
435
 
396
436
  return $schema;
397
437
}
398
 
 

Loggerhead 1.17 is a web-based interface for Bazaar branches