diff --git a/core/lib/Drupal/Core/Session/SessionManager.php b/core/lib/Drupal/Core/Session/SessionManager.php index 8249805..958aff3 100644 --- a/core/lib/Drupal/Core/Session/SessionManager.php +++ b/core/lib/Drupal/Core/Session/SessionManager.php @@ -126,8 +126,8 @@ public function start() { $user = new AnonymousUserSession(); // Randomly generate a session identifier for this request. This is - // necessary because \Drupal\user\TempStoreFactory::get() wants to know - // the future session ID of a lazily started session in advance. + // necessary because \Drupal\user\SharedTempStoreFactory::get() wants to + // know the future session ID of a lazily started session in advance. // // @todo: With current versions of PHP there is little reason to generate // the session id from within application code. Consider using the diff --git a/core/modules/node/node.services.yml b/core/modules/node/node.services.yml index 96b232a..9547490 100644 --- a/core/modules/node/node.services.yml +++ b/core/modules/node/node.services.yml @@ -30,7 +30,7 @@ services: - { name: event_subscriber } node_preview: class: Drupal\node\ParamConverter\NodePreviewConverter - arguments: ['@user.foo_tempstore'] + arguments: ['@user.private_tempstore'] tags: - { name: paramconverter } node.page_cache_request_policy.deny_node_preview: diff --git a/core/modules/node/src/Form/DeleteMultiple.php b/core/modules/node/src/Form/DeleteMultiple.php index 8116db8..abe8db1 100644 --- a/core/modules/node/src/Form/DeleteMultiple.php +++ b/core/modules/node/src/Form/DeleteMultiple.php @@ -12,7 +12,7 @@ use Drupal\Core\Url; use Drupal\Component\Utility\String; use Drupal\Core\Form\FormStateInterface; -use Drupal\user\TempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -31,7 +31,7 @@ class DeleteMultiple extends ConfirmFormBase { /** * The tempstore factory. * - * @var \Drupal\user\TempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; @@ -45,12 +45,12 @@ class DeleteMultiple extends ConfirmFormBase { /** * Constructs a DeleteMultiple form object. * - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. * @param \Drupal\Core\Entity\EntityManagerInterface $manager * The entity manager. */ - public function __construct(TempStoreFactory $temp_store_factory, EntityManagerInterface $manager) { + public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityManagerInterface $manager) { $this->tempStoreFactory = $temp_store_factory; $this->storage = $manager->getStorage('node'); } @@ -60,7 +60,7 @@ public function __construct(TempStoreFactory $temp_store_factory, EntityManagerI */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.tempstore'), + $container->get('user.private_tempstore'), $container->get('entity.manager') ); } diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 8e88166..17066ab 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -12,7 +12,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\user\Entity\User; -use Drupal\user\FooTempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -23,7 +23,7 @@ class NodeForm extends ContentEntityForm { /** * The tempstore factory. * - * @var \Drupal\user\FooTempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; @@ -37,10 +37,10 @@ class NodeForm extends ContentEntityForm { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The factory for the temp store object. */ - public function __construct(EntityManagerInterface $entity_manager, FooTempStoreFactory $temp_store_factory) { + public function __construct(EntityManagerInterface $entity_manager, PrivateTempStoreFactory $temp_store_factory) { parent::__construct($entity_manager); $this->tempStoreFactory = $temp_store_factory; } @@ -51,7 +51,7 @@ public function __construct(EntityManagerInterface $entity_manager, FooTempStore public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), - $container->get('user.foo_tempstore') + $container->get('user.private_tempstore') ); } diff --git a/core/modules/node/src/ParamConverter/NodePreviewConverter.php b/core/modules/node/src/ParamConverter/NodePreviewConverter.php index a3d4d39..6746fae 100644 --- a/core/modules/node/src/ParamConverter/NodePreviewConverter.php +++ b/core/modules/node/src/ParamConverter/NodePreviewConverter.php @@ -8,7 +8,7 @@ namespace Drupal\node\ParamConverter; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\user\FooTempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\Routing\Route; use Drupal\Core\ParamConverter\ParamConverterInterface; @@ -20,17 +20,17 @@ class NodePreviewConverter implements ParamConverterInterface { /** * Stores the tempstore factory. * - * @var \Drupal\user\FooTempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; /** * Constructs a new NodePreviewConverter. * - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The factory for the temp store object. */ - public function __construct(FooTempStoreFactory $temp_store_factory) { + public function __construct(PrivateTempStoreFactory $temp_store_factory) { $this->tempStoreFactory = $temp_store_factory; } diff --git a/core/modules/node/src/Plugin/Action/DeleteNode.php b/core/modules/node/src/Plugin/Action/DeleteNode.php index f01d0d1..d633dc8 100644 --- a/core/modules/node/src/Plugin/Action/DeleteNode.php +++ b/core/modules/node/src/Plugin/Action/DeleteNode.php @@ -10,7 +10,7 @@ use Drupal\Core\Action\ActionBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\user\TempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -28,7 +28,7 @@ class DeleteNode extends ActionBase implements ContainerFactoryPluginInterface { /** * The tempstore object. * - * @var \Drupal\user\TempStore + * @var \Drupal\user\SharedTempStore */ protected $tempStore; @@ -48,12 +48,12 @@ class DeleteNode extends ActionBase implements ContainerFactoryPluginInterface { * The plugin ID for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. * @param AccountInterface $current_user * Current user. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, TempStoreFactory $temp_store_factory, AccountInterface $current_user) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, PrivateTempStoreFactory $temp_store_factory, AccountInterface $current_user) { $this->currentUser = $current_user; $this->tempStore = $temp_store_factory->get('node_multiple_delete_confirm'); @@ -68,7 +68,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('user.tempstore'), + $container->get('user.private_tempstore'), $container->get('current_user') ); } diff --git a/core/modules/quickedit/js/editors/formEditor.js b/core/modules/quickedit/js/editors/formEditor.js index 7660bce..8dc3fb5 100644 --- a/core/modules/quickedit/js/editors/formEditor.js +++ b/core/modules/quickedit/js/editors/formEditor.js @@ -95,12 +95,13 @@ fieldID: fieldModel.get('fieldID'), $el: this.$el, nocssjs: false, - // Reset an existing entry for this entity in the TempStore (if any) when - // loading the field. Logically speaking, this should happen in a separate - // request because this is an entity-level operation, not a field-level - // operation. But that would require an additional request, that might not - // even be necessary: it is only when a user loads a first changed field - // for an entity that this needs to happen: precisely now! + // Reset an existing entry for this entity in the PrivateTempStore (if + // any) when loading the field. Logically speaking, this should happen + // in a separate request because this is an entity-level operation, not + // a field-level operation. But that would require an additional + // request, that might not even be necessary: it is only when a user + // loads a first changed field for an entity that this needs to happen: + // precisely now! reset: !fieldModel.get('entity').get('inTempStore') }; Drupal.quickedit.util.form.load(formOptions, function (form, ajax) { diff --git a/core/modules/quickedit/js/models/EntityModel.js b/core/modules/quickedit/js/models/EntityModel.js index 052ab3a..e850065 100644 --- a/core/modules/quickedit/js/models/EntityModel.js +++ b/core/modules/quickedit/js/models/EntityModel.js @@ -33,22 +33,24 @@ // Indicates whether this instance of this entity is currently being // edited in-place. isActive: false, - // Whether one or more fields have already been stored in TempStore. + // Whether one or more fields have already been stored in + // PrivateTempStore. inTempStore: false, - // Whether one or more fields have already been stored in TempStore *or* - // the field that's currently being edited is in the 'changed' or a later - // state. In other words, this boolean indicates whether a "Save" button is - // necessary or not. + // Whether one or more fields have already been stored in PrivateTempStore + // *or* the field that's currently being edited is in the 'changed' or a + // later state. In other words, this boolean indicates whether a "Save" + // button is necessary or not. isDirty: false, // Whether the request to the server has been made to commit this entity. // Used to prevent multiple such requests. isCommitting: false, // The current processing state of an entity. state: 'closed', - // The IDs of the fields whose new values have been stored in TempStore. We - // must store this on the EntityModel as well (even though it already is on - // the FieldModel) because when a field is rerendered, its FieldModel is - // destroyed and this allows us to transition it back to the proper state. + // The IDs of the fields whose new values have been stored in + // PrivateTempStore. We must store this on the EntityModel as well (even + // though it already is on the FieldModel) because when a field is + // rerendered, its FieldModel is destroyed and this allows us to + // transition it back to the proper state. fieldsInTempStore: [], // A flag the tells the application that this EntityModel must be reloaded // in order to restore the original values to its fields in the client. @@ -118,7 +120,7 @@ fieldModel.set('state', 'candidate'); }); // For fields that are in a changed state, field values must first be - // stored in TempStore. + // stored in PrivateTempStore. fields.chain() .filter(function (fieldModel) { return _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length; @@ -205,16 +207,17 @@ var previous = fieldModel.previous('state'); var fieldsInTempStore = entityModel.get('fieldsInTempStore'); // If the fieldModel changed to the 'saved' state: remember that this - // field was saved to TempStore. + // field was saved to PrivateTempStore. if (current === 'saved') { - // Mark the entity as saved in TempStore, so that we can pass the - // proper "reset TempStore" boolean value when communicating with the - // server. + // Mark the entity as saved in PrivateTempStore, so that we can pass the + // proper "reset PrivateTempStore" boolean value when communicating with + // the server. entityModel.set('inTempStore', true); - // Mark the field as saved in TempStore, so that visual indicators - // signifying just that may be rendered. + // Mark the field as saved in PrivateTempStore, so that visual + // indicators signifying just that may be rendered. fieldModel.set('inTempStore', true); - // Remember that this field is in TempStore, restore when rerendered. + // Remember that this field is in PrivateTempStore, restore when + // rerendered. fieldsInTempStore.push(fieldModel.get('fieldID')); fieldsInTempStore = _.uniq(fieldsInTempStore); entityModel.set('fieldsInTempStore', fieldsInTempStore); @@ -271,11 +274,11 @@ // Set the isDirty attribute when appropriate so that it is known when // to display the "Save" button in the entity toolbar. // Note that once a field has been changed, there's no way to discard - // that change, hence it will have to be saved into TempStore, or the - // in-place editing of this field will have to be stopped completely. - // In other words: once any field enters the 'changed' field, then for - // the remainder of the in-place editing session, the entity is by - // definition dirty. + // that change, hence it will have to be saved into PrivateTempStore, + // or the in-place editing of this field will have to be stopped + // completely. In other words: once any field enters the 'changed' + // field, then for the remainder of the in-place editing session, the + // entity is by definition dirty. if (fieldState === 'changed') { entityModel.set('isDirty', true); } @@ -380,9 +383,9 @@ entitySaverAjax.commands.quickeditEntitySaved = function (ajax, response, status) { // Clean up. $(ajax.element).off('quickedit-save.quickedit'); - // All fields have been moved from TempStore to permanent storage, update - // the "inTempStore" attribute on FieldModels, on the EntityModel and - // clear EntityModel's "fieldInTempStore" attribute. + // All fields have been moved from PrivateTempStore to permanent + // storage, update the "inTempStore" attribute on FieldModels, on the + // EntityModel and clear EntityModel's "fieldInTempStore" attribute. entityModel.get('fields').each(function (fieldModel) { fieldModel.set('inTempStore', false); }); @@ -566,13 +569,14 @@ // User has clicked the 'Save' button (and has thus changed at least one // field). // - Trigger: user. - // - Guarantees: see 'opened', plus: either a changed field is in TempStore, - // or the user has just modified a field without activating (switching to) - // another field. - // - Expected behavior: 1) if any of the fields are not yet in TempStore, - // save them to TempStore, 2) if then any of the fields has the 'invalid' - // state, then change the entity state back to 'opened', otherwise: save - // the entity by committing it from TempStore into permanent storage. + // - Guarantees: see 'opened', plus: either a changed field is in + // PrivateTempStore, or the user has just modified a field without + // activating (switching to) another field. + // - Expected behavior: 1) if any of the fields are not yet in + // PrivateTempStore, save them to PrivateTempStore, 2) if then any of + // the fields has the 'invalid' state, then change the entity state back + // to 'opened', otherwise: save the entity by committing it from + // PrivateTempStore into permanent storage. 'committing', // User has clicked the 'Close' button, or has clicked the 'Save' button and // that was successfully completed. diff --git a/core/modules/quickedit/js/models/FieldModel.js b/core/modules/quickedit/js/models/FieldModel.js index 5737383..6bd4e44 100644 --- a/core/modules/quickedit/js/models/FieldModel.js +++ b/core/modules/quickedit/js/models/FieldModel.js @@ -210,14 +210,15 @@ // - Guarantees: see 'candidate', plus in-place editor is ready for use. // - Expected behavior: visual indicator of change. 'changed', - // User is saving changed field data in in-place editor to TempStore. The - // save mechanism of the in-place editor is called. + // User is saving changed field data in in-place editor to + // PrivateTempStore. The save mechanism of the in-place editor is called. // - Trigger: user. // - Guarantees: see 'candidate' and 'active'. // - Expected behavior: saving indicator, in-place editor is saving field - // data into TempStore. Upon successful saving (without validation - // errors), the in-place editor transitions the field's state to 'saved', - // but to 'invalid' upon failed saving (with validation errors). + // data into PrivateTempStore. Upon successful saving (without + // validation errors), the in-place editor transitions the field's state + // to 'saved', but to 'invalid' upon failed saving (with validation + // errors). 'saving', // In-place editor has successfully saved the changed field. // - Trigger: in-place editor. diff --git a/core/modules/quickedit/js/util.js b/core/modules/quickedit/js/util.js index 3b3aa3a..2f76665 100644 --- a/core/modules/quickedit/js/util.js +++ b/core/modules/quickedit/js/util.js @@ -82,7 +82,7 @@ * - Boolean nocssjs: (required) boolean indicating whether no CSS and JS * should be returned (necessary when the form is invisible to the user). * - Boolean reset: (required) boolean indicating whether the data stored - * for this field's entity in TempStore should be used or reset. + * for this field's entity in PrivateTempStore should be used or reset. * @param Function callback * A callback function that will receive the form to be inserted, as well as * the ajax object, necessary if the callback wants to perform other AJAX diff --git a/core/modules/quickedit/js/views/AppView.js b/core/modules/quickedit/js/views/AppView.js index 9668251..c911da5 100644 --- a/core/modules/quickedit/js/views/AppView.js +++ b/core/modules/quickedit/js/views/AppView.js @@ -12,10 +12,10 @@ // Indicates whether the page should be reloaded after in-place editing has // shut down. A page reload is necessary to re-instate the original HTML of the // edited fields if in-place editing has been canceled and one or more of the - // entity's fields were saved to TempStore: one of them may have been changed to - // the empty value and hence may have been rerendered as the empty string, which - // makes it impossible for Quick Edit to know where to restore the original - // HTML. + // entity's fields were saved to PrivateTempStore: one of them may have been + // changed to the empty value and hence may have been rerendered as the empty + // string, which makes it impossible for Quick Edit to know where to restore + // the original HTML. var reload = false; Drupal.quickedit.AppView = Backbone.View.extend({ diff --git a/core/modules/quickedit/js/views/EditorView.js b/core/modules/quickedit/js/views/EditorView.js index 5122938..4bb410c 100644 --- a/core/modules/quickedit/js/views/EditorView.js +++ b/core/modules/quickedit/js/views/EditorView.js @@ -197,12 +197,13 @@ $el: this.$el, nocssjs: true, other_view_modes: fieldModel.findOtherViewModes(), - // Reset an existing entry for this entity in the TempStore (if any) when - // saving the field. Logically speaking, this should happen in a separate - // request because this is an entity-level operation, not a field-level - // operation. But that would require an additional request, that might not - // even be necessary: it is only when a user saves a first changed field - // for an entity that this needs to happen: precisely now! + // Reset an existing entry for this entity in the PrivateTempStore (if + // any) when saving the field. Logically speaking, this should happen in + // a separate request because this is an entity-level operation, not a + // field-level operation. But that would require an additional request, + // that might not even be necessary: it is only when a user saves a + // first changed field for an entity that this needs to happen: + // precisely now! reset: !this.fieldModel.get('entity').get('inTempStore') }; diff --git a/core/modules/quickedit/js/views/FieldDecorationView.js b/core/modules/quickedit/js/views/FieldDecorationView.js index a3d8d2e..93549e3 100644 --- a/core/modules/quickedit/js/views/FieldDecorationView.js +++ b/core/modules/quickedit/js/views/FieldDecorationView.js @@ -99,7 +99,8 @@ /** * Adds a class to the edited element that indicates whether the field has * been changed by the user (i.e. locally) or the field has already been - * changed and stored before by the user (i.e. remotely, stored in TempStore). + * changed and stored before by the user (i.e. remotely, stored in + * PrivateTempStore). */ renderChanged: function () { this.$el.toggleClass('quickedit-changed', this.model.get('isChanged') || this.model.get('inTempStore')); diff --git a/core/modules/quickedit/src/Ajax/EntitySavedCommand.php b/core/modules/quickedit/src/Ajax/EntitySavedCommand.php index e5b399f..cf7ad18 100644 --- a/core/modules/quickedit/src/Ajax/EntitySavedCommand.php +++ b/core/modules/quickedit/src/Ajax/EntitySavedCommand.php @@ -8,8 +8,8 @@ namespace Drupal\quickedit\Ajax; /** - * AJAX command to indicate the entity was loaded from TempStore and saved into - * the database. + * AJAX command to indicate the entity was loaded from PrivateTempStore and + * saved into the database. */ class EntitySavedCommand extends BaseCommand { diff --git a/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php b/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php index 3e6dee9..f0dc386 100644 --- a/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php +++ b/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php @@ -8,8 +8,9 @@ namespace Drupal\quickedit\Ajax; /** - * AJAX command to indicate a field was saved into TempStore without validation - * errors and pass the rerendered field to Quick Edit's JavaScript app. + * AJAX command to indicate a field was saved into PrivateTempStore without + * validation errors and pass the rerendered field to Quick Edit's JavaScript + * app. */ class FieldFormSavedCommand extends BaseCommand { diff --git a/core/modules/quickedit/src/Form/QuickEditFieldForm.php b/core/modules/quickedit/src/Form/QuickEditFieldForm.php index 6193932..54e7170 100644 --- a/core/modules/quickedit/src/Form/QuickEditFieldForm.php +++ b/core/modules/quickedit/src/Form/QuickEditFieldForm.php @@ -16,7 +16,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Entity\Entity\EntityFormDisplay; -use Drupal\user\FooTempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -27,7 +27,7 @@ class QuickEditFieldForm extends FormBase { /** * Stores the tempstore factory. * - * @var \Drupal\user\FooTempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; @@ -48,14 +48,14 @@ class QuickEditFieldForm extends FormBase { /** * Constructs a new EditFieldForm. * - * @param \Drupal\user\FooTempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Entity\EntityStorageInterface $node_type_storage * The node type storage. */ - public function __construct(FooTempStoreFactory $temp_store_factory, ModuleHandlerInterface $module_handler, EntityStorageInterface $node_type_storage) { + public function __construct(PrivateTempStoreFactory $temp_store_factory, ModuleHandlerInterface $module_handler, EntityStorageInterface $node_type_storage) { $this->moduleHandler = $module_handler; $this->nodeTypeStorage = $node_type_storage; $this->tempStoreFactory = $temp_store_factory; @@ -66,7 +66,7 @@ public function __construct(FooTempStoreFactory $temp_store_factory, ModuleHandl */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.foo_tempstore'), + $container->get('user.private_tempstore'), $container->get('module_handler'), $container->get('entity.manager')->getStorage('node_type') ); diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php index 62b18ae..3747609 100644 --- a/core/modules/quickedit/src/QuickEditController.php +++ b/core/modules/quickedit/src/QuickEditController.php @@ -9,7 +9,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Form\FormState; -use Drupal\user\FooTempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -27,9 +27,9 @@ class QuickEditController extends ControllerBase { /** - * The TempStore factory. + * The PrivateTempStore factory. * - * @var \Drupal\user\FooTempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; @@ -50,14 +50,14 @@ class QuickEditController extends ControllerBase { /** * Constructs a new QuickEditController. * - * @param \Drupal\user\FooTempStoreFactory $temp_store_factory - * The TempStore factory. + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory + * The PrivateTempStore factory. * @param \Drupal\quickedit\MetadataGeneratorInterface $metadata_generator * The in-place editing metadata generator. * @param \Drupal\quickedit\EditorSelectorInterface $editor_selector * The in-place editor selector. */ - public function __construct(FooTempStoreFactory $temp_store_factory, MetadataGeneratorInterface $metadata_generator, EditorSelectorInterface $editor_selector) { + public function __construct(PrivateTempStoreFactory $temp_store_factory, MetadataGeneratorInterface $metadata_generator, EditorSelectorInterface $editor_selector) { $this->tempStoreFactory = $temp_store_factory; $this->metadataGenerator = $metadata_generator; $this->editorSelector = $editor_selector; @@ -68,7 +68,7 @@ public function __construct(FooTempStoreFactory $temp_store_factory, MetadataGen */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.foo_tempstore'), + $container->get('user.private_tempstore'), $container->get('quickedit.metadata.generator'), $container->get('quickedit.editor.selector') ); @@ -167,8 +167,8 @@ public function attachments(Request $request) { public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view_mode_id, Request $request) { $response = new AjaxResponse(); - // Replace entity with TempStore copy if available and not resetting, init - // TempStore copy otherwise. + // Replace entity with PrivateTempStore copy if available and not resetting, + // init PrivateTempStore copy otherwise. $tempstore_entity = $this->tempStoreFactory->get('quickedit')->get($entity->uuid()); if ($tempstore_entity && $request->request->get('reset') !== 'true') { $entity = $tempstore_entity; @@ -184,8 +184,8 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view $form = $this->formBuilder()->buildForm('Drupal\quickedit\Form\QuickEditFieldForm', $form_state); if ($form_state->isExecuted()) { - // The form submission saved the entity in TempStore. Return the - // updated view of the field from the TempStore copy. + // The form submission saved the entity in PrivateTempStore. Return the + // updated view of the field from the PrivateTempStore copy. $entity = $this->tempStoreFactory->get('quickedit')->get($entity->uuid()); // Closure to render the field given a view mode. @@ -267,7 +267,7 @@ protected function renderField(EntityInterface $entity, $field_name, $langcode, } /** - * Saves an entity into the database, from TempStore. + * Saves an entity into the database, from PrivateTempStore. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity being edited. @@ -276,8 +276,8 @@ protected function renderField(EntityInterface $entity, $field_name, $langcode, * The Ajax response. */ public function entitySave(EntityInterface $entity) { - // Take the entity from TempStore and save in entity storage. fieldForm() - // ensures that the TempStore copy exists ahead. + // Take the entity from PrivateTempStore and save in entity storage. + // fieldForm() ensures that the PrivateTempStore copy exists ahead. $tempstore = $this->tempStoreFactory->get('quickedit'); $tempstore->get($entity->uuid())->save(); $tempstore->delete($entity->uuid()); diff --git a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php index 473cc08..3c42409 100644 --- a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php @@ -170,7 +170,8 @@ public function testAutocompleteQuickEdit() { $this->assertText('new term'); $this->assertNoLink('new term'); - // Load the form again, which should now get it back from TempStore. + // Load the form again, which should now get it back from + // PrivateTempStore. $quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->fieldName . '/' . $this->node->language()->getId() . '/full'; $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData(); $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post); diff --git a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php index 0cb2c63..3606f01 100644 --- a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php @@ -214,7 +214,7 @@ public function testUserWithPermission() { $post += $edit + $this->getAjaxPageStatePostData(); // Submit field form and check response. This should store the updated - // entity in TempStore on the server. + // entity in PrivateTempStore on the server. $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post); $this->assertResponse(200); $ajax_commands = Json::decode($response); @@ -227,7 +227,7 @@ public function testUserWithPermission() { $this->drupalGet('node/1'); $this->assertText('How are you?'); - // Save the entity by moving the TempStore values to entity storage. + // Save the entity by moving the PrivateTempStore values to entity storage. $post = array('nocssjs' => 'true'); $response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post); $this->assertResponse(200); @@ -249,7 +249,7 @@ public function testUserWithPermission() { // Now configure this node type to create new revisions automatically, // then again retrieve the field form, fill it, submit it (so it ends up - // in TempStore) and then save the entity. Now there should be two + // in PrivateTempStore) and then save the entity. Now there should be two // revisions. $node_type = entity_load('node_type', 'article'); $node_type->setNewRevision(TRUE); @@ -359,7 +359,7 @@ public function testTitleBaseField() { $post += $edit + $this->getAjaxPageStatePostData(); // Submit field form and check response. This should store the - // updated entity in TempStore on the server. + // updated entity in PrivateTempStore on the server. $response = $this->drupalPost('quickedit/form/' . 'node/1/title/en/full', 'application/vnd.drupal-ajax', $post); $this->assertResponse(200); $ajax_commands = Json::decode($response); @@ -371,7 +371,7 @@ public function testTitleBaseField() { $this->drupalGet('node/1'); $this->assertNoText('Obligatory question'); - // Save the entity by moving the TempStore values to entity storage. + // Save the entity by moving the PrivateTempStore values to entity storage. $post = array('nocssjs' => 'true'); $response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post); $this->assertResponse(200); diff --git a/core/modules/user/src/Form/UserMultipleCancelConfirm.php b/core/modules/user/src/Form/UserMultipleCancelConfirm.php index da26ee7..432544b 100644 --- a/core/modules/user/src/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/src/Form/UserMultipleCancelConfirm.php @@ -12,7 +12,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; -use Drupal\user\TempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Drupal\user\UserStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -24,7 +24,7 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { /** * The temp store factory. * - * @var \Drupal\user\TempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; @@ -45,14 +45,14 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { /** * Constructs a new UserMultipleCancelConfirm. * - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The temp store factory. * @param \Drupal\user\UserStorageInterface $user_storage * The user storage. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ - public function __construct(TempStoreFactory $temp_store_factory, UserStorageInterface $user_storage, EntityManagerInterface $entity_manager) { + public function __construct(PrivateTempStoreFactory $temp_store_factory, UserStorageInterface $user_storage, EntityManagerInterface $entity_manager) { $this->tempStoreFactory = $temp_store_factory; $this->userStorage = $user_storage; $this->entityManager = $entity_manager; @@ -63,7 +63,7 @@ public function __construct(TempStoreFactory $temp_store_factory, UserStorageInt */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.tempstore'), + $container->get('user.private_tempstore'), $container->get('entity.manager')->getStorage('user'), $container->get('entity.manager') ); diff --git a/core/modules/user/src/Plugin/Action/CancelUser.php b/core/modules/user/src/Plugin/Action/CancelUser.php index 3219b62..e057106 100644 --- a/core/modules/user/src/Plugin/Action/CancelUser.php +++ b/core/modules/user/src/Plugin/Action/CancelUser.php @@ -10,7 +10,7 @@ use Drupal\Core\Action\ActionBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\user\TempStoreFactory; +use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -28,7 +28,7 @@ class CancelUser extends ActionBase implements ContainerFactoryPluginInterface { /** * The tempstore factory. * - * @var \Drupal\user\TempStoreFactory + * @var \Drupal\user\PrivateTempStoreFactory */ protected $tempStoreFactory; @@ -48,12 +48,12 @@ class CancelUser extends ActionBase implements ContainerFactoryPluginInterface { * The plugin ID for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. * @param AccountInterface $current_user * Current user. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, TempStoreFactory $temp_store_factory, AccountInterface $current_user) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, PrivateTempStoreFactory $temp_store_factory, AccountInterface $current_user) { $this->currentUser = $current_user; $this->tempStoreFactory = $temp_store_factory; @@ -68,7 +68,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('user.tempstore'), + $container->get('user.private_tempstore'), $container->get('current_user') ); } diff --git a/core/modules/user/src/FooTempStore.php b/core/modules/user/src/PrivateTempStore.php similarity index 88% rename from core/modules/user/src/FooTempStore.php rename to core/modules/user/src/PrivateTempStore.php index 838d633..cb848c6 100644 --- a/core/modules/user/src/FooTempStore.php +++ b/core/modules/user/src/PrivateTempStore.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\user\FooTempStore. + * Contains Drupal\user\PrivateTempStore. */ namespace Drupal\user; @@ -16,23 +16,23 @@ /** * Stores and retrieves temporary data for a given owner. * - * A FooTempStore can be used to make temporary, non-cache data available - * across requests. The data for the FooTempStore is stored in one - * key/value collection. FooTempStore data expires automatically after a + * A PrivateTempStore can be used to make temporary, non-cache data available + * across requests. The data for the PrivateTempStore is stored in one + * key/value collection. PrivateTempStore data expires automatically after a * given timeframe. * - * The FooTempStore is different from a cache, because the data in it is not yet - * saved permanently and so it cannot be rebuilt. Typically, the FooTempStore + * The PrivateTempStore is different from a cache, because the data in it is not yet + * saved permanently and so it cannot be rebuilt. Typically, the PrivateTempStore * might be used to store work in progress that is later saved permanently * elsewhere, e.g. autosave data, multistep forms, or in-progress changes * to complex configuration that are not ready to be saved. * - * The FooTempStore differs from the TempStore in that all keys are + * The PrivateTempStore differs from the SharedTempStore in that all keys are * ensured to be unique for a particular user and users can never share data. If - * you want to be able to share data between users or use the tempStore for - * locking use \Drupal\user\TempStore. + * you want to be able to share data between users or use it for locking, use + * \Drupal\user\SharedTempStore. */ -class FooTempStore { +class PrivateTempStore { /** * The key/value storage object used for this data. @@ -94,7 +94,7 @@ public function __construct(KeyValueStoreExpirableInterface $storage, LockBacken } /** - * Retrieves a value from this TempStore for a given key. + * Retrieves a value from this PrivateTempStore for a given key. * * @param string $key * The key of the data to retrieve. @@ -110,7 +110,7 @@ public function get($key) { } /** - * Stores a particular key/value pair in this TempStore. + * Stores a particular key/value pair in this PrivateTempStore. * * @param string $key * The key of the data to store. diff --git a/core/modules/user/src/FooTempStoreFactory.php b/core/modules/user/src/PrivateTempStoreFactory.php similarity index 80% rename from core/modules/user/src/FooTempStoreFactory.php rename to core/modules/user/src/PrivateTempStoreFactory.php index aeecd7b..bd62633 100644 --- a/core/modules/user/src/FooTempStoreFactory.php +++ b/core/modules/user/src/PrivateTempStoreFactory.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\user\FooTempStoreFactory. + * Definition of Drupal\user\PrivateTempStoreFactory. */ namespace Drupal\user; @@ -13,9 +13,9 @@ use Symfony\Component\HttpFoundation\RequestStack; /** - * Creates a FooTempStore object for a given collecton. + * Creates a PrivateTempStore object for a given collecton. */ -class FooTempStoreFactory { +class PrivateTempStoreFactory { /** * The storage factory creating the backend to store the data. @@ -53,7 +53,7 @@ class FooTempStoreFactory { protected $expire; /** - * Constructs a Drupal\user\TempStoreFactory object. + * Constructs a Drupal\user\PrivateTempStoreFactory object. * * @param \Drupal\Core\Database\Connection $connection * The connection object used for this data. @@ -71,19 +71,19 @@ function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBac } /** - * Creates a FooTempStore. + * Creates a PrivateTempStore. * * @param string $collection * The collection name to use for this key/value store. This is typically * a shared namespace or module name, e.g. 'views', 'entity', etc. * - * @return \Drupal\user\TempStore + * @return \Drupal\user\PrivateTempStore * An instance of the key/value store. */ function get($collection) { // Store the data for this collection in the database. - $storage = $this->storageFactory->get("user.tempstore.$collection"); - return new FooTempStore($storage, $this->lockBackend, $this->currentUser, $this->requestStack, $this->expire); + $storage = $this->storageFactory->get("user.private_tempstore.$collection"); + return new PrivateTempStore($storage, $this->lockBackend, $this->currentUser, $this->requestStack, $this->expire); } } diff --git a/core/modules/user/src/TempStore.php b/core/modules/user/src/SharedTempStore.php similarity index 84% rename from core/modules/user/src/TempStore.php rename to core/modules/user/src/SharedTempStore.php index da87691..0049d79 100644 --- a/core/modules/user/src/TempStore.php +++ b/core/modules/user/src/SharedTempStore.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\user\TempStore. + * Contains Drupal\user\SharedTempStore. */ namespace Drupal\user; @@ -14,29 +14,33 @@ /** * Stores and retrieves temporary data for a given owner. * - * A TempStore can be used to make temporary, non-cache data available across - * requests. The data for the TempStore is stored in one key/value collection. - * TempStore data expires automatically after a given timeframe. + * A SharedTempStore can be used to make temporary, non-cache data available + * across requests. The data for the SharedTempStore is stored in one key/value + * collection. SharedTempStore data expires automatically after a given + * timeframe. * - * The TempStore is different from a cache, because the data in it is not yet - * saved permanently and so it cannot be rebuilt. Typically, the TempStore - * might be used to store work in progress that is later saved permanently - * elsewhere, e.g. autosave data, multistep forms, or in-progress changes - * to complex configuration that are not ready to be saved. + * The SharedTempStore is different from a cache, because the data in it is not + * yet saved permanently and so it cannot be rebuilt. Typically, the + * SharedTempStore might be used to store work in progress that is later saved + * permanently elsewhere, e.g. autosave data, multistep forms, or in-progress + * changes to complex configuration that are not ready to be saved. * - * Each TempStore belongs to a particular owner (e.g. a user, session, or + * Each SharedTempStore belongs to a particular owner (e.g. a user, session, or * process). Multiple owners may use the same key/value collection, and the * owner is stored along with the key/value pair. * - * Every key is unique within the collection, so the TempStore can check + * Every key is unique within the collection, so the SharedTempStore can check * whether a particular key is already set by a different owner. This is * useful for informing one owner that the data is already in use by another; * for example, to let one user know that another user is in the process of * editing certain data, or even to restrict other users from editing it at * the same time. It is the responsibility of the implementation to decide * when and whether one owner can use or update another owner's data. + * + * If you want to be able to ensure that the data belongs to the current user, + * use \Drupal\user\PrivateTempStore. */ -class TempStore { +class SharedTempStore { /** * The key/value storage object used for this data. @@ -90,7 +94,7 @@ public function __construct(KeyValueStoreExpirableInterface $storage, LockBacken } /** - * Retrieves a value from this TempStore for a given key. + * Retrieves a value from this SharedTempStore for a given key. * * @param string $key * The key of the data to retrieve. @@ -105,7 +109,7 @@ public function get($key) { } /** - * Retrieves a value from this TempStore for a given key. + * Retrieves a value from this SharedTempStore for a given key. * * Only returns the value if the value is owned by $this->owner. * @@ -142,7 +146,7 @@ public function setIfNotExists($key, $value) { } /** - * Stores a particular key/value pair in this TempStore. + * Stores a particular key/value pair in this SharedTempStore. * * Only stores the given key/value pair if it does not exist yet or is owned * by $this->owner. @@ -170,7 +174,7 @@ public function setIfOwner($key, $value) { } /** - * Stores a particular key/value pair in this TempStore. + * Stores a particular key/value pair in this SharedTempStore. * * @param string $key * The key of the data to store. diff --git a/core/modules/user/src/TempStoreFactory.php b/core/modules/user/src/SharedTempStoreFactory.php similarity index 76% rename from core/modules/user/src/TempStoreFactory.php rename to core/modules/user/src/SharedTempStoreFactory.php index 5f19199..6166815 100644 --- a/core/modules/user/src/TempStoreFactory.php +++ b/core/modules/user/src/SharedTempStoreFactory.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\user\TempStoreFactory. + * Definition of Drupal\user\SharedTempStoreFactory. */ namespace Drupal\user; @@ -12,9 +12,9 @@ use Drupal\Core\Lock\LockBackendInterface; /** - * Creates a key/value storage object for the current user or anonymous session. + * Creates a shared temporary storage for a collection. */ -class TempStoreFactory { +class SharedTempStoreFactory { /** * The storage factory creating the backend to store the data. @@ -38,7 +38,7 @@ class TempStoreFactory { protected $expire; /** - * Constructs a Drupal\user\TempStoreFactory object. + * Constructs a Drupal\user\SharedTempStoreFactory object. * * @param \Drupal\Core\Database\Connection $connection * The connection object used for this data. @@ -54,17 +54,17 @@ function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBac } /** - * Creates a TempStore for the current user or anonymous session. + * Creates a SharedTempStore for the current user or anonymous session. * * @param string $collection * The collection name to use for this key/value store. This is typically * a shared namespace or module name, e.g. 'views', 'entity', etc. * @param mixed $owner - * (optional) The owner of this TempStore. By default, the TempStore is + * (optional) The owner of this SharedTempStore. By default, the SharedTempStore is * owned by the currently authenticated user, or by the active anonymous * session if no user is logged in. * - * @return \Drupal\user\TempStore + * @return \Drupal\user\SharedTempStore * An instance of the key/value store. */ function get($collection, $owner = NULL) { @@ -75,8 +75,8 @@ function get($collection, $owner = NULL) { } // Store the data for this collection in the database. - $storage = $this->storageFactory->get("user.tempstore.$collection"); - return new TempStore($storage, $this->lockBackend, $owner, $this->expire); + $storage = $this->storageFactory->get("user.shared_tempstore.$collection"); + return new SharedTempStore($storage, $this->lockBackend, $owner, $this->expire); } } diff --git a/core/modules/user/src/TempStoreException.php b/core/modules/user/src/TempStoreException.php index 497a2ef..a552b7b 100644 --- a/core/modules/user/src/TempStoreException.php +++ b/core/modules/user/src/TempStoreException.php @@ -8,6 +8,9 @@ namespace Drupal\user; /** - * Defines the exception thrown if the TempStore cannot acquire a lock. + * Thrown by SharedTempStore and PrivateTempStore if they cannot acquire a lock. + * + * @see \Drupal\user\SharedTempStore + * @see \Drupal\user\PrivateTempStore */ class TempStoreException extends \Exception {} diff --git a/core/modules/user/src/Tests/TempStoreDatabaseTest.php b/core/modules/user/src/Tests/TempStoreDatabaseTest.php index ad6f56b..b12cbf2 100644 --- a/core/modules/user/src/Tests/TempStoreDatabaseTest.php +++ b/core/modules/user/src/Tests/TempStoreDatabaseTest.php @@ -10,7 +10,7 @@ use Drupal\Component\Serialization\PhpSerialize; use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; use Drupal\simpletest\KernelTestBase; -use Drupal\user\TempStoreFactory; +use Drupal\user\SharedTempStoreFactory; use Drupal\Core\Lock\DatabaseLockBackend; use Drupal\Core\Database\Database; @@ -32,7 +32,7 @@ class TempStoreDatabaseTest extends KernelTestBase { /** * A key/value store factory. * - * @var \Drupal\user\TempStoreFactory + * @var \Drupal\user\SharedTempStoreFactory */ protected $storeFactory; @@ -76,14 +76,14 @@ protected function setUp() { */ public function testUserTempStore() { // Create a key/value collection. - $factory = new TempStoreFactory(new KeyValueExpirableFactory(\Drupal::getContainer()), new DatabaseLockBackend(Database::getConnection())); + $factory = new SharedTempStoreFactory(new KeyValueExpirableFactory(\Drupal::getContainer()), new DatabaseLockBackend(Database::getConnection())); $collection = $this->randomMachineName(); // Create two mock users. for ($i = 0; $i <= 1; $i++) { $users[$i] = mt_rand(500, 5000000); - // Storing the TempStore objects in a class member variable causes a + // Storing the SharedTempStore objects in a class member variable causes a // fatal exception, because in that situation garbage collection is not // triggered until the test class itself is destructed, after tearDown() // has deleted the database tables. Store the objects locally instead. @@ -142,7 +142,7 @@ public function testUserTempStore() { // assert it is no longer accessible. db_update('key_value_expire') ->fields(array('expire' => REQUEST_TIME - 1)) - ->condition('collection', "user.tempstore.$collection") + ->condition('collection', "user.shared_tempstore.$collection") ->condition('name', $key) ->execute(); $this->assertFalse($stores[0]->get($key)); diff --git a/core/modules/user/tests/src/Unit/FooTempStoreTest.php b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php similarity index 95% rename from core/modules/user/tests/src/Unit/FooTempStoreTest.php rename to core/modules/user/tests/src/Unit/PrivateTempStoreTest.php index d2f1762..51a1b50 100644 --- a/core/modules/user/tests/src/Unit/FooTempStoreTest.php +++ b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php @@ -2,20 +2,20 @@ /** * @file - * Contains \Drupal\Tests\user\Unit\FooTempStoreTest. + * Contains \Drupal\Tests\user\Unit\PrivateTempStoreTest. */ namespace Drupal\Tests\user\Unit; use Drupal\Tests\UnitTestCase; -use Drupal\user\FooTempStore; +use Drupal\user\PrivateTempStore; use Symfony\Component\HttpFoundation\RequestStack; /** - * @coversDefaultClass \Drupal\user\FooTempStore + * @coversDefaultClass \Drupal\user\PrivateTempStore * @group user */ -class FooTempStoreTest extends UnitTestCase { +class PrivateTempStoreTest extends UnitTestCase { /** * The mock key value expirable backend. @@ -34,7 +34,7 @@ class FooTempStoreTest extends UnitTestCase { /** * The user temp store. * - * @var \Drupal\user\FooTempStore + * @var \Drupal\user\PrivateTempStore */ protected $tempStore; @@ -81,7 +81,7 @@ protected function setUp() { $this->requestStack = new RequestStack(); - $this->tempStore = new FooTempStore($this->keyValue, $this->lock, $this->currentUser, $this->requestStack, 604800); + $this->tempStore = new PrivateTempStore($this->keyValue, $this->lock, $this->currentUser, $this->requestStack, 604800); $this->ownObject = (object) array( 'data' => 'test_data', diff --git a/core/modules/user/tests/src/Unit/TempStoreTest.php b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php similarity index 96% rename from core/modules/user/tests/src/Unit/TempStoreTest.php rename to core/modules/user/tests/src/Unit/SharedTempStoreTest.php index 68b4e70..a402a06 100644 --- a/core/modules/user/tests/src/Unit/TempStoreTest.php +++ b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php @@ -2,19 +2,19 @@ /** * @file - * Contains \Drupal\Tests\user\Unit\TempStoreTest. + * Contains \Drupal\Tests\user\Unit\SharedTempStoreTest. */ namespace Drupal\Tests\user\Unit; use Drupal\Tests\UnitTestCase; -use Drupal\user\TempStore; +use Drupal\user\SharedTempStore; /** - * @coversDefaultClass \Drupal\user\TempStore + * @coversDefaultClass \Drupal\user\SharedTempStore * @group user */ -class TempStoreTest extends UnitTestCase { +class SharedTempStoreTest extends UnitTestCase { /** * The mock key value expirable backend. @@ -33,7 +33,7 @@ class TempStoreTest extends UnitTestCase { /** * The user temp store. * - * @var \Drupal\user\TempStore + * @var \Drupal\user\SharedTempStore */ protected $tempStore; @@ -67,7 +67,7 @@ protected function setUp() { $this->keyValue = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface'); $this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface'); - $this->tempStore = new TempStore($this->keyValue, $this->lock, $this->owner, 604800); + $this->tempStore = new SharedTempStore($this->keyValue, $this->lock, $this->owner, 604800); $this->ownObject = (object) array( 'data' => 'test_data', diff --git a/core/modules/user/user.services.yml b/core/modules/user/user.services.yml index d508d30..5bec22c 100644 --- a/core/modules/user/user.services.yml +++ b/core/modules/user/user.services.yml @@ -58,14 +58,14 @@ services: user.auth: class: Drupal\user\UserAuth arguments: ['@entity.manager', '@password'] - user.tempstore: - class: Drupal\user\TempStoreFactory - arguments: ['@keyvalue.expirable', '@lock', '%user.tempstore.expire%'] + user.private_tempstore: + class: Drupal\user\PrivateTempStoreFactory + arguments: ['@keyvalue.expirable', '@lock', '@current_user', '@request_stack', '%user.tempstore.expire%'] tags: - { name: backend_overridable } - user.foo_tempstore: - class: Drupal\user\FooTempStoreFactory - arguments: ['@keyvalue.expirable', '@lock', '@current_user', '@request_stack', '%user.tempstore.expire%'] + user.shared_tempstore: + class: Drupal\user\SharedTempStoreFactory + arguments: ['@keyvalue.expirable', '@lock', '%user.tempstore.expire%'] tags: - { name: backend_overridable } user.permissions: diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 05bc393..e6e6e29 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -401,7 +401,7 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie public static function postDelete(EntityStorageInterface $storage, array $entities) { parent::postDelete($storage, $entities); - $tempstore = \Drupal::service('user.tempstore')->get('views'); + $tempstore = \Drupal::service('user.shared_tempstore')->get('views'); foreach ($entities as $entity) { $tempstore->delete($entity->id()); } diff --git a/core/modules/views_ui/src/Form/BreakLockForm.php b/core/modules/views_ui/src/Form/BreakLockForm.php index 0d6d8db..82f1f6f 100644 --- a/core/modules/views_ui/src/Form/BreakLockForm.php +++ b/core/modules/views_ui/src/Form/BreakLockForm.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\user\TempStoreFactory; +use Drupal\user\SharedTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -28,7 +28,7 @@ class BreakLockForm extends EntityConfirmFormBase { /** * Stores the user tempstore. * - * @var \Drupal\user\TempStore + * @var \Drupal\user\SharedTempStore */ protected $tempStore; @@ -37,10 +37,10 @@ class BreakLockForm extends EntityConfirmFormBase { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The Entity manager. - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\SharedTempStoreFactory $temp_store_factory * The factory for the temp store object. */ - public function __construct(EntityManagerInterface $entity_manager, TempStoreFactory $temp_store_factory) { + public function __construct(EntityManagerInterface $entity_manager, SharedTempStoreFactory $temp_store_factory) { $this->entityManager = $entity_manager; $this->tempStore = $temp_store_factory->get('views'); } @@ -51,7 +51,7 @@ public function __construct(EntityManagerInterface $entity_manager, TempStoreFac public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), - $container->get('user.tempstore') + $container->get('user.shared_tempstore') ); } diff --git a/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php b/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php index 1a6fa99..c31a615 100644 --- a/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php +++ b/core/modules/views_ui/src/ParamConverter/ViewUIConverter.php @@ -11,7 +11,7 @@ use Drupal\Core\ParamConverter\EntityConverter; use Symfony\Component\Routing\Route; use Drupal\Core\ParamConverter\ParamConverterInterface; -use Drupal\user\TempStoreFactory; +use Drupal\user\SharedTempStoreFactory; use Drupal\views_ui\ViewUI; /** @@ -35,17 +35,17 @@ class ViewUIConverter extends EntityConverter implements ParamConverterInterface /** * Stores the tempstore factory. * - * @var \Drupal\user\TempStoreFactory + * @var \Drupal\user\SharedTempStoreFactory */ protected $tempStoreFactory; /** * Constructs a new ViewUIConverter. * - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\SharedTempStoreFactory $temp_store_factory * The factory for the temp store object. */ - public function __construct(EntityManagerInterface $entity_manager, TempStoreFactory $temp_store_factory) { + public function __construct(EntityManagerInterface $entity_manager, SharedTempStoreFactory $temp_store_factory) { parent::__construct($entity_manager); $this->tempStoreFactory = $temp_store_factory; diff --git a/core/modules/views_ui/src/Tests/CachedDataUITest.php b/core/modules/views_ui/src/Tests/CachedDataUITest.php index f6ca040..6330b7d 100644 --- a/core/modules/views_ui/src/Tests/CachedDataUITest.php +++ b/core/modules/views_ui/src/Tests/CachedDataUITest.php @@ -27,7 +27,7 @@ class CachedDataUITest extends UITestBase { public function testCacheData() { $views_admin_user_uid = $this->fullAdminUser->id(); - $temp_store = $this->container->get('user.tempstore')->get('views'); + $temp_store = $this->container->get('user.shared_tempstore')->get('views'); // The view should not be locked. $this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'The view is not locked.'); diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 37fc363..5d27d30 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -19,7 +19,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Url; -use Drupal\user\TempStoreFactory; +use Drupal\user\SharedTempStoreFactory; use Drupal\views\Views; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -33,7 +33,7 @@ class ViewEditForm extends ViewFormBase { /** * The views temp store. * - * @var \Drupal\user\TempStore + * @var \Drupal\user\SharedTempStore */ protected $tempStore; @@ -54,14 +54,14 @@ class ViewEditForm extends ViewFormBase { /** * Constructs a new ViewEditForm object. * - * @param \Drupal\user\TempStoreFactory $temp_store_factory + * @param \Drupal\user\SharedTempStoreFactory $temp_store_factory * The factory for the temp store object. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack object. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date Formatter service. */ - public function __construct(TempStoreFactory $temp_store_factory, RequestStack $requestStack, DateFormatter $date_formatter) { + public function __construct(SharedTempStoreFactory $temp_store_factory, RequestStack $requestStack, DateFormatter $date_formatter) { $this->tempStore = $temp_store_factory->get('views'); $this->requestStack = $requestStack; $this->dateFormatter = $date_formatter; @@ -72,7 +72,7 @@ public function __construct(TempStoreFactory $temp_store_factory, RequestStack $ */ public static function create(ContainerInterface $container) { return new static( - $container->get('user.tempstore'), + $container->get('user.shared_tempstore'), $container->get('request_stack'), $container->get('date.formatter') ); @@ -770,7 +770,7 @@ public function renderDisplayTop(ViewUI $view) { * Submit handler for form buttons that do not complete a form workflow. * * The Edit View form is a multistep form workflow, but with state managed by - * the TempStore rather than $form_state->setRebuild(). Without this + * the SharedTempStore rather than $form_state->setRebuild(). Without this * submit handler, buttons that add or remove displays would redirect to the * destination parameter (e.g., when the Edit View form is linked to from a * contextual link). This handler can be added to buttons whose form submission diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 08e887c..c5d7dc4 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -70,7 +70,7 @@ class ViewUI implements ViewEntityInterface { * If this view is locked for editing. * * If this view is locked it will contain the result of - * \Drupal\user\TempStore::getMetadata(). Which can be a stdClass or NULL. + * \Drupal\user\SharedTempStore::getMetadata(). Which can be a stdClass or NULL. * * @var stdClass */ @@ -877,7 +877,7 @@ public function cacheSet() { unset($executable->default_display); $executable->query = NULL; unset($executable->displayHandlers); - \Drupal::service('user.tempstore')->get('views')->set($this->id(), $this); + \Drupal::service('user.shared_tempstore')->get('views')->set($this->id(), $this); } /** diff --git a/core/modules/views_ui/views_ui.services.yml b/core/modules/views_ui/views_ui.services.yml index e75c7af..7a91adb 100644 --- a/core/modules/views_ui/views_ui.services.yml +++ b/core/modules/views_ui/views_ui.services.yml @@ -1,6 +1,6 @@ services: paramconverter.views_ui: class: Drupal\views_ui\ParamConverter\ViewUIConverter - arguments: ['@entity.manager', '@user.tempstore'] + arguments: ['@entity.manager', '@user.shared_tempstore'] tags: - { name: paramconverter, priority: 10 }