security update core+modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-26 18:38:56 +02:00
parent 2f45ea820a
commit 7c96373038
1022 changed files with 30319 additions and 11259 deletions

View File

@@ -1,175 +0,0 @@
<?php
/**
* @file
* Support for migration into Date fields.
*/
class DateMigrateFieldHandler extends MigrateFieldHandler {
/**
* Declares the types of fields used.
*/
public function __construct() {
$this->registerTypes(array('date', 'datestamp', 'datetime'));
}
/**
* Arguments for a date field migration.
*
* @param string $timezone
* Timezone (such as UTC, America/New_York, etc.) to apply.
* @param string $timezone_db
* Timezone_db value for the field.
* @param string $rrule
* Rule string for a repeating date field.
* @param string $language
* Language of the text (defaults to destination language)
*
* @return array
* An array of the defined variables in this scope.
*/
static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) {
return get_defined_vars();
}
/**
* Converts incoming data into the proper field arrays for Date fields.
*
* @param object $entity
* The destination entity which will hold the field arrays.
* @param array $field_info
* Metadata for the date field being populated.
* @param array $instance
* Metadata for this instance of the date field being populated.
* @param array $values
* Array of date values to be fielded.
*
* @return array|null
* An array of date fields.
*/
public function prepare($entity, array $field_info, array $instance, array $values) {
if (isset($values['arguments'])) {
$arguments = $values['arguments'];
unset($values['arguments']);
}
else {
$arguments = array();
}
if (isset($arguments['timezone'])) {
$default_timezone = $arguments['timezone'];
}
else {
$default_timezone = 'UTC';
}
if (isset($arguments['timezone_db'])) {
$default_timezone_db = $arguments['timezone_db'];
}
else {
$default_timezone_db = NULL;
}
if (isset($arguments['rrule'])) {
$default_rrule = $arguments['rrule'];
}
else {
$default_rrule = NULL;
}
$language = $this->getFieldLanguage($entity, $field_info, $arguments);
// Setup the standard Field API array for saving.
$delta = 0;
foreach ($values as $from) {
// Set defaults.
$to = NULL;
$timezone = $default_timezone;
$timezone_db = $default_timezone_db;
$rrule = $default_rrule;
// Is the value a straight datetime value, or JSON containing a set of
// properties?
if (!empty($from) && $from{0} == '{') {
$properties = drupal_json_decode($from);
$from = $properties['from'];
// Properties passed in with the date override any set via arguments.
if (!empty($properties['to'])) {
$to = $properties['to'];
}
if (!empty($properties['timezone'])) {
$timezone = $properties['timezone'];
}
if (!empty($properties['timezone_db'])) {
$timezone_db = $properties['timezone_db'];
}
if (!empty($properties['rrule'])) {
$rrule = $properties['rrule'];
}
}
// Missing data? Create an empty value and return;
// Don't try to turn the empty value into a bogus
// timestamp for 'now'.
if (empty($from)) {
$return[$language][$delta]['value'] = NULL;
if (!empty($field_info['settings']['todate'])) {
$return[$language][$delta]['value2'] = NULL;
}
return $return;
}
// If there is no 'to' date, just use the 'from' date.
if (!empty($field_info['settings']['todate']) && empty($to)) {
$to = $from;
}
// If we have a value, work from a timestamp.
$from = MigrationBase::timestamp($from);
if ($to) {
$to = MigrationBase::timestamp($to);
}
// What does the destination field expect?
switch ($field_info['type']) {
case 'datestamp':
// Already done.
break;
case 'datetime':
// YYYY-MM-DD HH:MM:SS.
$from = format_date($from, 'custom', 'Y-m-d H:i:s', $timezone);
if ($to) {
$to = format_date($to, 'custom', 'Y-m-d H:i:s', $timezone);
}
break;
case 'date':
// ISO date: YYYY-MM-DDTHH:MM:SS.
$from = format_date($from, 'custom', 'Y-m-d\TH:i:s', $timezone);
if ($to) {
$to = format_date($to, 'custom', 'Y-m-d\TH:i:s', $timezone);
}
break;
default:
break;
}
// Handle repeats, coming in as RRULEs. Many field instances may be
// created.
if (function_exists('date_repeat_build_dates') && !empty($field_info['settings']['repeat']) && $rrule) {
include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc';
$item = array('value' => $from, 'value2' => $to, 'timezone' => $timezone);
// Can be de-uglified when http://drupal.org/node/1159404 is committed.
$return[$language] = date_repeat_build_dates(NULL, date_ical_parse_rrule($field_info, $rrule), $field_info, $item);
}
else {
$return[$language][$delta]['value'] = $from;
if (!empty($to)) {
$return[$language][$delta]['value2'] = $to;
}
}
$delta++;
}
if (!isset($return)) {
$return = NULL;
}
return $return;
}
}

View File

@@ -1,16 +1,12 @@
name = Date Migration
description = Provides support for importing into date fields with the Migrate module.
description = Obsolete data migration module. Disable if no other modules depend on it.
core = 7.x
package = Date/Time
hidden = TRUE
dependencies[] = migrate
dependencies[] = date
files[] = date.migrate.inc
files[] = date_migrate.test
; Information added by drupal.org packaging script on 2012-09-30
version = "7.x-2.6+2-dev"
; Information added by Drupal.org packaging script on 2014-07-29
version = "7.x-2.8"
core = "7.x"
project = "date"
datestamp = "1348964349"
datestamp = "1406653438"

View File

@@ -2,15 +2,5 @@
/**
* @file
* Migration integration for Date Migrate.
* Obsolete migration integration for Date - now in Date itself.
*/
/**
* Implements hook_migrate_api().
*/
function date_migrate_migrate_api() {
$api = array(
'api' => 2,
);
return $api;
}

View File

@@ -1,70 +0,0 @@
<?php
/**
* @file
* Test for using date fields with Migrate module.
*/
/**
* Test date migration.
*/
class DateMigrateExampleUnitTest extends DrupalWebTestCase {
/**
* Provides information about this test.
*/
public static function getInfo() {
return array(
'name' => 'Date2 migration',
'description' => 'Testing migration of date fields',
'group' => 'Migrate',
);
}
/**
* Declars the module dependencies for the test.
*/
function setUp() {
parent::setUp('migrate', 'features', 'date', 'date_repeat', 'date_repeat_field', 'date_migrate_example');
}
/**
* Verify that date fields are imported correctly. When no timezone is
* explicitly provided with the source data, we want the displayed time on the
* Drupal site to match that in the source data. To validate that, we make
* sure we have set a consistent timezone at the PHP and Drupal levels, and
* that the format used on the page is not locale-dependent (no day or month
* names). Then, we can just look for the desired date/time strings in the
* node page.
*/
function testDateImport() {
date_default_timezone_set('America/Los_Angeles');
variable_set('date_default_timezone', 'America/Los_Angeles');
variable_set('date_format_medium', 'Y-m-d H:i');
$migration = Migration::getInstance('DateExample');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED, t('Variety term import returned RESULT_COMPLETED'));
$rawnodes = node_load_multiple(FALSE, array('type' => 'date_migrate_example'), TRUE);
$this->assertEqual(count($rawnodes), 2, t('Two sample nodes created'));
$node = reset($rawnodes);
$this->drupalGet('/node/' . $node->nid);
$this->assertText('2011-05-12 19:43', t('Simple date field found'));
$this->assertText('2011-06-13 18:32 to 2011-07-23 10:32', t('Date range field found'));
$this->assertText('2011-07-22 12:13', t('Datestamp field found'));
$this->assertText('2011-08-01 00:00 to 2011-09-01 00:00', t('Datestamp range field found'));
$this->assertText('2011-11-18 15:00', t('Datetime field with +9 timezone found'));
$this->assertText('2011-10-30 14:43 to 2011-12-31 17:59', t('Datetime range field with -5 timezone found'));
$this->assertText('2011-11-25 09:01', t('First date repeat instance found'));
$this->assertText('2011-12-09 09:01', t('Second date repeat instance found'));
$this->assertNoText('2011-12-23 09:01', t('Skipped date repeat instance not found'));
$this->assertText('2012-05-11 09:01', t('Last date repeat instance found'));
$node = next($rawnodes);
$this->drupalGet('/node/' . $node->nid);
$this->assertText('2012-06-21 15:32', t('First date value found'));
$this->assertText('2012-12-02 11:08', t('Second date value found'));
$this->assertText('2004-02-03 01:15', t('Start for first date range found'));
$this->assertText('2005-03-04 22:11', t('End for first date range found'));
$this->assertText('2014-09-01 17:21', t('Start for second date range found'));
$this->assertText('2015-12-23 00:01', t('End for first second range found'));
}
}

View File

@@ -2,7 +2,6 @@ core = "7.x"
dependencies[] = "date"
dependencies[] = "date_repeat"
dependencies[] = "date_repeat_field"
dependencies[] = "date_migrate"
dependencies[] = "features"
dependencies[] = "migrate"
description = "Examples of migrating with the Date module"
@@ -21,9 +20,9 @@ package = "Features"
project = "date_migrate_example"
version = "7.x-2.0"
; Information added by drupal.org packaging script on 2012-09-30
version = "7.x-2.6+2-dev"
; Information added by Drupal.org packaging script on 2014-07-29
version = "7.x-2.8"
core = "7.x"
project = "date"
datestamp = "1348964349"
datestamp = "1406653438"

View File

@@ -12,3 +12,12 @@ function date_migrate_example_disable() {
Migration::deregisterMigration('DateExample');
}
/**
* Implements hook_uninstall().
*/
function date_migrate_example_uninstall() {
node_type_delete('date_migrate_example');
variable_del('node_preview_date_migrate_example');
node_types_rebuild();
menu_rebuild();
}

View File

@@ -66,28 +66,34 @@ class DateExampleMigration extends XMLMigration {
// For date ranges, we add the "end" value in prepareRow() below.
$this->addFieldMapping('field_date_range', 'date_range_from');
$this->addFieldMapping('field_date_range:to', 'date_range_to');
// RRULEs on repeat fields are also done in prepareRow().
$this->addFieldMapping('field_date_repeat', 'date_repeat');
$this->addFieldMapping('field_date_repeat:rrule', 'date_repeat_rrule');
$this->addFieldMapping('field_datestamp', 'datestamp')
->xpath('datestamp');
$this->addFieldMapping('field_datestamp_range', 'datestamp_range_from');
$this->addFieldMapping('field_datestamp_range:to', 'datestamp_range_to');
// You can specify a timezone to be applied to all values going into the
// field (Tokyo is UTC+9, no DST)
$arguments = DateMigrateFieldHandler::arguments('Asia/Tokyo');
$this->addFieldMapping('field_datetime', 'datetime')
->xpath('datetime')
->arguments($arguments);
->xpath('datetime');
$this->addFieldMapping('field_datetime:timezone')
->defaultValue('Asia/Tokyo');
// You can also get the timezone from the source data - it can be different
// for each instance of the field. Like To and RRULE values, it is added
// in prepareRow().
$this->addFieldMapping('field_datetime_range', 'datetime_range_from');
$this->addFieldMapping('field_datetime_range:to', 'datetime_range_to');
$this->addFieldMapping('field_datetime_range:timezone', 'datetime_range_timezone');
// Unmapped destination fields.
$this->addUnmigratedDestinations(array('is_new', 'status', 'promote', 'revision', 'language', 'sticky', 'created', 'changed', 'revision_uid'));
$this->addUnmigratedDestinations(array('is_new', 'status', 'promote',
'revision', 'language', 'sticky', 'created', 'changed', 'revision_uid'));
}
/**
@@ -101,30 +107,25 @@ class DateExampleMigration extends XMLMigration {
// The date range field can have multiple values.
$current_row->date_range_from = array();
foreach ($current_row->xml->date_range as $range) {
$date_data = array(
'from' => (string) $range->from[0],
'to' => (string) $range->to[0],
);
$current_row->date_range_from[] = drupal_json_encode($date_data);
$current_row->date_range_from[] = (string)$range->from[0];
$current_row->date_range_to[] = (string)$range->to[0];
}
$date_data = array(
'from' => (string) $current_row->xml->datestamp_range->from[0],
'to' => (string) $current_row->xml->datestamp_range->to[0],
);
$current_row->datestamp_range_from = drupal_json_encode($date_data);
$current_row->datestamp_range_from =
(string) $current_row->xml->datestamp_range->from[0];
$current_row->datestamp_range_to =
(string) $current_row->xml->datestamp_range->to[0];
$date_data = array(
'from' => (string) $current_row->xml->datetime_range->from[0],
'to' => (string) $current_row->xml->datetime_range->to[0],
'timezone' => (string) $current_row->xml->datetime_range->timezone[0],
);
$current_row->datetime_range_from = drupal_json_encode($date_data);
$current_row->datetime_range_from =
(string) $current_row->xml->datetime_range->from[0];
$current_row->datetime_range_to =
(string) $current_row->xml->datetime_range->to[0];
$current_row->datetime_range_timezone =
(string) $current_row->xml->datetime_range->timezone[0];
$date_data = array(
'from' => (string) $current_row->xml->date_repeat->date[0],
'rrule' => (string) $current_row->xml->date_repeat->rule[0],
);
$current_row->date_repeat = drupal_json_encode($date_data);
$current_row->date_repeat =
(string) $current_row->xml->date_repeat->date[0];
$current_row->date_repeat_rrule =
(string) $current_row->xml->date_repeat->rule[0];
}
}

View File

@@ -13,6 +13,9 @@ include_once 'date_migrate_example.features.inc';
function date_migrate_example_migrate_api() {
$api = array(
'api' => 2,
'migrations' => array(
'DateExample' => array('class_name' => 'DateExampleMigration')
),
);
return $api;
}