Commit 39c3361d authored by catch's avatar catch

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

parent b1ad4a8d
......@@ -218,6 +218,11 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) {
if ($this->isStarted()) {
$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());
......@@ -230,10 +235,7 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) {
$this->migrateStoredSession($old_session_id);
}
if (!$this->isStarted()) {
// Start the session when it doesn't exist yet.
$this->startNow();
}
$this->startNow();
}
/**
......
......@@ -2,6 +2,7 @@
namespace Drupal\Core\TempStore;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\Session\AccountProxyInterface;
......@@ -27,6 +28,7 @@
* \Drupal\Core\TempStore\SharedTempStore.
*/
class PrivateTempStore {
use DependencySerializationTrait;
/**
* The key/value storage object used for this data.
......
......@@ -895,13 +895,13 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL
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())]));
$files[$i] = FALSE;
continue;
continue 2;
case UPLOAD_ERR_PARTIAL:
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()]));
$files[$i] = FALSE;
continue;
continue 2;
case UPLOAD_ERR_OK:
// 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
default:
\Drupal::messenger()->addError(t('The file %file could not be saved. An unknown error has occurred.', ['%file' => $file_info->getFilename()]));
$files[$i] = FALSE;
continue;
continue 2;
}
// Begin building file entity.
......
......@@ -208,7 +208,14 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids)
$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;
}
......
......@@ -855,6 +855,7 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas
$attributes = $testcase->attributes();
$function = $attributes->class . '->' . $attributes->name . '()';
$record = [
'test_id' => $test_id,
'test_class' => (string) $attributes->class,
......@@ -862,9 +863,11 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas
'message' => $message,
// @todo: Check on the proper values for this.
'message_group' => 'Other',
'function' => $attributes->class . '->' . $attributes->name . '()',
'function' => $function,
'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;
}
......@@ -40,7 +40,7 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c
// Allow to skip entire config files.
if ($skipped_config[$config_name] === TRUE) {
continue;
break;
}
// Allow to skip some specific lines of imported config files.
......@@ -71,12 +71,12 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c
case 'Drupal\Component\Diff\Engine\DiffOpAdd':
// The _core property does not exist in the default config.
if ($op->closing[0] === '_core:') {
continue;
break;
}
foreach ($op->closing as $closing) {
// The UUIDs don't exist in the default config.
if (strpos($closing, 'uuid: ') === 0) {
continue;
break;
}
throw new \Exception($config_name . ': ' . var_export($op, TRUE));
}
......
......@@ -138,8 +138,11 @@ protected function setUp() {
}
foreach (array_reverse(str_split(decbin($i))) as $key => $bit) {
if ($bit) {
list($field_name, $langcode, $values) = $units[$key];
$entity->getTranslation($langcode)->{$field_name}[] = $values;
// @todo https://www.drupal.org/project/drupal/issues/3001920 Doing
// 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();
......
......@@ -676,7 +676,7 @@ protected function drupalGetHeader($name) {
* The JSON decoded drupalSettings value from the current page.
*/
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)) {
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