Commit 4964fd29 authored by catch's avatar catch

Issue #1635394 by djdevin, droplet, webflo, floretan: Fixed Fatal error when...

Issue #1635394 by djdevin, droplet, webflo, floretan: Fixed Fatal error when filtering the content admin page by language.
parent 6f38f533
......@@ -203,4 +203,35 @@ function testContentTypeDirLang() {
$this->drupalLogout();
}
/**
* Test filtering Node content by language.
*/
function testNodeAdminLanguageFilter() {
// User to add and remove language.
$admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'access content overview', 'administer nodes', 'bypass node access'));
// Log in as admin.
$this->drupalLogin($admin_user);
// Enable multiple languages.
$this->drupalPost('admin/config/regional/language/edit/en', array('locale_translate_english' => TRUE), t('Save language'));
$this->drupalPost('admin/config/regional/language/add', array('predefined_langcode' => 'zh-hant'), t('Add language'));
// Create two nodes: English and Chinese.
$node_en = $this->drupalCreateNode(array('langcode' => 'en'));
$node_zh_hant = $this->drupalCreateNode(array('langcode' => 'zh-hant'));
$this->drupalGet('admin/content');
// Verify filtering by language.
$edit = array(
'langcode' => 'zh-hant',
);
$this->drupalPost(NULL, $edit, t('Filter'));
$this->assertLinkByHref('node/' . $node_zh_hant->nid . '/edit');
$this->assertNoLinkByHref('node/' . $node_en->nid . '/edit');
}
}
......@@ -114,7 +114,7 @@ function node_filters() {
// Make locked languages appear special in the list.
$language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
}
$filters['language'] = array(
$filters['langcode'] = array(
'title' => t('language'),
'options' => array(
'[any]' => t('- Any -'),
......@@ -140,7 +140,7 @@ function node_build_filter_query(SelectInterface $query) {
// Note: no exploitable hole as $key/$value have already been checked when submitted
list($key, $value) = explode('-', $value, 2);
case 'type':
case 'language':
case 'langcode':
$query->condition('n.' . $key, $value);
break;
}
......@@ -176,7 +176,7 @@ function node_filter_form() {
$value = module_invoke('taxonomy', 'term_load', $value);
$value = $value->name;
}
elseif ($type == 'language') {
elseif ($type == 'langcode') {
$value = language_name($value);
}
else {
......@@ -189,7 +189,7 @@ function node_filter_form() {
else {
$form['filters']['current'][] = array('#markup' => t('where %property is %value', $t_args));
}
if (in_array($type, array('type', 'language'))) {
if (in_array($type, array('type', 'langcode'))) {
// Remove the option if it is already being filtered on.
unset($filters[$type]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment