Problem/Motivation
Since Drupal 10 and specifically [#3006268] \Drupal\ctools\SerializableTempstoreFactory
is broken.
/**
* Constructs a Drupal\Core\TempStore\SharedTempStoreFactory object.
*
* @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $storage_factory
* The key/value store factory.
* @param \Drupal\Core\Lock\LockBackendInterface $lock_backend
* The lock object used for this data.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
* @param int $expire
* The time to live for items, in seconds.
* @param \Drupal\Core\Session\AccountProxyInterface|null $current_user
* The current logged user.
*/
public function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lock_backend, RequestStack $request_stack, $expire = 604800, AccountProxyInterface $current_user = NULL) {
parent::__construct($storage_factory, $lock_backend, $request_stack, $expire);
$this->currentUser = $current_user ?: \Drupal::currentUser();
}
calls the parent class with different parameters then expected. Here the same call, but then with named paremeters:
parent::__construct(storage_factory: $storage_factory, lock_backend: $lock_backend, request_stack: $request_stack, current_user: $expire);
Notice that current_user: $expire
does not match.
The service declaration for ctools.serializable.tempstore.factory
is:
ctools.serializable.tempstore.factory:
class: Drupal\ctools\SerializableTempstoreFactory
arguments: ['@keyvalue.expirable', '@lock', '@request_stack', '%tempstore.expire%', '@current_user']
deprecated: The "%service_id%" service is deprecated. You should use the core shared tempstore factory service instead.
tags:
- { name: backend_overridable }
Additional notes:
- the current_user object in Drupal 10 is required. In the ctools class it is optional.
- the ctools class is deprecated and it is noted that it will be removed before ctools:4.0.0.
Proposed resolution
1. Although deprecated, fix the class in this ticket for the 3.x branch.
Remaining tasks
User interface changes
API changes
Data model changes