Permalink
Browse files

Merge remote-tracking branch 'upstream/7.x' into wayfair

  • Loading branch information...
2 parents bd5afd8 + 1aad594 commit e1bb611db27bbb8c83b11aec3a8cd32ce26ee140 @lattera lattera committed Jan 12, 2012
View
@@ -257,6 +257,7 @@ System module
- ?
Taxonomy module
+- Jess Myrbo 'xjm' <http://drupal.org/user/65776>
- Nathaniel Catchpole 'catch' <http://drupal.org/user/35733>
- Benjamin Doherty 'bangpound' <http://drupal.org/user/100456>
@@ -630,7 +630,14 @@ function locale_modules_disabled($modules) {
*/
function locale($string = NULL, $context = NULL, $langcode = NULL) {
global $language;
- $locale_t = &drupal_static(__FUNCTION__);
+
+ // Use the advanced drupal_static() pattern, since this is called very often.
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['locale'] = &drupal_static(__FUNCTION__);
+ }
+ $locale_t = &$drupal_static_fast['locale'];
+
if (!isset($string)) {
// Return all cached strings if no string was specified
@@ -570,6 +570,10 @@ function hook_node_load($nodes, $types) {
* block access, return NODE_ACCESS_IGNORE or simply return nothing.
* Blindly returning FALSE will break other node access modules.
*
+ * Also note that this function isn't called for node listings (e.g., RSS feeds,
+ * the default home page at path 'node', a recent content block, etc.) See
+ * @link node_access Node access rights @endlink for a full explanation.
+ *
* @param $node
* Either a node object or the machine name of the content type on which to
* perform the access check.
View
@@ -2790,13 +2790,14 @@ function node_search_validate($form, &$form_state) {
* that this table is a list of grants; any matching row is sufficient to
* grant access to the node.
*
- * In node listings, the process above is followed except that
- * hook_node_access() is not called on each node for performance reasons and for
- * proper functioning of the pager system. When adding a node listing to your
- * module, be sure to use a dynamic query created by db_select() and add a tag
- * of "node_access". This will allow modules dealing with node access to ensure
- * only nodes to which the user has access are retrieved, through the use of
- * hook_query_TAG_alter().
+ * In node listings (lists of nodes generated from a select query, such as the
+ * default home page at path 'node', an RSS feed, a recent content block, etc.),
+ * the process above is followed except that hook_node_access() is not called on
+ * each node for performance reasons and for proper functioning of the pager
+ * system. When adding a node listing to your module, be sure to use a dynamic
+ * query created by db_select() and add a tag of "node_access". This will allow
+ * modules dealing with node access to ensure only nodes to which the user has
+ * access are retrieved, through the use of hook_query_TAG_alter().
*
* Note: Even a single module returning NODE_ACCESS_DENY from hook_node_access()
* will block access to the node. Therefore, implementers should take care to
View
@@ -288,9 +288,10 @@ function poll_form($node, &$form_state) {
// Add initial or additional choices.
$existing_delta = $delta;
- $weight++;
for ($delta; $delta < $choice_count; $delta++) {
$key = 'new:' . ($delta - $existing_delta);
+ // Increase the weight of each new choice.
+ $weight++;
$form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, NULL, '', 0, $weight, $choice_count);
}
@@ -408,6 +409,7 @@ function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight
'#maxlength' => 7,
'#parents' => array('choice', $key, 'chvotes'),
'#access' => user_access('administer nodes'),
+ '#element_validate' => array('element_validate_integer'),
);
$form['weight'] = array(
@@ -451,10 +453,8 @@ function poll_node_form_submit(&$form, &$form_state) {
*/
function poll_validate($node, $form) {
if (isset($node->title)) {
- // Check for at least two options and validate amount of votes:
+ // Check for at least two options and validate amount of votes.
$realchoices = 0;
- // Renumber fields
- $node->choice = array_values($node->choice);
foreach ($node->choice as $i => $choice) {
if ($choice['chtext'] != '') {
$realchoices++;
@@ -586,8 +586,10 @@ function poll_update($node) {
'weight' => $choice['weight'],
))
->insertFields(array(
- 'nid' => $node->nid,
- 'chtext' => $choice['chtext'],
+ 'nid' => $node->nid,
+ 'chtext' => $choice['chtext'],
+ 'chvotes' => (int) $choice['chvotes'],
+ 'weight' => $choice['weight'],
))
->execute();
}
View
@@ -24,15 +24,28 @@ class PollTestCase extends DrupalWebTestCase {
function pollCreate($title, $choices, $preview = TRUE) {
$this->assertTrue(TRUE, 'Create a poll');
+ $admin_user = $this->drupalCreateUser(array('create poll content', 'administer nodes'));
$web_user = $this->drupalCreateUser(array('create poll content', 'access content', 'edit own poll content'));
- $this->drupalLogin($web_user);
+ $this->drupalLogin($admin_user);
// Get the form first to initialize the state of the internal browser.
$this->drupalGet('node/add/poll');
// Prepare a form with two choices.
list($edit, $index) = $this->_pollGenerateEdit($title, $choices);
+ // Verify that the vote count element only allows non-negative integers.
+ $edit['choice[new:1][chvotes]'] = -1;
+ $edit['choice[new:0][chvotes]'] = $this->randomString(7);
+ $this->drupalPost(NULL, $edit, t('Save'));
+ $this->assertText(t('Negative values are not allowed.'));
+ $this->assertText(t('Vote count for new choice must be an integer.'));
+
+ // Repeat steps for initializing the state of the internal browser.
+ $this->drupalLogin($web_user);
+ $this->drupalGet('node/add/poll');
+ list($edit, $index) = $this->_pollGenerateEdit($title, $choices);
+
// Re-submit the form until all choices are filled in.
if (count($choices) > 2) {
while ($index < count($choices)) {
@@ -88,10 +101,6 @@ class PollTestCase extends DrupalWebTestCase {
}
foreach ($new_choices as $k => $text) {
$edit['choice[new:' . $k . '][chtext]'] = $text;
- // To test poll choice weights, every new choice is sorted in front of
- // existing choices. Existing/already submitted choices should keep their
- // weight.
- $edit['choice[new:' . $k . '][weight]'] = (- $index - $k);
}
return array($edit, count($already_submitted_choices) + count($new_choices));
}
@@ -122,11 +131,11 @@ class PollTestCase extends DrupalWebTestCase {
*/
function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) {
$expected = array();
+ $weight = 0;
foreach ($choices as $id => $label) {
if ($id < $index) {
- // The expected weight of each choice is exactly the negated id.
- // @see PollTestCase::_pollGenerateEdit()
- $weight = -$id;
+ // The expected weight of each choice is higher than the previous one.
+ $weight++;
// Directly assert the weight form element value for this choice.
$this->assertFieldByName('choice[chid:' . $id . '][weight]', $weight, t('Found choice @id with weight @weight.', array(
'@id' => $id,
@@ -205,18 +214,25 @@ class PollCreateTestCase extends PollTestCase {
$new_option = $this->randomName();
+ $vote_count = '2000';
$node->choice[] = array(
'chid' => '',
'chtext' => $new_option,
- 'chvotes' => 0,
- 'weight' => 0,
+ 'chvotes' => (int) $vote_count,
+ 'weight' => 1000,
);
node_save($node);
$this->drupalGet('poll');
$this->clickLink($title);
$this->assertText($new_option, 'New option found.');
+
+ $option = $this->xpath('//div[@id="node-1"]//div[@class="poll"]//div[@class="text"]');
+ $this->assertEqual(end($option), $new_option, 'Last item is equal to new option.');
+
+ $votes = $this->xpath('//div[@id="node-1"]//div[@class="poll"]//div[@class="percent"]');
+ $this->assertTrue(strpos(end($votes), $vote_count) > 0, t("Votes saved."));
}
function testPollClose() {
@@ -1188,7 +1188,7 @@ function search_excerpt($keys, $text) {
if (($s = strrpos($end, ' ')) !== FALSE) {
// Account for the added spaces.
$q = max($q - 1, 0);
- $s = min($s, drupal_strlen($end) - 1);
+ $s = min($s, strlen($end) - 1);
$ranges[$q] = $p + $s;
$length += $p + $s - $q;
$included[$key] = $p + 1;
@@ -1599,6 +1599,12 @@ class SearchExcerptTestCase extends DrupalUnitTestCase {
$result = preg_replace('| +|', ' ', search_excerpt('nothing', $entities));
$this->assertFalse(strpos($result, '&'), 'Entities are not present in excerpt');
$this->assertTrue(strpos($result, 'í') > 0, 'Entities are converted in excerpt');
+
+ // The node body that will produce this rendered $text is:
+ // 123456789 HTMLTest +123456789+&lsquo; +&lsquo; +&lsquo; +&lsquo; +12345678 &nbsp;&nbsp; +&lsquo; +&lsquo; +&lsquo; &lsquo;
+ $text = "<div class=\"field field-name-body field-type-text-with-summary field-label-hidden\"><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ‘</p>\n</div></div></div> ";
+ $result = search_excerpt('HTMLTest', $text);
+ $this->assertFalse(empty($result), 'Rendered Multi-byte HTML encodings are not corrupted in search excerpts');
}
/**
@@ -42,6 +42,15 @@ Drupal.behaviors.shortcutDrag = {
if (total == -1) {
var disabled = $(table).find('tr.shortcut-status-disabled');
disabled.after(disabled.prevAll().filter(':not(.shortcut-slot-empty)').get(0));
+ if ($(swappedRow).hasClass('draggable')) {
+ // The dropped element will automatically be marked as changed by
+ // the tableDrag system. However, the row that swapped with it
+ // has moved to the "disabled" section, so we need to force its
+ // status to be disabled and mark it also as changed.
+ swappedRowObject = new tableDrag.row(swappedRow, 'mouse', self.indentEnabled, self.maxDepth, true);
+ swappedRowObject.markChanged();
+ rowStatusChange(swappedRowObject);
+ }
}
else if (total != visibleLength) {
if (total > visibleLength) {
@@ -59,13 +68,17 @@ Drupal.behaviors.shortcutDrag = {
// Add a handler so when a row is dropped, update fields dropped into new regions.
tableDrag.onDrop = function () {
+ rowStatusChange(this.rowObject);
+ return true;
+ };
+
+ function rowStatusChange(rowObject) {
// Use "status-message" row instead of "status" row because
// "status-{status_name}-message" is less prone to regexp match errors.
- var statusRow = $(this.rowObject.element).prevAll('tr.shortcut-status').get(0);
+ var statusRow = $(rowObject.element).prevAll('tr.shortcut-status').get(0);
var statusName = statusRow.className.replace(/([^ ]+[ ]+)*shortcut-status-([^ ]+)([ ]+[^ ]+)*/, '$2');
- var statusField = $('select.shortcut-status-select', this.rowObject.element);
+ var statusField = $('select.shortcut-status-select', rowObject.element);
statusField.val(statusName);
- return true;
};
tableDrag.restripeTable = function () {
@@ -20,10 +20,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'SimpleTest functionality',
- 'description' => 'Test SimpleTest\'s web interface: check that the intended tests were
- run and ensure that test reports display the intended results. Also
- test SimpleTest\'s internal browser and API\'s both explicitly and
- implicitly.',
+ 'description' => "Test SimpleTest's web interface: check that the intended tests were run and ensure that test reports display the intended results. Also test SimpleTest's internal browser and API's both explicitly and implicitly.",
'group' => 'SimpleTest'
);
}
@@ -976,16 +976,16 @@ function system_menu() {
);
$items['admin/config/system/site-information'] = array(
'title' => 'Site information',
- 'description' => t('Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.'),
+ 'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.',
'page callback' => 'drupal_get_form',
'page arguments' => array('system_site_information_settings'),
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
'weight' => -20,
);
$items['admin/config/system/cron'] = array(
- 'title' => t('Cron'),
- 'description' => t('Manage automatic site maintenance tasks.'),
+ 'title' => 'Cron',
+ 'description' => 'Manage automatic site maintenance tasks.',
'page callback' => 'drupal_get_form',
'page arguments' => array('system_cron_settings'),
'access arguments' => array('administer site configuration'),
@@ -428,6 +428,7 @@ function taxonomy_vocabulary_save($vocabulary) {
if (!empty($vocabulary->vid) && !empty($vocabulary->name)) {
$status = drupal_write_record('taxonomy_vocabulary', $vocabulary, 'vid');
+ taxonomy_vocabulary_static_reset(array($vocabulary->vid));
if ($vocabulary->old_machine_name != $vocabulary->machine_name) {
field_attach_rename_bundle('taxonomy_term', $vocabulary->old_machine_name, $vocabulary->machine_name);
}
@@ -436,14 +437,14 @@ function taxonomy_vocabulary_save($vocabulary) {
}
elseif (empty($vocabulary->vid)) {
$status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
+ taxonomy_vocabulary_static_reset();
field_attach_create_bundle('taxonomy_term', $vocabulary->machine_name);
module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
module_invoke_all('entity_insert', $vocabulary, 'taxonomy_vocabulary');
}
unset($vocabulary->original);
cache_clear_all();
- taxonomy_vocabulary_static_reset(array($vocabulary->vid));
return $status;
}
@@ -1290,10 +1290,16 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase {
);
field_update_field($this->field);
// Change the machine name.
+ $old_name = $this->vocabulary->machine_name;
$new_name = drupal_strtolower($this->randomName());
$this->vocabulary->machine_name = $new_name;
taxonomy_vocabulary_save($this->vocabulary);
+ // Check that entity bundles are properly updated.
+ $info = entity_get_info('taxonomy_term');
+ $this->assertFalse(isset($info['bundles'][$old_name]), t('The old bundle name does not appear in entity_get_info().'));
+ $this->assertTrue(isset($info['bundles'][$new_name]), t('The new bundle name appears in entity_get_info().'));
+
// Check that the field instance is still attached to the vocabulary.
$field = field_info_field($this->field_name);
$allowed_values = $field['settings']['allowed_values'];
@@ -82,6 +82,7 @@ function toolbar_toggle_page() {
* An associative array containing:
* - collapsed: A boolean value representing the toolbar drawer's visibility.
* - attributes: An associative array of HTML attributes.
+ *
* @return
* An HTML string representing the element for toggling.
*
@@ -175,7 +176,10 @@ function toolbar_system_info_alter(&$info, $file, $type) {
}
/**
- * Build the admin menu as a structured array ready for drupal_render().
+ * Builds the admin menu as a structured array ready for drupal_render().
+ *
+ * @return
+ * Array of links and settings relating to the admin menu.
*/
function toolbar_view() {
global $user;
@@ -272,7 +276,10 @@ function toolbar_view() {
}
/**
- * Get only the top level items below the 'admin' path.
+ * Gets only the top level items below the 'admin' path.
+ *
+ * @return
+ * An array containing a menu tree of top level items below the 'admin' path.
*/
function toolbar_get_menu_tree() {
$tree = array();
@@ -289,10 +296,13 @@ function toolbar_get_menu_tree() {
}
/**
- * Generate a links array from a menu tree array.
+ * Generates a links array from a menu tree array.
*
* Based on menu_navigation_links(). Adds path based IDs and icon placeholders
* to the links.
+ *
+ * @return
+ * An array of links as defined above.
*/
function toolbar_menu_navigation_links($tree) {
$links = array();
@@ -330,6 +340,9 @@ function toolbar_menu_navigation_links($tree) {
* Useful when using a menu generated by menu_tree_all_data() which does
* not set the 'in_active_trail' flag on items.
*
+ * @return
+ * TRUE when path is in the active trail, FALSE if not.
+ *
* @todo
* Look at migrating to a menu system level function.
*/
@@ -1,5 +1,4 @@
-<?php
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
<head>
@@ -1,5 +1,4 @@
-<?php
-?>
+
<div id="branding" class="clearfix">
<?php print $breadcrumb; ?>
<?php print render($title_prefix); ?>

0 comments on commit e1bb611

Please sign in to comment.