Skip to content
Snippets Groups Projects
Commit f243a856 authored by Jakob P's avatar Jakob P
Browse files

Issue #2992362 by thalles, Daniel Korte, sagannotcarl, baikho, osman, japerry,...

Issue #2992362 by thalles, Daniel Korte, sagannotcarl, baikho, osman, japerry, stevekeiretsu: Wizards should be using PrivateTempStore not SharedTempStore, otherwise all users end up sharing the same cached form values
parent 78788f48
Branches 9.1.x
No related tags found
3 merge requests!61Drupal 11 Compatibility.,!50Issue #3392754: Warning: Undefined array key "value" in Drupal\ctools_views\Plugin\Display\Block->preBlockBuild(),!46Issue #3348486: Ctools_Views not Drupal 10/php 8.2 compatible?
......@@ -24,7 +24,7 @@ class WizardFormController extends FormController {
/**
* Tempstore Factory for keeping track of values in each step of the wizard.
*
* @var \Drupal\Core\TempStore\SharedTempStoreFactory
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
*/
protected $tempstore;
......
......@@ -9,7 +9,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\ctools\Event\WizardEvent;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
......@@ -25,7 +25,7 @@ abstract class EntityFormWizardBase extends FormWizardBase implements EntityForm
protected $entityTypeManager;
/**
* @param \Drupal\Core\TempStore\SharedTempStoreFactory $tempstore
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $tempstore
* Tempstore Factory for keeping track of values in each step of the
* wizard.
* @param \Drupal\Core\Form\FormBuilderInterface $builder
......@@ -36,16 +36,19 @@ abstract class EntityFormWizardBase extends FormWizardBase implements EntityForm
* The event dispatcher.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match object.
* @param $tempstore_id
* The shared temp store factory collection name.
* The private temp store factory collection name.
* @param null $machine_name
* The SharedTempStore key for our current wizard values.
* The PrivateTempStore key for our current wizard values.
* @param null $step
* The current active step of the wizard.
*/
public function __construct(SharedTempStoreFactory $tempstore, FormBuilderInterface $builder, ClassResolverInterface $class_resolver, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $route_match, RendererInterface $renderer, $tempstore_id, EntityTypeManagerInterface $entity_type_manager, $machine_name = NULL, $step = NULL) {
parent::__construct($tempstore, $builder, $class_resolver, $event_dispatcher, $route_match, $renderer, $tempstore_id, $machine_name, $step);
public function __construct(PrivateTempStoreFactory $tempstore, FormBuilderInterface $builder, ClassResolverInterface $class_resolver, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $route_match, RendererInterface $renderer, $tempstore_id, EntityTypeManagerInterface $entity_type_manager, $machine_name = NULL, $step = NULL) {
$this->entityTypeManager = $entity_type_manager;
parent::__construct($tempstore, $builder, $class_resolver, $event_dispatcher, $route_match, $renderer, $tempstore_id, $machine_name, $step);
}
/**
......@@ -53,7 +56,7 @@ abstract class EntityFormWizardBase extends FormWizardBase implements EntityForm
*/
public static function getParameters() {
$parameters = [
'tempstore' => \Drupal::service('tempstore.shared'),
'tempstore' => \Drupal::service('tempstore.private'),
'builder' => \Drupal::service('form_builder'),
'class_resolver' => \Drupal::service('class_resolver'),
'event_dispatcher' => \Drupal::service('event_dispatcher'),
......
......@@ -11,10 +11,10 @@ use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Drupal\Core\Url;
use Drupal\ctools\Ajax\OpenModalWizardCommand;
use Drupal\ctools\Event\WizardEvent;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -26,7 +26,7 @@ abstract class FormWizardBase extends FormBase implements FormWizardInterface {
/**
* Tempstore Factory for keeping track of values in each step of the wizard.
*
* @var \Drupal\Core\TempStore\SharedTempStoreFactory
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
*/
protected $tempstore;
......@@ -52,14 +52,14 @@ abstract class FormWizardBase extends FormBase implements FormWizardInterface {
protected $dispatcher;
/**
* The shared temp store factory collection name.
* The private temp store factory collection name.
*
* @var string
*/
protected $tempstore_id;
/**
* The SharedTempStore key for our current wizard values.
* The PrivateTempStore key for our current wizard values.
*
* @var string|null
*/
......@@ -80,7 +80,7 @@ abstract class FormWizardBase extends FormBase implements FormWizardInterface {
protected $renderer;
/**
* @param \Drupal\Core\TempStore\SharedTempStoreFactory $tempstore
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $tempstore
* Tempstore Factory for keeping track of values in each step of the
* wizard.
* @param \Drupal\Core\Form\FormBuilderInterface $builder
......@@ -90,13 +90,13 @@ abstract class FormWizardBase extends FormBase implements FormWizardInterface {
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
* @param $tempstore_id
* The shared temp store factory collection name.
* The private temp store factory collection name.
* @param null $machine_name
* The SharedTempStore key for our current wizard values.
* The PrivateTempStore key for our current wizard values.
* @param null $step
* The current active step of the wizard.
*/
public function __construct(SharedTempStoreFactory $tempstore, FormBuilderInterface $builder, ClassResolverInterface $class_resolver, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $route_match, RendererInterface $renderer, $tempstore_id, $machine_name = NULL, $step = NULL) {
public function __construct(PrivateTempStoreFactory $tempstore, FormBuilderInterface $builder, ClassResolverInterface $class_resolver, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $route_match, RendererInterface $renderer, $tempstore_id, $machine_name = NULL, $step = NULL) {
$this->tempstore = $tempstore;
$this->builder = $builder;
$this->classResolver = $class_resolver;
......@@ -113,7 +113,7 @@ abstract class FormWizardBase extends FormBase implements FormWizardInterface {
*/
public static function getParameters() {
return [
'tempstore' => \Drupal::service('tempstore.shared'),
'tempstore' => \Drupal::service('tempstore.private'),
'builder' => \Drupal::service('form_builder'),
'class_resolver' => \Drupal::service('class_resolver'),
'event_dispatcher' => \Drupal::service('event_dispatcher'),
......
......@@ -30,21 +30,21 @@ interface FormWizardInterface extends FormInterface {
public function initValues();
/**
* The shared temp store factory collection name.
* The private temp store factory collection name.
*
* @return string
*/
public function getTempstoreId();
/**
* The active SharedTempStore for this wizard.
* The active PrivateTempStore for this wizard.
*
* @return \Drupal\Core\TempStore\SharedTempStore
* @return \Drupal\Core\TempStore\PrivateTempStore
*/
public function getTempstore();
/**
* The SharedTempStore key for our current wizard values.
* The PrivateTempStore key for our current wizard values.
*
* @return null|string
*/
......
......@@ -4,7 +4,7 @@ namespace Drupal\ctools_wizard_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -15,17 +15,17 @@ class ExampleConfigEntityExternalForm extends FormBase {
/**
* Tempstore factory.
*
* @var \Drupal\Core\TempStore\SharedTempStoreFactory
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
*/
protected $tempstore;
/**
* Constructs a new ExampleConfigEntityExternalForm.
*
* @param \Drupal\ctools_wizard_test\Form\SharedTempStoreFactory $tempstore
* Creates a shared temporary storage for a collection.
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $tempstore
* Creates a private temporary storage for a collection.
*/
public function __construct(SharedTempStoreFactory $tempstore) {
public function __construct(PrivateTempStoreFactory $tempstore) {
$this->tempstore = $tempstore;
}
......@@ -33,7 +33,7 @@ class ExampleConfigEntityExternalForm extends FormBase {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('tempstore.shared'));
return new static($container->get('tempstore.private'));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment