Unverified Commit 19c4f189 authored by alexpott's avatar alexpott
Browse files

Issue #3157895 by dww, andypost, alexpott: Move 'install_time' state update...

Issue #3157895 by dww, andypost, alexpott: Move 'install_time' state update from \Drupal\Core\Installer\Form\SiteConfigureForm to installed_finished()
parent f669278e
......@@ -1865,6 +1865,9 @@ function install_finished(&$install_state) {
'@drupal' => drupal_install_profile_distribution_name(),
]);
\Drupal::messenger()->addStatus($success_message);
// Record when this install ran.
\Drupal::state()->set('install_time', $_SERVER['REQUEST_TIME']);
}
/**
......
......@@ -2,12 +2,12 @@
namespace Drupal\Core\Installer\Form;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Locale\CountryManagerInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\State\StateInterface;
use Drupal\user\UserStorageInterface;
use Drupal\user\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -19,6 +19,8 @@
*/
class SiteConfigureForm extends ConfigFormBase {
use DeprecatedServicePropertyTrait;
/**
* The site path.
*
......@@ -34,11 +36,9 @@ class SiteConfigureForm extends ConfigFormBase {
protected $userStorage;
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
* {@inheritdoc}
*/
protected $state;
protected $deprecatedProperties = ['state' => 'state'];
/**
* The module installer.
......@@ -64,24 +64,43 @@ class SiteConfigureForm extends ConfigFormBase {
/**
* Constructs a new SiteConfigureForm.
*
* Note, for BC reasons, we cannot typehint the last 2 parameters since this
* function used to take 6 arguments, including the 'state' service as the
* fourth parameter.
*
* @todo Clean this up in drupal:10.0.0.
* @see https://www.drupal.org/node/3159456
*
* @param string $root
* The app root.
* @param string $site_path
* The site path.
* @param \Drupal\user\UserStorageInterface $user_storage
* The user storage.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
* @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer
* The module installer.
* @param \Drupal\Core\Locale\CountryManagerInterface $country_manager
* The country manager.
*
* @throws \InvalidArgumentException
* Thrown when either the $module_installer or $country_manager parameters
* are not of the correct type.
*/
public function __construct($root, $site_path, UserStorageInterface $user_storage, StateInterface $state, ModuleInstallerInterface $module_installer, CountryManagerInterface $country_manager) {
public function __construct($root, $site_path, UserStorageInterface $user_storage, $module_installer, $country_manager) {
$this->root = $root;
$this->sitePath = $site_path;
$this->userStorage = $user_storage;
$this->state = $state;
if (!$module_installer instanceof ModuleInstallerInterface) {
@trigger_error('Passing the state service to ' . __METHOD__ . '() is deprecated in drupal:9.1.0 and will be removed before drupal:10.0.0. Only pass five parameters instead. See https://www.drupal.org/node/3158440', E_USER_DEPRECATED);
$module_installer = $country_manager;
$country_manager = @func_get_arg(5);
}
if (!$module_installer instanceof ModuleInstallerInterface) {
throw new \InvalidArgumentException('The fourth argument must implement \Drupal\Core\Extension\ModuleInstallerInterface.');
}
if (!$country_manager instanceof CountryManagerInterface) {
throw new \InvalidArgumentException('The fifth argument must implement \Drupal\Core\Locale\CountryManager.');
}
$this->moduleInstaller = $module_installer;
$this->countryManager = $country_manager;
}
......@@ -94,7 +113,6 @@ public static function create(ContainerInterface $container) {
$container->getParameter('app.root'),
$container->getParameter('site.path'),
$container->get('entity_type.manager')->getStorage('user'),
$container->get('state'),
$container->get('module_installer'),
$container->get('country_manager')
);
......@@ -313,9 +331,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$account->pass = $account_values['pass'];
$account->name = $account_values['name'];
$account->save();
// Record when this install ran.
$this->state->set('install_time', $_SERVER['REQUEST_TIME']);
}
}
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