Skip to content
Snippets Groups Projects
Commit 227325ab authored by Adam G-H's avatar Adam G-H
Browse files

Store stage ID in sess during batch

parent e032a1f0
No related branches found
No related tags found
1 merge request!213Issue #3248928: Redirect or provide link to apply form for user who started update if accessing start form
This commit is part of merge request !213. Comments created here will be created in the context of that merge request.
...@@ -73,8 +73,8 @@ class BatchProcessor { ...@@ -73,8 +73,8 @@ class BatchProcessor {
*/ */
public static function begin(array $project_versions, array &$context): void { public static function begin(array $project_versions, array &$context): void {
try { try {
$stage_unique = static::getUpdater()->begin($project_versions); $stage_id = static::getUpdater()->begin($project_versions);
$context['results']['stage_id'] = $stage_unique; \Drupal::service('session')->set(static::STAGE_ID_SESSION_KEY, $stage_id);
} }
catch (\Throwable $e) { catch (\Throwable $e) {
static::handleException($e, $context); static::handleException($e, $context);
...@@ -91,7 +91,7 @@ class BatchProcessor { ...@@ -91,7 +91,7 @@ class BatchProcessor {
*/ */
public static function stage(array &$context): void { public static function stage(array &$context): void {
try { try {
$stage_id = $context['results']['stage_id']; $stage_id = \Drupal::service('session')->get(static::STAGE_ID_SESSION_KEY);
static::getUpdater()->claim($stage_id)->stage(); static::getUpdater()->claim($stage_id)->stage();
} }
catch (\Throwable $e) { catch (\Throwable $e) {
...@@ -149,8 +149,9 @@ class BatchProcessor { ...@@ -149,8 +149,9 @@ class BatchProcessor {
*/ */
public static function finishStage(bool $success, array $results, array $operations): ?RedirectResponse { public static function finishStage(bool $success, array $results, array $operations): ?RedirectResponse {
if ($success) { if ($success) {
$stage_id = \Drupal::service('session')->get(static::STAGE_ID_SESSION_KEY);
$url = Url::fromRoute('automatic_updates.confirmation_page', [ $url = Url::fromRoute('automatic_updates.confirmation_page', [
'stage_id' => $results['stage_id'], 'stage_id' => $stage_id,
]); ]);
return new RedirectResponse($url->setAbsolute()->toString()); return new RedirectResponse($url->setAbsolute()->toString());
} }
...@@ -169,6 +170,8 @@ class BatchProcessor { ...@@ -169,6 +170,8 @@ class BatchProcessor {
* A list of the operations that had not been completed by the batch API. * A list of the operations that had not been completed by the batch API.
*/ */
public static function finishCommit(bool $success, array $results, array $operations): ?RedirectResponse { public static function finishCommit(bool $success, array $results, array $operations): ?RedirectResponse {
\Drupal::service('session')->remove(static::STAGE_ID_SESSION_KEY);
if ($success) { if ($success) {
$url = Url::fromRoute('automatic_updates.finish') $url = Url::fromRoute('automatic_updates.finish')
->setAbsolute() ->setAbsolute()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment