Problem/Motivation
Error: Call to a member function getId() on null in /core/lib/Drupal/Core/TempStore/PrivateTempStore.php on line 222 #0 /core/lib/Drupal/Core/TempStore/PrivateTempStore.php(212): Drupal\Core\TempStore\PrivateTempStore->getOwner()
This exposes a core bug: #2860341: PrivateTempStore->getOwner Attempts to access possibly unset Request Session
Proposed resolution
Start session as a quick fix.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2976862.patch | 843 bytes | heddn |
Comments
Comment #2
heddnComment #3
joelpittetYes that fixes things, thanks @heddn
Comment #5
heddnComment #6
firfin commentedYes, works perfectly, thanks!
Comment #7
dkh commentedWith migrate 8.x-4.0-beta3, patch won't apply. So I'll try the dev branch.
patch -p1 < 2976862.patch
patching file migrate_tools.module
Hunk #1 FAILED at 36.
1 out of 1 hunk FAILED -- saving rejects to file migrate_tools.module.rej
dhaley-30197s:migrate_tools dhaley$ cat migrate_tools.module.rej
***************
*** 36,41 ****
/** @var \Drupal\Core\TempStore\PrivateTempStoreFactory $store */
$tempStoreFactory = \Drupal::service('tempstore.private');
$store = $tempStoreFactory->get('migrate_tools');
// Get the list of changed migrations.
$migrationsChanged = $store->get('migrations_changed');
if (isset($store) && (is_array($migrationsChanged))) {
--- 36,48 ----
/** @var \Drupal\Core\TempStore\PrivateTempStoreFactory $store */
$tempStoreFactory = \Drupal::service('tempstore.private');
$store = $tempStoreFactory->get('migrate_tools');
+ // TODO: remove work-around after
+ // https://www.drupal.org/project/drupal/issues/2860341 is fixed.
+ if (!\Drupal::request()->hasSession()) {
+ $session = \Drupal::service('session');
+ \Drupal::request()->setSession($session);
+ $session->start();
+ }
// Get the list of changed migrations.
$migrationsChanged = $store->get('migrations_changed');
if (isset($store) && (is_array($migrationsChanged))) {
Comment #9
firfin commentedExposed core bug #2860341: PrivateTempStore->getOwner Attempts to access possibly unset Request Session is fixed and committed. And so will be in D8.7 and the next 8.6.x release.
Is it best to undo this patch in this thread (and if so, when?)
Or should it be done in a followup issue?
## EDIT
Trying to change the status I just answered my own question I guess. Created a new follow up issue: #3001798: Core patch is committed, follow up to remove workaround