diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-01-29 12:14:44 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-01-29 12:14:44 +0000 |
commit | 7b7bd71132f2d066265f7a9b7cc553818b86e5a9 (patch) | |
tree | ee1ce21939d2585095c2ca78c2ef2f42b4bc756e | |
parent | 68d000561db973c54f4289bce86c55de718543a9 (diff) | |
download | brdo-7b7bd71132f2d066265f7a9b7cc553818b86e5a9.tar.gz brdo-7b7bd71132f2d066265f7a9b7cc553818b86e5a9.tar.bz2 |
- Patch #693362 by catch, Dave Reid: taxonomy_form_all() is dangerous and ?q=admin/content can be a performance killer.
-rw-r--r-- | modules/node/node.admin.inc | 9 | ||||
-rw-r--r-- | modules/node/node.module | 13 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 18 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.test | 128 |
4 files changed, 0 insertions, 168 deletions
diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc index b2539b0ea..3db9033ec 100644 --- a/modules/node/node.admin.inc +++ b/modules/node/node.admin.inc @@ -97,15 +97,6 @@ function node_filters() { ) + node_type_get_names(), ); - // The taxonomy filter - if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) { - $filters['term'] = array( - 'title' => t('term'), - 'options' => array( - '[any]' => t('any'), - ) + $taxonomy, - ); - } // Language filter if there is a list of languages if ($languages = module_invoke('locale', 'language_list')) { $languages = array(LANGUAGE_NONE => t('Language neutral')) + $languages; diff --git a/modules/node/node.module b/modules/node/node.module index 971aeadf9..c454bd7fc 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2503,19 +2503,6 @@ function node_form_search_form_alter(&$form, $form_state) { '#maxlength' => 255, ); - // Taxonomy box: - if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) { - $form['advanced']['term'] = array( - '#type' => 'select', - '#title' => t('Only in the term(s)'), - '#prefix' => '<div class="criterion">', - '#size' => 10, - '#suffix' => '</div>', - '#options' => $taxonomy, - '#multiple' => TRUE, - ); - } - // Node types: $types = array_map('check_plain', node_type_get_names()); $form['advanced']['type'] = array( diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index cad3049f8..8e70c5a84 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -573,24 +573,6 @@ function taxonomy_terms_static_reset() { } /** - * Generate a set of options for selecting a term from all vocabularies. - */ -function taxonomy_form_all() { - $vocabularies = taxonomy_get_vocabularies(); - $options = array(); - foreach ($vocabularies as $vid => $vocabulary) { - $tree = taxonomy_get_tree($vid); - if ($tree && (count($tree) > 0)) { - $options[$vocabulary->name] = array(); - foreach ($tree as $term) { - $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name; - } - } - } - return $options; -} - -/** * Return an array of all vocabulary objects. * * @param $type diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 957e0ca02..d0db7b734 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -834,131 +834,3 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { $this->assertText($term->name, t('Term name is displayed')); } } - -/** - * Test taxonomy filters in node forms. - */ -class TaxonomyNodeFilterTestCase extends TaxonomyWebTestCase { - - public static function getInfo() { - return array( - 'name' => 'Taxonomy term filters in node forms', - 'description' => 'Test node form filtering by taxonomy terms.', - 'group' => 'Taxonomy', - ); - } - - function setUp() { - parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'bypass node access', 'search content', 'use advanced search')); - $this->drupalLogin($this->admin_user); - $this->vocabulary = $this->createVocabulary(); - - $this->langcode = LANGUAGE_NONE; - $this->instance = array( - 'field_name' => 'taxonomy_' . $this->vocabulary->machine_name, - 'bundle' => 'article', - 'object_type' => 'node', - 'widget' => array( - 'type' => 'options_select', - ), - 'display' => array( - 'full' => array( - 'type' => 'taxonomy_term_reference_link', - ), - ), - ); - field_create_instance($this->instance); - } - - /** - * Test node administration page filtering by taxonomy terms. - */ - function testContentAdminPage() { - // Create two taxonomy terms. - $term1 = $this->createTerm($this->vocabulary); - $term2 = $this->createTerm($this->vocabulary); - - // Create nodes with various terms. - $nodes['article1'] = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->instance['field_name'] . '[' . $this->langcode . '][]'] = $term1->tid; - $this->drupalPost('node/' . $nodes['article1']->nid . '/edit', $edit, t('Save')); - - $nodes['article2'] = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->instance['field_name'] . '[' . $this->langcode . '][]'] = $term2->tid; - $this->drupalPost('node/' . $nodes['article2']->nid . '/edit', $edit, t('Save')); - - $nodes['article1_2'] = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->instance['field_name'] . '[' . $this->langcode . '][]'] = array($term1->tid, $term2->tid); - $this->drupalPost('node/' . $nodes['article1_2']->nid . '/edit', $edit, t('Save')); - - // Verify that nodes appear on content admin page. - $this->drupalGet('admin/content'); - $this->assertResponse(200); - foreach ($nodes as $node) { - $this->assertLinkByHref('node/' . $node->nid); - } - - // Verify filtering by term 1. - $edit = array( - 'term' => $term1->tid, - ); - $this->drupalPost(NULL, $edit, t('Filter')); - $this->assertRaw(t('<strong>%type</strong> is <strong>%name</strong>', array('%type' => 'term', '%name' => $term1->name)), t('Content list is filtered by term 1.')); - $this->assertLinkByHref('node/' . $nodes['article1']->nid . '/edit'); - $this->assertLinkByHref('node/' . $nodes['article1_2']->nid . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['article2']->nid . '/edit'); - - // Verify filtering by term 1 and term 2. - $edit = array( - 'term' => $term2->tid, - ); - $this->drupalPost(NULL, $edit, t('Refine')); - $this->assertRaw(t('<strong>%type</strong> is <strong>%name</strong>', array('%type' => 'term', '%name' => $term1->name)), t('Content list is filtered by term 1.')); - $this->assertRaw(t('<strong>%type</strong> is <strong>%name</strong>', array('%type' => 'term', '%name' => $term2->name)), t('Content list is filtered by term 2.')); - $this->assertLinkByHref('node/' . $nodes['article1_2']->nid . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['article1']->nid . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['article2']->nid . '/edit'); - - // Verify filtering by term 2. - $this->drupalPost(NULL, $edit, t('Reset')); - $edit = array( - 'term' => $term2->tid, - ); - $this->drupalPost(NULL, $edit, t('Filter')); - $this->assertRaw(t('<strong>%type</strong> is <strong>%name</strong>', array('%type' => 'term', '%name' => $term2->name)), t('Content list is filtered by term 2.')); - $this->assertLinkByHref('node/' . $nodes['article2']->nid . '/edit'); - $this->assertLinkByHref('node/' . $nodes['article1_2']->nid . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['article1']->nid . '/edit'); - } - - /** - * Test advanced search filtering by taxonomy terms. - */ - function testAdvancedSearch() { - // Create two taxonomy terms. - $term1 = $this->createTerm($this->vocabulary); - $term2 = $this->createTerm($this->vocabulary); - - // Create a node with the term. - $node = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->instance['field_name'] . '[' . $this->langcode . '][]'] = $term1->tid; - $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); - - // Update the search index. - node_update_index(); - search_update_totals(); - - // Search for the node title. - $this->drupalGet('search/node/' . $node->title); - $this->assertText($node->title, t('Article node found with search.')); - - // Search for the node title, filtering by term 1. - $this->drupalGet('search/node/' . $node->title . ' term:' . $term1->tid); - $this->assertText($node->title, t('Article node found with search filtering by term 1.')); - - // Search for the node title, filtering by term 2. - $this->drupalGet('search/node/' . $node->title . ' term:' . $term2->tid); - $this->assertNoText($node->title, t('Article node not found with search filtering by term 2.')); - } -} |