-
-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console] PHP Fatal error: Call to a member function getId() on null #3091
Comments
@ismailcherri Can you try with latest DC versionRC-15 and comment back if still happening. |
Hi, So let me rephrase my original question, is what I'm doing wrong? Should I use another method to store temporary data for anonymous users? Or this is a console and/or core bug? Thanks! |
Same configuration and same problems of @ismailcherri |
I'm also seeing the same issue with RC-16. In a custom module, I'm starting sessions for anonymous users, and using PrivateTempStore to get data out of it. I'm seeing the same error as above. |
I should note that this was being called from a cache context. I added a workaround similar to what @ismailcherri is doing with checking for 'cli'. Now I'm seeing a similar issue with the Masquerade module: The offending code is:
So I guess the question is, is it possible to get sessions and the requestStack working with Drupal Console? What's odd is that I was able to use Drupal Console previously, so I'll need to track down what changed. I believe we upgraded our version of Drupal Console recently. |
I suddenly can't use any drupal console commands either, getting a similar bug. Error: Call to a member function getId() on null in /var/www/docroot/core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php on line 25 #0 /var/www/docroot/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php(118): Drupal\Core\Cache\Context\SessionCacheContext->getContext(NULL) Drupal core 8.3.1 |
@Christofferberg Drupal Console |
@jmolivas Sorry, that was my local version, my containerized drupal console is running version 1.0.0-rc16 and it's the same. |
I'm using version 1.0.0-rc18 and stumbled upon the same problem @Christofferberg had. I applied the Additional info: this only happens when I have a particular theme enabled, a sub-theme of Gesso. There isn't any relevant code in the theme, so it is probably related to the presence of custom blocks. |
Let's see if we can get a core d.org issue, to see if we can do some safe wrapping on that core context service. |
I have a similar issue:
@nelovishk Yes, it is the theme related issue. It happens only when my custom Bootstrap theme is activated. @ismailcherri's workaround works too in my case. Thank you, the both. How to solve it correctly? |
Same nasty issue with 1.0.0-rc21 |
@skvskv We need a way to identify and replicate in order to have this fixed. Did the workaround works for you? |
@jmolivas In order to reproduce you need the following:
|
@jmolivas I can verify that what @ismailcherri reported is still present in DC version RC-23 (and Drupal 8.3.4). I have pretty much the same conditions he has described. Looking into PrivateTempStore::getOwner() a little closer, it's not testing for a null session. |
@jmolivas This is still happening with the latest version of everything (Drupal core and console [rc-25])
|
This remains an issue on the |
I can confirm that this issue still remains. Maybe this could help: https://www.drupal.org/node/2839523 |
It appears to a be a module's problem, but I don't know why I never had that kind of problem with Drush. Anyways here's my patch to the Miling List module, which was the problem in my case: If you came here and you don't have the Mailing List module installed, check if there's any of your modules are using session even when is anonymous, and try to check if session is available before is used and then check if Drupal console is back again. Cheers. |
My solution was adding back language I removed and removing all the content in that particular language, also custom blocks needs to be deleted. Then you can safely remove language and no errors. |
Thank God I've finally quit developing for Drupal! |
Hi @ismailcherri and the other guys here, I have experimented similar issues as described here and tried to solve with the suggested workaround but I found another issue: #3553 I have dedicated few days to try to make our project compatible with 1.0.2 and worked on a fix that I just requested pull request #3558 to @jmolivas or @enzolutions that you can help to test and confirm if solves your issues. If you are interested to try here is the changes you need to do on your composer.json file: Add my fork on your repositories: "repositories": {
"console": {
"type": "vcs",
"url": "https://github.com/citlacom/drupal-console"
}
},
Change your require of drupal/console to:
Run the command:
Go to "vendor/drupal/console" or whatever is your vendor directory and ensure that composer have updated to my fork and fix branch "experimentation-fix-issue-3553". You can do that just running "git status" and look that you are "On branch experimentation-fix-issue-3553". In case composer do not upgrade to the fork try to remove the drupal vendor directory and it's contents and try again the composer update command. Finally run your custom commands and confirm here if this issue go away. Thanks. |
@ismailcherri @CRYX2 @bkildow @Christofferberg @noel-rivas @james-nesbitt @ArtuGit @skvskv @tuag @CaioBianchi @sebas5384 @lauriskuznecovs @citlacom |
@jmolivas Tested with version |
Hi @jmolivas - I have tested our custom Drupal Console commands after upgrade to 1.1.0 and worked perfectly. Many thanks for review the PR and released the new version. Have a great week! |
@jmolivas The issue can be closed |
Closing this one. Feel free to re-open if still happening after updating to the latest version. |
[ERROR] PHP Fatal error: Call to a member function getId() on null in /core/modules/user/src/PrivateTempStore.php on line 204
Hi, I get this error when I try to execute any Console command with a custom block enabled on every page of my Drupal 8.2.5 installation.
The block in question try to extract variable from the user private temp store using class \Drupal\user\PrivateTempStoreFactory
The problem is in this line of code in User core module:
The user module is trying to get a session but it seems that it doesn't exist on CLI of Console.
My workarround for now is to add a check
if (php_sapi_name() !== 'cli')
before trying to get the store.My question is:
Is this a core bug or a console bug?
The text was updated successfully, but these errors were encountered: