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

CommentFileSizeAuthor
#2 2976862.patch843 bytesheddn

Comments

heddn created an issue. See original summary.

heddn’s picture

Status: Active » Needs review
StatusFileSize
new843 bytes
joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Yes that fixes things, thanks @heddn

  • heddn committed 99f94aa on 8.x-4.x
    Issue #2976862 by heddn, joelpittet: PrivateTempStore throws exception...
heddn’s picture

Status: Reviewed & tested by the community » Fixed
firfin’s picture

Yes, works perfectly, thanks!

dkh’s picture

With 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))) {

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

firfin’s picture

Exposed 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