From fd1bcf754eace5e404ebcf5a57f41dc98388166c Mon Sep 17 00:00:00 2001 From: David Snopek Date: Wed, 13 Feb 2019 15:53:50 -0600 Subject: [PATCH] Apply the changes from D6LTS 6.47 (#125) --- CHANGELOG.txt | 4 ++++ includes/form.inc | 13 +++++++------ includes/theme.inc | 10 +++++----- includes/unicode.inc | 14 +++++++++----- modules/book/book.module | 3 ++- modules/profile/profile.module | 1 + modules/system/system.module | 2 +- 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index caa00daabcd..232868cfab2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,7 @@ +Drupal 6.47 LTS, 2019-01-02 +--------------------------------------- +- Improved support for PHP 7.2. + Drupal 6.46 LTS, 2018-10-17 --------------------------------------- - Fixed security issues (open redirect), backport. See SA-CORE-2018-006. diff --git a/includes/form.inc b/includes/form.inc index be58955e2b4..272c0f5087e 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1424,14 +1424,15 @@ function form_set_value($form_item, $value, &$form_state) { * the right array. */ function _form_set_value(&$form_values, $form_item, $parents, $value) { + // This makes PHP 7 have the same behavior as PHP 5 when the value is an + // empty string, rather than an array. This is depended on surprisingly + // often in Drupal 6 contrib. + if ($form_values === '') { + $form_values = array(); + } + $parent = array_shift($parents); if (empty($parents)) { - // This makes PHP 7 have the same behavior as PHP 5 when the value is an - // empty string, rather than an array. This is depended on surprisingly - // often in Drupal 6 contrib. - if ($form_values === '') { - $form_values = array(); - } $form_values[$parent] = $value; } else { diff --git a/includes/theme.inc b/includes/theme.inc index 0b25f710e54..21e203e36af 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1371,7 +1371,7 @@ function theme_submenu($links) { function theme_table($header, $rows, $attributes = array(), $caption = NULL) { // Add sticky headers, if applicable. - if (count($header)) { + if (!empty($header)) { drupal_add_js('misc/tableheader.js'); // Add 'sticky-enabled' class to the table to identify it for JS. // This is needed to target tables constructed by this function. @@ -1385,24 +1385,24 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { } // Format the table header: - if (count($header)) { + if (!empty($header)) { $ts = tablesort_init($header); // HTML requires that the thead tag has tr tags in it followed by tbody // tags. Using ternary operator to check and see if we have any rows. - $output .= (count($rows) ? ' ' : ' '); + $output .= (!empty($rows) ? ' ' : ' '); foreach ($header as $cell) { $cell = tablesort_header($cell, $header, $ts); $output .= _theme_table_cell($cell, TRUE); } // Using ternary operator to close the tags based on whether or not there are rows - $output .= (count($rows) ? " \n" : "\n"); + $output .= (!empty($rows) ? " \n" : "\n"); } else { $ts = array(); } // Format the table rows: - if (count($rows)) { + if (!empty($rows)) { $output .= "\n"; $flip = array('even' => 'odd', 'odd' => 'even'); $class = 'even'; diff --git a/includes/unicode.inc b/includes/unicode.inc index bf0ae52c93f..b5fe688cf0f 100644 --- a/includes/unicode.inc +++ b/includes/unicode.inc @@ -59,11 +59,15 @@ function _unicode_check() { if (ini_get('mbstring.encoding_translation') != 0) { return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.encoding_translation setting. Please refer to the PHP mbstring documentation for more information.', array('@url' => 'http://www.php.net/mbstring'))); } - if (ini_get('mbstring.http_input') != 'pass') { - return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentation for more information.', array('@url' => 'http://www.php.net/mbstring'))); - } - if (ini_get('mbstring.http_output') != 'pass') { - return array(UNICODE_ERROR, $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_output setting. Please refer to the PHP mbstring documentation for more information.', array('@url' => 'http://www.php.net/mbstring'))); + // mbstring.http_input and mbstring.http_output are deprecated and empty by + // default in PHP 5.6. + if (version_compare(PHP_VERSION, '5.6.0') == -1) { + if (ini_get('mbstring.http_input') != 'pass') { + return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentation for more information.', array('@url' => 'http://www.php.net/mbstring'))); + } + if (ini_get('mbstring.http_output') != 'pass') { + return array(UNICODE_ERROR, $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_output setting. Please refer to the PHP mbstring documentation for more information.', array('@url' => 'http://www.php.net/mbstring'))); + } } // Set appropriate configuration diff --git a/modules/book/book.module b/modules/book/book.module index 56f839a33c6..37d8c06f135 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -556,7 +556,8 @@ function book_prev($book_link) { // The previous page in the book may be a child of the previous visible link. if ($prev['depth'] == $book_link['depth'] && $prev['has_children']) { // The subtree will have only one link at the top level - get its data. - $data = array_shift(book_menu_subtree_data($prev)); + $subtree = book_menu_subtree_data($prev); + $data = array_shift($subtree); // The link of interest is the last child - iterate to find the deepest one. while ($data['below']) { $data = end($data['below']); diff --git a/modules/profile/profile.module b/modules/profile/profile.module index e8c053904b5..e056f68dec7 100644 --- a/modules/profile/profile.module +++ b/modules/profile/profile.module @@ -490,6 +490,7 @@ function template_preprocess_profile_block(&$variables) { // Supply filtered version of $fields that have values. foreach ($variables['fields'] as $field) { if ($field->value) { + $variables['profile'][$field->name] = new stdClass(); $variables['profile'][$field->name]->title = check_plain($field->title); $variables['profile'][$field->name]->value = $field->value; $variables['profile'][$field->name]->type = $field->type; diff --git a/modules/system/system.module b/modules/system/system.module index 51771c9e4a7..6f8561ebacb 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -8,7 +8,7 @@ /** * The current system version. */ -define('VERSION', '6.46'); +define('VERSION', '6.47'); /** * Core API compatibility.