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

126
modules/system/form.api.php Normal file
View File

@@ -0,0 +1,126 @@
<?php
/**
* @file
* Callbacks provided by the form system.
*/
/**
* @addtogroup callbacks
* @{
*/
/**
* Perform a single batch operation.
*
* Callback for batch_set().
*
* @param $MULTIPLE_PARAMS
* Additional parameters specific to the batch. These are specified in the
* array passed to batch_set().
* @param $context
* The batch context array, passed by reference. This contains the following
* properties:
* - 'finished': A float number between 0 and 1 informing the processing
* engine of the completion level for the operation. 1 (or no value
* explicitly set) means the operation is finished: the operation will not
* be called again, and execution passes to the next operation or the
* callback_batch_finished() implementation. Any other value causes this
* operation to be called again; however it should be noted that the value
* set here does not persist between executions of this callback: each time
* it is set to 1 by default by the batch system.
* - 'sandbox': This may be used by operations to persist data between
* successive calls to the current operation. Any values set in
* $context['sandbox'] will be there the next time this function is called
* for the current operation. For example, an operation may wish to store a
* pointer in a file or an offset for a large query. The 'sandbox' array key
* is not initially set when this callback is first called, which makes it
* useful for determining whether it is the first call of the callback or
* not:
* @code
* if (empty($context['sandbox'])) {
* // Perform set-up steps here.
* }
* @endcode
* The values in the sandbox are stored and updated in the database between
* http requests until the batch finishes processing. This avoids problems
* if the user navigates away from the page before the batch finishes.
* - 'message': A text message displayed in the progress page.
* - 'results': The array of results gathered so far by the batch processing.
* This array is highly useful for passing data between operations. After
* all operations have finished, this is passed to callback_batch_finished()
* where results may be referenced to display information to the end-user,
* such as how many total items were processed.
*/
function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['current_node'] = 0;
$context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
}
// For this example, we decide that we can safely process
// 5 nodes at a time without a timeout.
$limit = 5;
// With each pass through the callback, retrieve the next group of nids.
$result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
while ($row = db_fetch_array($result)) {
// Here we actually perform our processing on the current node.
$node = node_load($row['nid'], NULL, TRUE);
$node->value1 = $options1;
$node->value2 = $options2;
node_save($node);
// Store some result for post-processing in the finished callback.
$context['results'][] = check_plain($node->title);
// Update our progress information.
$context['sandbox']['progress']++;
$context['sandbox']['current_node'] = $node->nid;
$context['message'] = t('Now processing %node', array('%node' => $node->title));
}
// Inform the batch engine that we are not finished,
// and provide an estimation of the completion level we reached.
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
}
}
/**
* Complete a batch process.
*
* Callback for batch_set().
*
* This callback may be specified in a batch to perform clean-up operations, or
* to analyze the results of the batch operations.
*
* @param $success
* A boolean indicating whether the batch has completed successfully.
* @param $results
* The value set in $context['results'] by callback_batch_operation().
* @param $operations
* If $success is FALSE, contains the operations that remained unprocessed.
*/
function callback_batch_finished($success, $results, $operations) {
if ($success) {
// Here we do something meaningful with the results.
$message = t("!count items were processed.", array(
'!count' => count($results),
));
$message .= theme('item_list', array('items' => $results));
drupal_set_message($message);
}
else {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
$message = t('An error occurred while processing %error_operation with arguments: @arguments', array(
'%error_operation' => $error_operation[0],
'@arguments' => print_r($error_operation[1], TRUE)
));
drupal_set_message($message, 'error');
}
}

View File

@@ -56,13 +56,8 @@ function image_gd_settings_validate($form, &$form_state) {
* A boolean indicating if the GD toolkit is available on this machine.
*/
function image_gd_check_settings() {
if ($check = get_extension_funcs('gd')) {
if (in_array('imagegd2', $check)) {
// GD2 support is available.
return TRUE;
}
}
return FALSE;
// GD2 support is available.
return function_exists('imagegd2');
}
/**
@@ -346,7 +341,7 @@ function image_gd_create_tmp(stdClass $image, $width, $height) {
*/
function image_gd_get_info(stdClass $image) {
$details = FALSE;
$data = getimagesize($image->source);
$data = @getimagesize($image->source);
if (isset($data) && is_array($data)) {
$extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');

View File

@@ -111,18 +111,18 @@ function hook_language_types_info_alter(array &$language_types) {
*
* @return
* An associative array of language negotiation provider definitions. The keys
* are provider identifiers, and the values are associative arrays definining
* are provider identifiers, and the values are associative arrays defining
* each provider, with the following elements:
* - types: An array of allowed language types. If a language negotiation
* provider does not specify which language types it should be used with, it
* will be available for all the configurable language types.
* - callbacks: An associative array of functions that will be called to
* perform various tasks. Possible elements are:
* - negotiation: (required) Name of the callback function that determines
* the language value.
* - language_switch: (optional) Name of the callback function that
* determines links for a language switcher block associated with this
* provider. See language_switcher_url() for an example.
* - language: (required) Name of the callback function that determines the
* language value.
* - switcher: (optional) Name of the callback function that determines
* links for a language switcher block associated with this provider. See
* language_switcher_url() for an example.
* - url_rewrite: (optional) Name of the callback function that provides URL
* rewriting, if needed by this provider.
* - file: The file where callback functions are defined (this file will be

View File

@@ -309,7 +309,7 @@ function system_theme_enable() {
}
drupal_goto('admin/appearance');
}
return drupal_access_denied();
return MENU_ACCESS_DENIED;
}
/**
@@ -337,7 +337,7 @@ function system_theme_disable() {
}
drupal_goto('admin/appearance');
}
return drupal_access_denied();
return MENU_ACCESS_DENIED;
}
/**
@@ -383,7 +383,7 @@ function system_theme_default() {
}
drupal_goto('admin/appearance');
}
return drupal_access_denied();
return MENU_ACCESS_DENIED;
}
/**
@@ -995,22 +995,28 @@ function _system_modules_build_row($info, $extra) {
$status_short = '';
$status_long = '';
// Initialize empty arrays of long and short reasons explaining why the
// module is incompatible.
// Add each reason as a separate element in both the arrays.
$reasons_short = array();
$reasons_long = array();
// Check the core compatibility.
if (!isset($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
$compatible = FALSE;
$status_short .= t('Incompatible with this version of Drupal core.');
$status_long .= t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY));
$reasons_short[] = t('Incompatible with this version of Drupal core.');
$reasons_long[] = t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY));
}
// Ensure this module is compatible with the currently installed version of PHP.
if (version_compare(phpversion(), $info['php']) < 0) {
$compatible = FALSE;
$status_short .= t('Incompatible with this version of PHP');
$reasons_short[] = t('Incompatible with this version of PHP');
$php_required = $info['php'];
if (substr_count($info['php'], '.') < 2) {
$php_required .= '.*';
}
$status_long .= t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion()));
$reasons_long[] = t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion()));
}
// If this module is compatible, present a checkbox indicating
@@ -1026,6 +1032,8 @@ function _system_modules_build_row($info, $extra) {
}
}
else {
$status_short = implode(' ', $reasons_short);
$status_long = implode(' ', $reasons_long);
$form['enable'] = array(
'#markup' => theme('image', array('path' => 'misc/watchdog-error.png', 'alt' => $status_short, 'title' => $status_short)),
);
@@ -1618,6 +1626,7 @@ function system_cron_settings() {
$form['cron']['cron_safe_threshold'] = array(
'#type' => 'select',
'#title' => t('Run cron every'),
'#description' => t('More information about setting up scheduled tasks can be found by <a href="@url">reading the cron tutorial on drupal.org</a>.', array('@url' => url('http://drupal.org/cron'))),
'#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD),
'#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
);
@@ -2575,7 +2584,7 @@ function theme_status_report($variables) {
foreach ($requirements as $requirement) {
if (empty($requirement['#type'])) {
$severity = $severities[isset($requirement['severity']) ? (int) $requirement['severity'] : 0];
$severity = $severities[isset($requirement['severity']) ? (int) $requirement['severity'] : REQUIREMENT_OK];
$severity['icon'] = '<div title="' . $severity['title'] . '"><span class="element-invisible">' . $severity['title'] . '</span></div>';
// Output table row(s)

View File

@@ -607,10 +607,12 @@ function hook_cron() {
* An associative array where the key is the queue name and the value is
* again an associative array. Possible keys are:
* - 'worker callback': The name of the function to call. It will be called
* with one argument, the item created via DrupalQueue::createItem() in
* hook_cron().
* with one argument, the item created via DrupalQueue::createItem().
* - 'time': (optional) How much time Drupal should spend on calling this
* worker in seconds. Defaults to 15.
* - 'skip on cron': (optional) Set to TRUE to avoid being processed during
* cron runs (for example, if you want to control all queue execution
* manually).
*
* @see hook_cron()
* @see hook_cron_queue_info_alter()
@@ -873,7 +875,7 @@ function hook_css_alter(&$css) {
*
* @see ajax_render()
*/
function hook_ajax_render_alter($commands) {
function hook_ajax_render_alter(&$commands) {
// Inject any new status messages into the content area.
$commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
}
@@ -3098,37 +3100,39 @@ function hook_requirements($phase) {
/**
* Define the current version of the database schema.
*
* A Drupal schema definition is an array structure representing one or
* more tables and their related keys and indexes. A schema is defined by
* A Drupal schema definition is an array structure representing one or more
* tables and their related keys and indexes. A schema is defined by
* hook_schema() which must live in your module's .install file.
*
* This hook is called at install and uninstall time, and in the latter
* case, it cannot rely on the .module file being loaded or hooks being known.
* If the .module file is needed, it may be loaded with drupal_load().
* This hook is called at install and uninstall time, and in the latter case, it
* cannot rely on the .module file being loaded or hooks being known. If the
* .module file is needed, it may be loaded with drupal_load().
*
* The tables declared by this hook will be automatically created when
* the module is first enabled, and removed when the module is uninstalled.
* This happens before hook_install() is invoked, and after hook_uninstall()
* is invoked, respectively.
* The tables declared by this hook will be automatically created when the
* module is first enabled, and removed when the module is uninstalled. This
* happens before hook_install() is invoked, and after hook_uninstall() is
* invoked, respectively.
*
* By declaring the tables used by your module via an implementation of
* hook_schema(), these tables will be available on all supported database
* engines. You don't have to deal with the different SQL dialects for table
* creation and alteration of the supported database engines.
*
* See the Schema API Handbook at http://drupal.org/node/146843 for
* details on schema definition structures.
* See the Schema API Handbook at http://drupal.org/node/146843 for details on
* schema definition structures.
*
* @return
* @return array
* A schema definition structure array. For each element of the
* array, the key is a table name and the value is a table structure
* definition.
*
* @see hook_schema_alter()
*
* @ingroup schemaapi
*/
function hook_schema() {
$schema['node'] = array(
// example (partial) specification for table "node"
// Example (partial) specification for table "node".
'description' => 'The base table for nodes.',
'fields' => array(
'nid' => array(
@@ -4095,7 +4099,7 @@ function hook_date_format_types_alter(&$types) {
* declared in an implementation of hook_date_format_types().
* - 'format': A PHP date format string to use when formatting dates. It
* can contain any of the formatting options described at
* http://php.net/manual/en/function.date.php
* http://php.net/manual/function.date.php
* - 'locales': (optional) An array of 2 and 5 character locale codes,
* defining which locales this format applies to (for example, 'en',
* 'en-us', etc.). If your date format is not language-specific, leave this

View File

@@ -12,8 +12,8 @@ files[] = system.test
required = TRUE
configure = admin/config/system
; 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

@@ -6,12 +6,7 @@
*/
/**
* Test and report Drupal installation requirements.
*
* @param $phase
* The current system installation phase.
* @return
* An array of system requirements.
* Implements hook_requirements().
*/
function system_requirements($phase) {
global $base_url;
@@ -258,6 +253,39 @@ function system_requirements($phase) {
$requirements['settings.php']['title'] = $t('Configuration file');
}
// Test the contents of the .htaccess files.
if ($phase == 'runtime') {
// Try to write the .htaccess files first, to prevent false alarms in case
// (for example) the /tmp directory was wiped.
file_ensure_htaccess();
$htaccess_files['public://.htaccess'] = array(
'title' => $t('Public files directory'),
'directory' => variable_get('file_public_path', conf_path() . '/files'),
);
if ($private_files_directory = variable_get('file_private_path')) {
$htaccess_files['private://.htaccess'] = array(
'title' => $t('Private files directory'),
'directory' => $private_files_directory,
);
}
$htaccess_files['temporary://.htaccess'] = array(
'title' => $t('Temporary files directory'),
'directory' => variable_get('file_temporary_path', file_directory_temp()),
);
foreach ($htaccess_files as $htaccess_file => $info) {
// Check for the string which was added to the recommended .htaccess file
// in the latest security update.
if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
$requirements[$htaccess_file] = array(
'title' => $info['title'],
'value' => $t('Not fully protected'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('See <a href="@url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', array('@url' => 'http://drupal.org/SA-CORE-2013-003', '%directory' => $info['directory'])),
);
}
}
}
// Report cron status.
if ($phase == 'runtime') {
// Cron warning threshold defaults to two days.
@@ -516,7 +544,7 @@ function system_install() {
->execute();
// Populate the cron key variable.
$cron_key = drupal_hash_base64(drupal_random_bytes(55));
$cron_key = drupal_random_key();
variable_set('cron_key', $cron_key);
}
@@ -830,6 +858,7 @@ function system_schema() {
'filesize' => array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
@@ -1743,7 +1772,7 @@ function system_update_7000() {
* Generate a cron key and save it in the variables table.
*/
function system_update_7001() {
variable_set('cron_key', drupal_hash_base64(drupal_random_bytes(55)));
variable_set('cron_key', drupal_random_key());
}
/**
@@ -3106,6 +3135,21 @@ function system_update_7078() {
), array('unique keys' => array('formats' => array('format', 'type'))));
}
/**
* Convert the 'filesize' column in {file_managed} to a bigint.
*/
function system_update_7079() {
$spec = array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
db_change_field('file_managed', 'filesize', 'filesize', $spec);
}
/**
* @} End of "defgroup updates-7.x-extra".
* The next series of updates should start at 8000.

View File

@@ -31,7 +31,7 @@ class DefaultMailSystem implements MailSystemInterface {
/**
* Send an e-mail message, using Drupal variables and default settings.
*
* @see http://php.net/manual/en/function.mail.php
* @see http://php.net/manual/function.mail.php
* @see drupal_mail()
*
* @param $message

View File

@@ -2730,7 +2730,17 @@ function system_default_region($theme) {
}
/**
* Add default buttons to a form and set its prefix.
* Sets up a form to save information automatically.
*
* This function adds a submit handler and a submit button to a form array. The
* submit function saves all the data in the form, using variable_set(), to
* variables named the same as the keys in the form array. Note that this means
* you should normally prefix your form array keys with your module name, so
* that they are unique when passed into variable_set().
*
* If you need to manipulate the data in a custom manner, you can either put
* your own submission handler in the form array before calling this function,
* or just use your own submission handler instead of calling this function.
*
* @param $form
* An associative array containing the structure of the form.
@@ -2739,6 +2749,7 @@ function system_default_region($theme) {
* The form structure.
*
* @see system_settings_form_submit()
*
* @ingroup forms
*/
function system_settings_form($form) {
@@ -2757,7 +2768,7 @@ function system_settings_form($form) {
}
/**
* Execute the system_settings_form.
* Form submission handler for system_settings_form().
*
* If you want node type configure style handling of your checkboxes,
* add an array_filter value to your form.
@@ -3411,30 +3422,32 @@ function system_image_toolkits() {
/**
* Attempts to get a file using drupal_http_request and to store it locally.
*
* @param $url
* @param string $url
* The URL of the file to grab.
*
* @param $destination
* @param string $destination
* Stream wrapper URI specifying where the file should be placed. If a
* directory path is provided, the file is saved into that directory under
* its original name. If the path contains a filename as well, that one will
* be used instead.
* If this value is omitted, the site's default files scheme will be used,
* usually "public://".
*
* @param $managed boolean
* @param bool $managed
* If this is set to TRUE, the file API hooks will be invoked and the file is
* registered in the database.
*
* @param $replace boolean
* @param int $replace
* Replace behavior when the destination file already exists:
* - FILE_EXISTS_REPLACE: Replace the existing file.
* - FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is
* unique.
* - FILE_EXISTS_ERROR: Do nothing and return FALSE.
*
* @return
* On success the location the file was saved to, FALSE on failure.
* @return mixed
* One of these possibilities:
* - If it succeeds and $managed is FALSE, the location where the file was
* saved.
* - If it succeeds and $managed is TRUE, a \Drupal\file\FileInterface
* object which describes the file.
* - If it fails, FALSE.
*/
function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) {
$parsed_url = parse_url($url);

View File

@@ -867,6 +867,44 @@ class CronRunTestCase extends DrupalWebTestCase {
}
}
/**
* Test execution of the cron queue.
*/
class CronQueueTestCase extends DrupalWebTestCase {
/**
* Implement getInfo().
*/
public static function getInfo() {
return array(
'name' => 'Cron queue functionality',
'description' => 'Tests the cron queue runner.',
'group' => 'System'
);
}
function setUp() {
parent::setUp(array('common_test', 'common_test_cron_helper'));
}
/**
* Tests that exceptions thrown by workers are handled properly.
*/
function testExceptions() {
$queue = DrupalQueue::get('cron_queue_test_exception');
// Enqueue an item for processing.
$queue->createItem(array($this->randomName() => $this->randomName()));
// Run cron; the worker for this queue should throw an exception and handle
// it.
$this->cronRun();
// The item should be left in the queue.
$this->assertEqual($queue->numberOfItems(), 1, 'Failing item still in the queue after throwing an exception.');
}
}
class AdminMetaTagTestCase extends DrupalWebTestCase {
/**
* Implement getInfo().
@@ -2712,3 +2750,50 @@ class TokenScanTest extends DrupalWebTestCase {
}
}
/**
* Test case for drupal_valid_token().
*/
class SystemValidTokenTest extends DrupalUnitTestCase {
/**
* Flag to indicate whether PHP error reportings should be asserted.
*
* @var bool
*/
protected $assertErrors = TRUE;
public static function getInfo() {
return array(
'name' => 'Token validation',
'description' => 'Test the security token validation.',
'group' => 'System',
);
}
/**
* Tests invalid invocations of drupal_valid_token() that must return FALSE.
*/
public function testTokenValidation() {
// The following checks will throw PHP notices, so we disable error
// assertions.
$this->assertErrors = FALSE;
$this->assertFalse(drupal_valid_token(NULL, new stdClass()), 'Token NULL, value object returns FALSE.');
$this->assertFalse(drupal_valid_token(0, array()), 'Token 0, value array returns FALSE.');
$this->assertFalse(drupal_valid_token('', array()), "Token '', value array returns FALSE.");
$this->assertFalse('' === drupal_get_token(array()), 'Token generation does not return an empty string on invalid parameters.');
$this->assertErrors = TRUE;
$this->assertFalse(drupal_valid_token(TRUE, 'foo'), 'Token TRUE, value foo returns FALSE.');
$this->assertFalse(drupal_valid_token(0, 'foo'), 'Token 0, value foo returns FALSE.');
}
/**
* Overrides DrupalTestCase::errorHandler().
*/
public function errorHandler($severity, $message, $file = NULL, $line = NULL) {
if ($this->assertErrors) {
return parent::errorHandler($severity, $message, $file, $line);
}
return TRUE;
}
}

View File

@@ -0,0 +1,12 @@
name = Cron Queue test
description = 'Support module for the cron queue runner.'
package = Testing
version = VERSION
core = 7.x
hidden = TRUE
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
project = "drupal"
datestamp = "1399522731"

View File

@@ -0,0 +1,15 @@
<?php
/**
* Implements hook_cron_queue_info().
*/
function cron_queue_test_cron_queue_info() {
$queues['cron_queue_test_exception'] = array(
'worker callback' => 'cron_queue_test_exception',
);
return $queues;
}
function cron_queue_test_exception($item) {
throw new Exception('That is not supposed to happen.');
}