Skip to content

Commit 8884d40

Browse files
committed
7.52 release
2 parents 081b593 + cabbffd commit 8884d40

File tree

8 files changed

+166
-7
lines changed

8 files changed

+166
-7
lines changed

CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
Drupal 7.52, 2016-11-16
3+
-----------------------
4+
- Fixed security issues (multiple vulnerabilities). See SA-CORE-2016-005.
5+
26
Drupal 7.51, 2016-10-05
37
-----------------------
48
- The Update module now also checks for updates to a disabled theme that is

includes/bootstrap.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* The current system version.
1010
*/
11-
define('VERSION', '7.51');
11+
define('VERSION', '7.52');
1212

1313
/**
1414
* Core API compatibility.

includes/database/select.inc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,21 @@ class SelectQuery extends Query implements SelectQueryInterface {
12311231

12321232
// Modules may alter all queries or only those having a particular tag.
12331233
if (isset($this->alterTags)) {
1234+
// Many contrib modules assume that query tags used for access-checking
1235+
// purposes follow the pattern $entity_type . '_access'. But this is
1236+
// not the case for taxonomy terms, since core used to add term_access
1237+
// instead of taxonomy_term_access to its queries. Provide backwards
1238+
// compatibility by adding both tags here instead of attempting to fix
1239+
// all contrib modules in a coordinated effort.
1240+
// TODO:
1241+
// - Extract this mechanism into a hook as part of a public (non-security)
1242+
// issue.
1243+
// - Emit E_USER_DEPRECATED if term_access is used.
1244+
// https://www.drupal.org/node/2575081
1245+
$term_access_tags = array('term_access' => 1, 'taxonomy_term_access' => 1);
1246+
if (array_intersect_key($this->alterTags, $term_access_tags)) {
1247+
$this->alterTags += $term_access_tags;
1248+
}
12341249
$hooks = array('query');
12351250
foreach ($this->alterTags as $tag => $value) {
12361251
$hooks[] = 'query_' . $tag;

modules/simpletest/tests/taxonomy_test.module

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,33 @@ function taxonomy_test_get_antonym($tid) {
109109
->execute()
110110
->fetchField();
111111
}
112+
113+
/**
114+
* Implements hook_query_alter().
115+
*/
116+
function taxonomy_test_query_alter(QueryAlterableInterface $query) {
117+
$value = variable_get(__FUNCTION__);
118+
if (isset($value)) {
119+
variable_set(__FUNCTION__, ++$value);
120+
}
121+
}
122+
123+
/**
124+
* Implements hook_query_TAG_alter().
125+
*/
126+
function taxonomy_test_query_term_access_alter(QueryAlterableInterface $query) {
127+
$value = variable_get(__FUNCTION__);
128+
if (isset($value)) {
129+
variable_set(__FUNCTION__, ++$value);
130+
}
131+
}
132+
133+
/**
134+
* Implements hook_query_TAG_alter().
135+
*/
136+
function taxonomy_test_query_taxonomy_term_access_alter(QueryAlterableInterface $query) {
137+
$value = variable_get(__FUNCTION__);
138+
if (isset($value)) {
139+
variable_set(__FUNCTION__, ++$value);
140+
}
141+
}

modules/system/system.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2883,7 +2883,7 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL,
28832883

28842884
// Prepare cancel link.
28852885
if (isset($_GET['destination'])) {
2886-
$options = drupal_parse_url(urldecode($_GET['destination']));
2886+
$options = drupal_parse_url($_GET['destination']);
28872887
}
28882888
elseif (is_array($path)) {
28892889
$options = $path;

modules/taxonomy/taxonomy.module

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ function taxonomy_get_parents($tid) {
10231023
$query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
10241024
$query->addField('t', 'tid');
10251025
$query->condition('h.tid', $tid);
1026-
$query->addTag('term_access');
1026+
$query->addTag('taxonomy_term_access');
10271027
$query->orderBy('t.weight');
10281028
$query->orderBy('t.name');
10291029
$tids = $query->execute()->fetchCol();
@@ -1081,7 +1081,7 @@ function taxonomy_get_children($tid, $vid = 0) {
10811081
if ($vid) {
10821082
$query->condition('t.vid', $vid);
10831083
}
1084-
$query->addTag('term_access');
1084+
$query->addTag('taxonomy_term_access');
10851085
$query->orderBy('t.weight');
10861086
$query->orderBy('t.name');
10871087
$tids = $query->execute()->fetchCol();
@@ -1129,7 +1129,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities
11291129
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
11301130
$result = $query
11311131
->addTag('translatable')
1132-
->addTag('term_access')
1132+
->addTag('taxonomy_term_access')
11331133
->fields('t')
11341134
->fields('h', array('parent'))
11351135
->condition('t.vid', $vid)
@@ -1249,7 +1249,7 @@ class TaxonomyTermController extends DrupalDefaultEntityController {
12491249
protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
12501250
$query = parent::buildQuery($ids, $conditions, $revision_id);
12511251
$query->addTag('translatable');
1252-
$query->addTag('term_access');
1252+
$query->addTag('taxonomy_term_access');
12531253
// When name is passed as a condition use LIKE.
12541254
if (isset($conditions['name'])) {
12551255
$query_conditions = &$query->conditions();

modules/taxonomy/taxonomy.pages.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function taxonomy_autocomplete($field_name = '', $tags_typed = '') {
150150

151151
$query = db_select('taxonomy_term_data', 't');
152152
$query->addTag('translatable');
153-
$query->addTag('term_access');
153+
$query->addTag('taxonomy_term_access');
154154

155155
// Do not select already entered terms.
156156
if (!empty($tags_typed)) {

modules/taxonomy/taxonomy.test

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,3 +1983,113 @@ class TaxonomyEFQTestCase extends TaxonomyWebTestCase {
19831983
}
19841984

19851985
}
1986+
1987+
/**
1988+
* Tests that appropriate query tags are added.
1989+
*/
1990+
class TaxonomyQueryAlterTestCase extends TaxonomyWebTestCase {
1991+
public static function getInfo() {
1992+
return array(
1993+
'name' => 'Taxonomy query tags',
1994+
'description' => 'Verifies that taxonomy_term_access tags are added to queries.',
1995+
'group' => 'Taxonomy',
1996+
);
1997+
}
1998+
1999+
public function setUp() {
2000+
parent::setUp('taxonomy_test');
2001+
}
2002+
2003+
/**
2004+
* Tests that appropriate tags are added when querying the database.
2005+
*/
2006+
public function testTaxonomyQueryAlter() {
2007+
// Create a new vocabulary and add a few terms to it.
2008+
$vocabulary = $this->createVocabulary();
2009+
$terms = array();
2010+
for ($i = 0; $i < 5; $i++) {
2011+
$terms[$i] = $this->createTerm($vocabulary);
2012+
}
2013+
2014+
// Set up hierarchy. Term 2 is a child of 1.
2015+
$terms[2]->parent = array($terms[1]->tid);
2016+
taxonomy_term_save($terms[2]);
2017+
2018+
$this->setupQueryTagTestHooks();
2019+
$loaded_term = taxonomy_term_load($terms[0]->tid);
2020+
$this->assertEqual($loaded_term->tid, $terms[0]->tid, 'First term was loaded');
2021+
$this->assertQueryTagTestResult(1, 'taxonomy_term_load()');
2022+
2023+
$this->setupQueryTagTestHooks();
2024+
$loaded_terms = taxonomy_get_tree($vocabulary->vid);
2025+
$this->assertEqual(count($loaded_terms), count($terms), 'All terms were loaded');
2026+
$this->assertQueryTagTestResult(1, 'taxonomy_get_tree()');
2027+
2028+
$this->setupQueryTagTestHooks();
2029+
$loaded_terms = taxonomy_get_parents($terms[2]->tid);
2030+
$this->assertEqual(count($loaded_terms), 1, 'All parent terms were loaded');
2031+
$this->assertQueryTagTestResult(2, 'taxonomy_get_parents()');
2032+
2033+
$this->setupQueryTagTestHooks();
2034+
$loaded_terms = taxonomy_get_children($terms[1]->tid);
2035+
$this->assertEqual(count($loaded_terms), 1, 'All child terms were loaded');
2036+
$this->assertQueryTagTestResult(2, 'taxonomy_get_children()');
2037+
2038+
$this->setupQueryTagTestHooks();
2039+
$query = db_select('taxonomy_term_data', 't');
2040+
$query->addField('t', 'tid');
2041+
$query->addTag('taxonomy_term_access');
2042+
$tids = $query->execute()->fetchCol();
2043+
$this->assertEqual(count($tids), count($terms), 'All term IDs were retrieved');
2044+
$this->assertQueryTagTestResult(1, 'custom db_select() with taxonomy_term_access tag (preferred)');
2045+
2046+
$this->setupQueryTagTestHooks();
2047+
$query = db_select('taxonomy_term_data', 't');
2048+
$query->addField('t', 'tid');
2049+
$query->addTag('term_access');
2050+
$tids = $query->execute()->fetchCol();
2051+
$this->assertEqual(count($tids), count($terms), 'All term IDs were retrieved');
2052+
$this->assertQueryTagTestResult(1, 'custom db_select() with term_access tag (deprecated)');
2053+
2054+
$this->setupQueryTagTestHooks();
2055+
$query = new EntityFieldQuery();
2056+
$query->entityCondition('entity_type', 'taxonomy_term');
2057+
$query->addTag('taxonomy_term_access');
2058+
$result = $query->execute();
2059+
$this->assertEqual(count($result['taxonomy_term']), count($terms), 'All term IDs were retrieved');
2060+
$this->assertQueryTagTestResult(1, 'custom EntityFieldQuery with taxonomy_term_access tag (preferred)');
2061+
2062+
$this->setupQueryTagTestHooks();
2063+
$query = new EntityFieldQuery();
2064+
$query->entityCondition('entity_type', 'taxonomy_term');
2065+
$query->addTag('term_access');
2066+
$result = $query->execute();
2067+
$this->assertEqual(count($result['taxonomy_term']), count($terms), 'All term IDs were retrieved');
2068+
$this->assertQueryTagTestResult(1, 'custom EntityFieldQuery with term_access tag (deprecated)');
2069+
}
2070+
2071+
/**
2072+
* Sets up the hooks in the test module.
2073+
*/
2074+
protected function setupQueryTagTestHooks() {
2075+
taxonomy_terms_static_reset();
2076+
variable_set('taxonomy_test_query_alter', 0);
2077+
variable_set('taxonomy_test_query_term_access_alter', 0);
2078+
variable_set('taxonomy_test_query_taxonomy_term_access_alter', 0);
2079+
}
2080+
2081+
/**
2082+
* Verifies invocation of the hooks in the test module.
2083+
*
2084+
* @param int $expected_invocations
2085+
* The number of times the hooks are expected to have been invoked.
2086+
* @param string $method
2087+
* A string describing the invoked function which generated the query.
2088+
*/
2089+
protected function assertQueryTagTestResult($expected_invocations, $method) {
2090+
$this->assertIdentical($expected_invocations, variable_get('taxonomy_test_query_alter'), 'hook_query_alter() invoked when executing ' . $method);
2091+
$this->assertIdentical($expected_invocations, variable_get('taxonomy_test_query_term_access_alter'), 'Deprecated hook_query_term_access_alter() invoked when executing ' . $method);
2092+
$this->assertIdentical($expected_invocations, variable_get('taxonomy_test_query_taxonomy_term_access_alter'), 'Preferred hook_query_taxonomy_term_access_alter() invoked when executing ' . $method);
2093+
}
2094+
2095+
}

0 commit comments

Comments
 (0)