Unverified Commit 5d17da1f authored by catch's avatar catch Committed by larowlan

Issue #2989734 by alexpott, andypost, mikelutz, tacituseu: PHP 7.3 compatibility

(cherry picked from commit 39c3361d)
parent 1af77f31
...@@ -218,6 +218,11 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) { ...@@ -218,6 +218,11 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) {
if ($this->isStarted()) { if ($this->isStarted()) {
$old_session_id = $this->getId(); $old_session_id = $this->getId();
// Save and close the old session. Call the parent method to avoid issue
// with session destruction due to the session being considered obsolete.
parent::save();
// Ensure the session is reloaded correctly.
$this->startedLazy = TRUE;
} }
session_id(Crypt::randomBytesBase64()); session_id(Crypt::randomBytesBase64());
...@@ -230,10 +235,7 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) { ...@@ -230,10 +235,7 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) {
$this->migrateStoredSession($old_session_id); $this->migrateStoredSession($old_session_id);
} }
if (!$this->isStarted()) { $this->startNow();
// Start the session when it doesn't exist yet.
$this->startNow();
}
} }
/** /**
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Core\TempStore; namespace Drupal\Core\TempStore;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Session\AccountProxyInterface;
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
* \Drupal\Core\TempStore\SharedTempStore. * \Drupal\Core\TempStore\SharedTempStore.
*/ */
class PrivateTempStore { class PrivateTempStore {
use DependencySerializationTrait;
/** /**
* The key/value storage object used for this data. * The key/value storage object used for this data.
......
...@@ -895,13 +895,13 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL ...@@ -895,13 +895,13 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL
case UPLOAD_ERR_FORM_SIZE: case UPLOAD_ERR_FORM_SIZE:
\Drupal::messenger()->addError(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', ['%file' => $file_info->getFilename(), '%maxsize' => format_size(file_upload_max_size())])); \Drupal::messenger()->addError(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', ['%file' => $file_info->getFilename(), '%maxsize' => format_size(file_upload_max_size())]));
$files[$i] = FALSE; $files[$i] = FALSE;
continue; continue 2;
case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE: case UPLOAD_ERR_NO_FILE:
\Drupal::messenger()->addError(t('The file %file could not be saved because the upload did not complete.', ['%file' => $file_info->getFilename()])); \Drupal::messenger()->addError(t('The file %file could not be saved because the upload did not complete.', ['%file' => $file_info->getFilename()]));
$files[$i] = FALSE; $files[$i] = FALSE;
continue; continue 2;
case UPLOAD_ERR_OK: case UPLOAD_ERR_OK:
// Final check that this is a valid upload, if it isn't, use the // Final check that this is a valid upload, if it isn't, use the
...@@ -914,7 +914,7 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL ...@@ -914,7 +914,7 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL
default: default:
\Drupal::messenger()->addError(t('The file %file could not be saved. An unknown error has occurred.', ['%file' => $file_info->getFilename()])); \Drupal::messenger()->addError(t('The file %file could not be saved. An unknown error has occurred.', ['%file' => $file_info->getFilename()]));
$files[$i] = FALSE; $files[$i] = FALSE;
continue; continue 2;
} }
// Begin building file entity. // Begin building file entity.
......
...@@ -208,7 +208,14 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids) ...@@ -208,7 +208,14 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids)
$migration->set('requirements', $required_dependency_graph[$migration_id]['paths']); $migration->set('requirements', $required_dependency_graph[$migration_id]['paths']);
} }
} }
array_multisort($weights, SORT_DESC, SORT_NUMERIC, $migrations); // Sort weights, labels, and keys in the same order as each other.
array_multisort(
// Use the numerical weight as the primary sort.
$weights, SORT_DESC, SORT_NUMERIC,
// When migrations have the same weight, sort them alphabetically by ID.
array_keys($migrations), SORT_ASC, SORT_NATURAL,
$migrations
);
return $migrations; return $migrations;
} }
......
...@@ -855,6 +855,7 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas ...@@ -855,6 +855,7 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas
$attributes = $testcase->attributes(); $attributes = $testcase->attributes();
$function = $attributes->class . '->' . $attributes->name . '()';
$record = [ $record = [
'test_id' => $test_id, 'test_id' => $test_id,
'test_class' => (string) $attributes->class, 'test_class' => (string) $attributes->class,
...@@ -862,9 +863,11 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas ...@@ -862,9 +863,11 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas
'message' => $message, 'message' => $message,
// @todo: Check on the proper values for this. // @todo: Check on the proper values for this.
'message_group' => 'Other', 'message_group' => 'Other',
'function' => $attributes->class . '->' . $attributes->name . '()', 'function' => $function,
'line' => $attributes->line ?: 0, 'line' => $attributes->line ?: 0,
'file' => $attributes->file, // There are situations when the file will not be present because a PHPUnit
// @requires has caused a test to be skipped.
'file' => $attributes->file ?: $function,
]; ];
return $record; return $record;
} }
...@@ -40,7 +40,7 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c ...@@ -40,7 +40,7 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c
// Allow to skip entire config files. // Allow to skip entire config files.
if ($skipped_config[$config_name] === TRUE) { if ($skipped_config[$config_name] === TRUE) {
continue; break;
} }
// Allow to skip some specific lines of imported config files. // Allow to skip some specific lines of imported config files.
...@@ -71,12 +71,12 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c ...@@ -71,12 +71,12 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c
case 'Drupal\Component\Diff\Engine\DiffOpAdd': case 'Drupal\Component\Diff\Engine\DiffOpAdd':
// The _core property does not exist in the default config. // The _core property does not exist in the default config.
if ($op->closing[0] === '_core:') { if ($op->closing[0] === '_core:') {
continue; break;
} }
foreach ($op->closing as $closing) { foreach ($op->closing as $closing) {
// The UUIDs don't exist in the default config. // The UUIDs don't exist in the default config.
if (strpos($closing, 'uuid: ') === 0) { if (strpos($closing, 'uuid: ') === 0) {
continue; break;
} }
throw new \Exception($config_name . ': ' . var_export($op, TRUE)); throw new \Exception($config_name . ': ' . var_export($op, TRUE));
} }
......
...@@ -138,8 +138,11 @@ protected function setUp() { ...@@ -138,8 +138,11 @@ protected function setUp() {
} }
foreach (array_reverse(str_split(decbin($i))) as $key => $bit) { foreach (array_reverse(str_split(decbin($i))) as $key => $bit) {
if ($bit) { if ($bit) {
list($field_name, $langcode, $values) = $units[$key]; // @todo https://www.drupal.org/project/drupal/issues/3001920 Doing
$entity->getTranslation($langcode)->{$field_name}[] = $values; // list($field_name, $langcode, $values) = $units[$key]; causes
// problems in PHP 7.3. Revert to better variable names once
// https://bugs.php.net/bug.php?id=76937 is fixed.
$entity->getTranslation($units[$key][1])->{$units[$key][0]}[] = $units[$key][2];
} }
} }
$entity->save(); $entity->save();
......
...@@ -676,7 +676,7 @@ protected function drupalGetHeader($name) { ...@@ -676,7 +676,7 @@ protected function drupalGetHeader($name) {
* The JSON decoded drupalSettings value from the current page. * The JSON decoded drupalSettings value from the current page.
*/ */
protected function getDrupalSettings() { protected function getDrupalSettings() {
$html = $this->getSession()->getPage()->getHtml(); $html = $this->getSession()->getPage()->getContent();
if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $html, $matches)) { if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $html, $matches)) {
return Json::decode($matches[1]); return Json::decode($matches[1]);
} }
......
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