Commit ff301288 authored by Dries's avatar Dries
Browse files

- Patch #348448 by mfb, c960657, marvil07, cdale, jpmckinney: fixed PHP strict...

- Patch #348448 by mfb, c960657, marvil07, cdale, jpmckinney: fixed PHP strict warnings when running tests and for PHP 5.3.
parent de33f74b
......@@ -38,6 +38,8 @@ DirectoryIndex index.php index.html index.htm
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
# Report all PHP errors, including compile-time errors.
php_value error_reporting -1
</IfModule>
# Requires mod_expires to be enabled.
......
......@@ -84,6 +84,8 @@ Drupal 7.0, xxxx-xx-xx (development version)
* If your site is being upgraded from Drupal 6 and you do not have the
contributed date or event modules installed, user time zone settings will
fallback to the system time zone and will have to be reconfigured by each user.
* User-configured time zones now serve as the default time zone for PHP
date/time functions.
- Filter system:
* Revamped the filter API and text format storage.
* Added support for default text formats to be assigned on a per-role basis.
......
......@@ -1816,6 +1816,21 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
return $stored_phase;
}
/**
* Return the time zone of the current user.
*/
function drupal_get_user_timezone() {
global $user;
if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
return $user->timezone;
}
else {
// Ignore PHP strict notice if time zone has not yet been set in the php.ini
// configuration.
return variable_get('date_default_timezone', @date_default_timezone_get());
}
}
/**
* Custom PHP error handler.
*
......@@ -1910,6 +1925,7 @@ function _drupal_bootstrap_page_cache() {
$cache = drupal_page_get_cache();
// If there is a cached page, display it.
if (is_object($cache)) {
date_default_timezone_set(drupal_get_user_timezone());
// If the skipping of the bootstrap hooks is not enforced, call
// hook_boot.
if (variable_get('page_cache_invoke_hooks', TRUE)) {
......
......@@ -1765,13 +1765,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
$timezones = &$drupal_static_fast['timezones'];
if (!isset($timezone)) {
global $user;
if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
$timezone = $user->timezone;
}
else {
$timezone = variable_get('date_default_timezone', 'UTC');
}
$timezone = date_default_timezone_get();
}
// Store DateTimeZone objects in an array rather than repeatedly
// constructing identical objects over the life of a request.
......
......@@ -501,11 +501,11 @@ public function hasTag($tag) {
}
public function hasAllTags() {
return call_user_func_array(array($this->query, 'hasAllTags', func_get_args()));
return call_user_func_array(array($this->query, 'hasAllTags'), func_get_args());
}
public function hasAnyTag() {
return call_user_func_array(array($this->query, 'hasAnyTags', func_get_args()));
return call_user_func_array(array($this->query, 'hasAnyTags'), func_get_args());
}
public function addMetaData($key, $object) {
......
......@@ -201,7 +201,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
// Display the message if the current error reporting level allows this type
// of message to be displayed, and unconditionnaly in update.php.
$error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL);
$display_error = $error_level == ERROR_REPORTING_DISPLAY_ALL || ($error_level == ERROR_REPORTING_DISPLAY_SOME && $error['%type'] != 'Notice');
$display_error = $error_level == ERROR_REPORTING_DISPLAY_ALL || ($error_level == ERROR_REPORTING_DISPLAY_SOME && $error['%type'] != 'Notice' && $error['%type'] != 'Strict warning');
if ($display_error || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) {
$class = 'error';
......
......@@ -24,7 +24,16 @@ function __construct($jail) {
$this->jail = $jail;
}
abstract static function factory($jail, $settings);
/**
* Classes that extend this class must override the factory() static method.
*
* @param string $jail
* @param array $settings
* @return object New instance of the appropriate FileTransfer subclass.
*/
static function factory($jail, $settings) {
throw new FileTransferException('FileTransfer::factory() static method not overridden by FileTransfer subclass.');
}
/**
* Implementation of the magic __get() method.
......
......@@ -1204,7 +1204,8 @@ function install_select_locale(&$install_state) {
}
else {
include_once DRUPAL_ROOT . '/includes/form.inc';
$output = drupal_render(drupal_get_form('install_select_locale_form', $locales, $profilename));
$elements = drupal_get_form('install_select_locale_form', $locales, $profilename);
$output = drupal_render($elements);
}
return $output;
}
......@@ -1237,7 +1238,8 @@ function install_select_locale(&$install_state) {
if ($install_state['interactive']) {
drupal_set_title(st('Choose language'));
include_once DRUPAL_ROOT . '/includes/form.inc';
return drupal_render(drupal_get_form('install_select_locale_form', $locales, $profilename));
$elements = drupal_get_form('install_select_locale_form', $locales, $profilename);
return drupal_render($elements);
}
else {
throw new Exception(st('Sorry, you must select a language to continue the installation.'));
......
......@@ -209,6 +209,7 @@ function drupal_session_initialize() {
$user = drupal_anonymous_user();
session_id(md5(uniqid('', TRUE)));
}
date_default_timezone_set(drupal_get_user_timezone());
}
/**
......@@ -310,6 +311,7 @@ function drupal_session_regenerate() {
->condition('sid', $old_session_id)
->execute();
}
date_default_timezone_set(drupal_get_user_timezone());
}
/**
......
......@@ -745,7 +745,11 @@ function book_children($book_link) {
}
}
return $children ? drupal_render(menu_tree_output($children)) : '';
if ($children) {
$elements = menu_tree_output($children);
return drupal_render($elements);
}
return '';
}
/**
......
......@@ -37,9 +37,8 @@ class ColorTestCase extends DrupalWebTestCase {
$edit['palette[link]'] = '#123456';
$this->drupalPost('admin/appearance/settings/garland', $edit, t('Save configuration'));
global $theme_key;
$this->drupalGet('<front>');
$stylesheets = variable_get('color_' . $theme_key . '_stylesheets', array());
$stylesheets = variable_get('color_garland_stylesheets', array());
$this->assertPattern('|' . file_create_url($stylesheets[0]) . '|', 'Make sure the color stylesheet is included in the content.');
$stylesheet_content = join("\n", file($stylesheets[0]));
......@@ -52,7 +51,7 @@ class ColorTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/appearance/settings/garland', $edit, t('Save configuration'));
$this->drupalGet('<front>');
$stylesheets = variable_get('color_' . $theme_key . '_stylesheets', array());
$stylesheets = variable_get('color_garland_stylesheets', array());
$stylesheet_content = join("\n", file($stylesheets[0]));
$matched = preg_match('/(.*color: #0c7a00.*)/i', $stylesheet_content, $matches);
$this->assertTrue($matched == 1, 'Make sure the color we changed is in the color stylesheet.');
......
......@@ -15,12 +15,13 @@ class FieldTestCase extends DrupalWebTestCase {
/**
* Set the default field storage backend for fields created during tests.
*/
function setUp($modules = array()) {
function setUp() {
// Since this is a base class for many test cases, support the same
// flexibility that DrupalWebTestCase::setUp() has for the modules to be
// passed in as either an array or a variable number of string arguments.
if (!is_array($modules)) {
$modules = func_get_args();
$modules = func_get_args();
if (isset($modules[0]) && is_array($modules[0])) {
$modules = $modules[0];
}
parent::setUp($modules);
// Set default storage backend.
......
......@@ -655,6 +655,7 @@ function template_preprocess_field_ui_display_overview_form(&$vars) {
$row = new stdClass();
foreach (element_children($element) as $child) {
if (array_key_exists('label', $element[$child])) {
$row->{$child} = new stdClass();
$row->{$child}->label = drupal_render($element[$child]['label']);
$row->{$child}->type = drupal_render($element[$child]['type']);
}
......
......@@ -1244,7 +1244,8 @@ alert("test")
$this->assertEqual($f, '&#039;', t('The @function() function correctly filters single quotes.', $replacements));
// Test that the filter is not fooled by different evasion techniques.
$f = $function("\xc2\"");
// Ignore PHP 5.3+ invalid multibyte sequence warning.
$f = @$function("\xc2\"");
$this->assertEqual($f, '', t('The @function() function correctly filters invalid UTF-8.', $replacements));
}
}
......
......@@ -322,7 +322,8 @@ function forum_node_presave($node) {
if (_forum_node_check_node_type($node)) {
// Make sure all fields are set properly:
$node->icon = !empty($node->icon) ? $node->icon : '';
$langcode = array_shift(array_keys($node->taxonomy_forums));
reset($node->taxonomy_forums);
$langcode = key($node->taxonomy_forums);
if (!empty($node->taxonomy_forums[$langcode])) {
$node->forum_tid = $node->taxonomy_forums[$langcode][0]['tid'];
$old_tid = db_query_range("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, array(':nid' => $node->nid))->fetchField();
......
......@@ -248,7 +248,7 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase {
*/
class ImageAdminStylesUnitTest extends DrupalWebTestCase {
function getInfo() {
public static function getInfo() {
return array(
'name' => 'Image styles and effects UI configuration',
'description' => 'Tests creation, deletion, and editing of image styles and effects at the UI level.',
......
......@@ -783,7 +783,8 @@ function locale_translate_seek_screen() {
// Add CSS.
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css', array('preprocess' => FALSE));
$output = drupal_render(drupal_get_form('locale_translation_filter_form'));
$elements = drupal_get_form('locale_translation_filter_form');
$output = drupal_render($elements);
$output .= _locale_translate_seek();
return $output;
}
......@@ -1023,9 +1024,11 @@ function locale_translate_export_screen() {
$output = '';
// Offer translation export if any language is set up.
if (count($names)) {
$output = drupal_render(drupal_get_form('locale_translate_export_po_form', $names));
$elements = drupal_get_form('locale_translate_export_po_form', $names);
$output = drupal_render($elements);
}
$output .= drupal_render(drupal_get_form('locale_translate_export_pot_form'));
$elements = drupal_get_form('locale_translate_export_pot_form');
$output .= drupal_render($elements);
return $output;
}
......@@ -1354,6 +1357,7 @@ function locale_date_format_form($form, &$form_state, $langcode) {
$choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
}
}
reset($formats);
// Get configured formats for each language.
$locale_formats = system_date_format_locale($langcode);
......@@ -1363,7 +1367,7 @@ function locale_date_format_form($form, &$form_state, $langcode) {
$default = $locale_formats[$type];
}
else {
$default = variable_get('date_format_' . $type, array_shift(array_keys($formats)));
$default = variable_get('date_format_' . $type, key($formats));
}
// Show date format select list.
......
......@@ -3600,7 +3600,8 @@ function node_unpublish_by_keyword_action_submit($form, $form_state) {
*/
function node_unpublish_by_keyword_action($node, $context) {
foreach ($context['keywords'] as $keyword) {
if (strpos(drupal_render(node_view(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
$elements = node_view(clone $node);
if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
$node->status = NODE_NOT_PUBLISHED;
watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title));
break;
......
......@@ -355,8 +355,10 @@ function theme_node_preview($variables) {
$preview_trimmed_version = FALSE;
$trimmed = drupal_render(node_view(clone $node, 'teaser'));
$full = drupal_render(node_view($node, 'full'));
$elements = node_view(clone $node, 'teaser');
$trimmed = drupal_render($elements);
$elements = node_view($node, 'full');
$full = drupal_render($elements);
// Do we need to preview trimmed version of post as well as full version?
if ($trimmed != $full) {
......
......@@ -90,7 +90,8 @@ function openid_redirect_http($url, $message) {
*/
function openid_redirect($url, $message) {
$output = '<html><head><title>' . t('OpenID redirect') . "</title></head>\n<body>";
$output .= drupal_render(drupal_get_form('openid_redirect_form', $url, $message));
$elements = drupal_get_form('openid_redirect_form', $url, $message);
$output .= drupal_render($elements);
$output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>';
$output .= "</body></html>\n";
print $output;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment