drupal core updated to 7.28

This commit is contained in:
Bachir Soussi Chiadmi
2014-07-07 18:53:44 +02:00
parent 10de06dd70
commit c3011cef61
263 changed files with 3331 additions and 8894 deletions

View File

@@ -255,11 +255,11 @@ function _node_characters($length) {
*/
function node_type_form_validate($form, &$form_state) {
$type = new stdClass();
$type->type = trim($form_state['values']['type']);
$type->type = $form_state['values']['type'];
$type->name = trim($form_state['values']['name']);
// Work out what the type was before the user submitted this form
$old_type = trim($form_state['values']['old_type']);
$old_type = $form_state['values']['old_type'];
$types = node_type_get_names();
@@ -288,7 +288,7 @@ function node_type_form_submit($form, &$form_state) {
$type = node_type_set_defaults();
$type->type = trim($form_state['values']['type']);
$type->type = $form_state['values']['type'];
$type->name = trim($form_state['values']['name']);
$type->orig_type = trim($form_state['values']['orig_type']);
$type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;

View File

@@ -471,6 +471,7 @@ function node_admin_nodes() {
$header['operations'] = array('data' => t('Operations'));
$query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
$query->addTag('node_admin_filter');
node_build_filter_query($query);
if (!user_access('bypass node access')) {
@@ -695,6 +696,7 @@ function node_multiple_delete_confirm($form, &$form_state, $nodes) {
function node_multiple_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
node_delete_multiple(array_keys($form_state['values']['nodes']));
cache_clear_all();
$count = count($form_state['values']['nodes']);
watchdog('content', 'Deleted @count posts.', array('@count' => $count));
drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));

View File

@@ -1033,9 +1033,17 @@ function hook_node_type_delete($info) {
* This hook is invoked only on the module that defines the node's content type
* (use hook_node_delete() to respond to all node deletions).
*
* This hook is invoked from node_delete_multiple() after the node has been
* removed from the node table in the database, before hook_node_delete() is
* invoked, and before field_attach_delete() is called.
* This hook is invoked from node_delete_multiple() before hook_node_delete()
* is invoked and before field_attach_delete() is called.
*
* Note that when this hook is invoked, the changes have not yet been written
* to the database, because a database transaction is still in progress. The
* transaction is not finalized until the delete operation is entirely
* completed and node_delete_multiple() goes out of scope. You should not rely
* on data in the database at this time as it is not updated yet. You should
* also note that any write/update database queries executed from this hook are
* also not committed immediately. Check node_delete_multiple() and
* db_transaction() for more info.
*
* @param $node
* The node that is being deleted.
@@ -1063,21 +1071,19 @@ function hook_delete($node) {
* @ingroup node_api_hooks
*/
function hook_prepare($node) {
if ($file = file_check_upload($field_name)) {
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
if ($file) {
if (!image_get_info($file->uri)) {
form_set_error($field_name, t('Uploaded file is not a valid image'));
return;
}
}
else {
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
if ($file) {
if (!image_get_info($file->uri)) {
form_set_error($field_name, t('Uploaded file is not a valid image'));
return;
}
$node->images['_original'] = $file->uri;
_image_build_derivatives($node, TRUE);
$node->new_file = TRUE;
}
else {
return;
}
$node->images['_original'] = $file->uri;
_image_build_derivatives($node, TRUE);
$node->new_file = TRUE;
}
/**

View File

@@ -9,8 +9,8 @@ required = TRUE
configure = admin/structure/types
stylesheets[all][] = node.css
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"

View File

@@ -114,6 +114,7 @@ function node_schema() {
'uid' => array('uid'),
'tnid' => array('tnid'),
'translate' => array('translate'),
'language' => array('language'),
),
'unique keys' => array(
'vid' => array('vid'),
@@ -925,6 +926,13 @@ function node_update_7013() {
db_add_unique_key('node', 'vid', array('vid'));
}
/**
* Add an index on {node}.language.
*/
function node_update_7014() {
db_add_index('node', 'language', array('language'));
}
/**
* @} End of "addtogroup updates-7.x-extra".
*/

View File

@@ -1179,10 +1179,8 @@ function node_save($node) {
module_invoke_all('node_' . $op, $node);
module_invoke_all('entity_' . $op, $node, 'node');
// Update the node access table for this node. There's no need to delete
// existing records if the node is new.
$delete = $op == 'update';
node_access_acquire_grants($node, $delete);
// Update the node access table for this node.
node_access_acquire_grants($node);
// Clear internal properties.
unset($node->is_new);
@@ -1685,7 +1683,7 @@ function node_search_admin() {
);
$form['content_ranking']['#theme'] = 'node_search_admin';
$form['content_ranking']['info'] = array(
'#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>'
'#markup' => '<p><em>' . t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em></p>'
);
// Note: reversed to reflect that higher number = higher ranking.
@@ -1872,7 +1870,7 @@ function theme_node_search_admin($variables) {
$output = drupal_render($form['info']);
$header = array(t('Factor'), t('Weight'));
$header = array(t('Factor'), t('Influence'));
foreach (element_children($form['factors']) as $key) {
$row = array();
$row[] = $form['factors'][$key]['#title'];
@@ -2224,8 +2222,8 @@ function node_last_changed($nid) {
/**
* Returns a list of all the existing revision numbers.
*
* @param Drupal\node\Node $node
* The node entity.
* @param $node
* The node object.
*
* @return
* An associative array keyed by node revision number.
@@ -3292,6 +3290,17 @@ function node_query_entity_field_access_alter(QueryAlterableInterface $query) {
/**
* Helper for node access functions.
*
* Queries tagged with 'node_access' that are not against the {node} table
* should add the base table as metadata. For example:
* @code
* $query
* ->addTag('node_access')
* ->addMetaData('base_table', 'taxonomy_index');
* @endcode
* If the query is not against the {node} table, an attempt is made to guess
* the table, but is not recommended to rely on this as it is deprecated and not
* allowed in Drupal 8. It is always safer to provide the table.
*
* @param $query
* The query to add conditions to.
* @param $type

View File

@@ -542,6 +542,7 @@ function node_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$node = node_load($form_state['values']['nid']);
node_delete($form_state['values']['nid']);
cache_clear_all();
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
}

View File

@@ -571,6 +571,8 @@ class NodeCreationTestCase extends DrupalWebTestCase {
);
try {
// An exception is generated by node_test_exception_node_insert() if the
// title is 'testing_transaction_exception'.
node_save((object) $edit);
$this->fail(t('Expected exception has not been thrown.'));
}
@@ -1363,6 +1365,22 @@ class NodeSaveTestCase extends DrupalWebTestCase {
$node = node_load($node->nid);
$this->assertEqual($node->title, 'updated_presave', 'Static cache has been cleared.');
}
/**
* Tests saving a node on node insert.
*
* This test ensures that a node has been fully saved when hook_node_insert()
* is invoked, so that the node can be saved again in a hook implementation
* without errors.
*
* @see node_test_node_insert()
*/
function testNodeSaveOnInsert() {
// node_test_node_insert() triggers a save on insert if the title equals
// 'new'.
$node = $this->drupalCreateNode(array('title' => 'new'));
$this->assertEqual($node->title, 'Node ' . $node->nid, 'Node saved on node insert.');
}
}
/**
@@ -2426,6 +2444,35 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input)));
}
// Repeat for a node without a summary.
$settings['body'] = array(LANGUAGE_NONE => array(array('value' => $this->randomName(32), 'summary' => '')));
$node = $this->drupalCreateNode($settings);
// Load node (without summary) so that the body and summary fields are
// structured properly.
$node = node_load($node->nid);
$instance = field_info_instance('node', 'body', $node->type);
// Generate and test sanitized token - use full body as expected value.
$tests = array();
$tests['[node:summary]'] = _text_sanitize($instance, $langcode, $node->body[$langcode][0], 'value');
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.');
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('language' => $language));
$this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced for node without a summary.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
$tests['[node:summary]'] = $node->body[$langcode][0]['value'];
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input)));
}
}
}
@@ -2755,3 +2802,78 @@ class NodeEntityViewModeAlterTest extends NodeWebTestCase {
$this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.');
}
}
/**
* Tests the cache invalidation of node operations.
*/
class NodePageCacheTest extends NodeWebTestCase {
/**
* An admin user with administrative permissions for nodes.
*/
protected $admin_user;
public static function getInfo() {
return array(
'name' => 'Node page cache test',
'description' => 'Test cache invalidation of node operations.',
'group' => 'Node',
);
}
function setUp() {
parent::setUp();
variable_set('cache', 1);
variable_set('page_cache_maximum_age', 300);
$this->admin_user = $this->drupalCreateUser(array(
'bypass node access',
'access content overview',
'administer nodes',
));
}
/**
* Tests deleting nodes clears page cache.
*/
public function testNodeDelete() {
$node_path = 'node/' . $this->drupalCreateNode()->nid;
// Populate page cache.
$this->drupalGet($node_path);
// Login and delete the node.
$this->drupalLogin($this->admin_user);
$this->drupalPost($node_path . '/delete', array(), t('Delete'));
// Logout and check the node is not available.
$this->drupalLogout();
$this->drupalGet($node_path);
$this->assertResponse(404);
// Create two new nodes.
$nodes[0] = $this->drupalCreateNode();
$nodes[1] = $this->drupalCreateNode();
$node_path = 'node/' . $nodes[0]->nid;
// Populate page cache.
$this->drupalGet($node_path);
// Login and delete the nodes.
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/content');
$edit = array(
'operation' => 'delete',
'nodes[' . $nodes[0]->nid . ']' => TRUE,
'nodes[' . $nodes[1]->nid . ']' => TRUE,
);
$this->drupalPost(NULL, $edit, t('Update'));
$this->drupalPost(NULL, array(), t('Delete'));
// Logout and check the node is not available.
$this->drupalLogout();
$this->drupalGet($node_path);
$this->assertResponse(404);
}
}

View File

@@ -136,10 +136,29 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
case 'body':
case 'summary':
if ($items = field_get_items('node', $node, 'body', $language_code)) {
$column = ($name == 'body') ? 'value' : 'summary';
$instance = field_info_instance('node', 'body', $node->type);
$field_langcode = field_language('node', $node, 'body', $language_code);
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
// If the summary was requested and is not empty, use it.
if ($name == 'summary' && !empty($items[0]['summary'])) {
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'summary') : $items[0]['summary'];
}
// Attempt to provide a suitable version of the 'body' field.
else {
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
// A summary was requested.
if ($name == 'summary') {
if (isset($instance['display']['teaser']['settings']['trim_length'])) {
$trim_length = $instance['display']['teaser']['settings']['trim_length'];
}
else {
// Use default value.
$trim_length = NULL;
}
// Generate an optionally trimmed summary of the body field.
$output = text_summary($output, $instance['settings']['text_processing'] ? $items[0]['format'] : NULL, $trim_length);
}
}
$replacements[$original] = $output;
}
break;

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"

View File

@@ -161,3 +161,21 @@ function node_test_entity_view_mode_alter(&$view_mode, $context) {
$view_mode = $change_view_mode;
}
}
/**
* Implements hook_node_insert().
*
* This tests saving a node on node insert.
*
* @see NodeSaveTest::testNodeSaveOnInsert()
*/
function node_test_node_insert($node) {
// Set the node title to the node ID and save.
if ($node->title == 'new') {
$node->title = 'Node '. $node->nid;
// Remove the is_new flag, so that the node is updated and not inserted
// again.
unset($node->is_new);
node_save($node);
}
}

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-08-08
version = "7.23"
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1375928238"
datestamp = "1399522731"