I try to use the Photos module for the first time but when I click on the Photos tab it throws an error and this message appears on the screen
The website encountered an unexpected error. Please try again later.
In the drupal log there is this message in the top, followed by 30 rows more
Error: Call to a member function getType() on null i _photos_access() (rad 103 av /B64/home/upplyser-nu/public_html/upplyser/web/modules/contrib/photos/photos.module)
The Apache error log says
[Sun Mar 29 22:05:53.327489 2020] [proxy_fcgi:error] [pid 62010] [client 90.46.121.131:49936] AH01071: Got error 'PHP message: Error: Call to a member function getType() on null in /B64/home/upplyser-nu/public_html/upplyser/web/modules/contrib/photos/photos.module on line 103 #0 /B64/home/upplyser-nu/public_html/upplyser/web/modules/contrib/photos/src/Form/PhotosUploadForm.php(119): _photos_access('editAlbum', NULL)\n#1 [internal function]: Drupal\\photos\\Form\\PhotosUploadForm->access(Object(Drupal\\Core\\Session\\AccountProxy))\n#2 /B64/home/upplyser-nu/public_html/upplyser/web/core/lib/Drupal/Core/Access/CustomAccessCheck.php(75): call_user_func_array(Array, Array)\n#3 [internal function]: Drupal\\Core\\Access\\CustomAccessCheck->access(Object(Symfony\\Component\\Routing\\Route), Object(Drupal\\Core\\Routing\\RouteMatch), Object(Drupal\\Core\\Session\\AccountProxy))\n#4 /B64/home/upplyser-nu/public_html/upplyser/web/core/lib/Drupal/Core/Access/AccessManager.php(159): call_user_func_array(Array, Array)\n#5 /B64/home/upplyser-nu/public_html/upplyser/web/core/lib/Drupal/Core/Access/AccessManager.php(135): Drupal\\Core\\Access\\AccessManager-...\n', referer: http://upplyser.nu/node/53/photos-rearrange
Comments
Comment #2
nathaniel commentedWhat version of Drupal core is installed on the site? Currently I'm not able to reproduce the error.
In /modules/contrib/photos/src/Form/PhotosUploadForm.php you could alter line 119 to check if $node is not NULL.
Something like this:
That will hide the error, but the page will return access denied.
Were there any other errors when the module was first installed? Was there a custom content type already called "photos"? Are you logged in as user 1 or some other user?
Comment #3
hassebasse commentedHi
Thanks for answering.
Drupal 8.8.4
The first thing I tried was "Are you logged in as user 1 or some other user?" and the answer is that I was not user 1, but some one else, though I had admin rights.
When changing to user 1 everything work as it should.
So it seem that only user 1 can use the module. Do you have any solution for that?
All the best
Hans
Comment #4
nathaniel commentedIt may be a permissions issue then. I would look at all "photo" permissions for the photos node and photos module permissions. I still can't reproduce the issue. There shouldn't be an error though.
Comment #5
nathaniel commentedA couple other thoughts (if you haven't already):
1. Check status report: /admin/reports/status (Rebuild permissions)
2. Clear cache
Comment #6
hassebasse commentedHI
The problem remain.
On top:Plupload does not work
Hans
Comment #7
nathaniel commentedI'm not sure about plupload. But the original issue indicates that the node does not exist (or it can't find it / can't access it for some reason). Normally it should return page not found.
Are there any other access or privacy modules installed?
Or if there is any custom code that modifies access that would be a good place to test.
Comment #8
hassebasse commentedHi
I can't understand why it makes a difference between Admins. User number one works just fine but but why does not other Admins work? How could this be related to rights?
Anyhow, I've delted and reinstalled; but in vain.
Hans
Comment #9
hassebasse commentedHi again
I've found something.
So Admin rights to any other user than n° 1 blocks Photos and give errors. Isn't that odd?
Hans
Comment #10
nathaniel commentedThat is odd. Thanks for keeping us in the loop. Sounds like you are getting close to figuring this one out.
Still the only thing that comes to mind is some kind of permissions issue.
Core (I think you did all of this already):
/admin/people/permissions
/admin/config/people/accounts (the "Administrator role" can be changed here).
/admin/reports/status
/admin/reports/status/rebuild
/admin/config/development/performance (clear all caches)
If you have the group module installed there can be other more complex permissions:
/admin/group/types/manage/{group_type}/permissions
/admin/group/types/manage/{group_type}/permissions/outsider
/admin/group/types/manage/{group_type}/roles/{group_role}/permissions
I'm running some tests with group installed, but still unable to reproduce. If we can figure out the steps to reproduce the issue that would be best. Either way I might add the code from #2 so it doesn't cause a PHP error.
Comment #11
hassebasse commentedI will keep you updated but I have to come back a little later, I've spent too much time with it right now. Give me a few days.
It clearly has to do with permissions because while I was experimenting with the user QUERTY and chanching permissins to the groupe Photos, suddenly it all screwed upp again. For the moment I can't say what I did, but I added some permissins and it chrashed, and I couldn't have it running until I started all from the beginning.
To me, being an amateur who doesn't know how to code, it seem to be some permissions not being compatible with each other. I will see if I can figure it out during the WE.
Comment #12
hassebasse commentedI've found the culprit !!!
I've the setup in Swedish so I will try to find the correct English translation.
When giving permission "Använda administrationssidorna och hjälp" = "Use the administration pages and help" under System, then it goes bad. In my user groupe "Photos" I've multiple times checked and unchecked that box and everytime I check it, it craches.
So "Use the administration pages and help" does only work with User 1 in combination with the Photos module. !!! In other setups the Photos modules thorws errors !!!
Pls let me know when you have fixed this! If you need more info about my setup; pls let me know. If you would be helped by an Admin access to the site, just let me know. For the moment I just use it as a site for learning D8, for a later transfer of my main company site.
Bonne week-end
Hans
Comment #13
nathaniel commentedHey, thanks for the updates. If you don't mind, I will take a look at admin access. You can send it with my contact form:
https://www.drupal.org/u/nathaniel
I'm curious if there is anything else in the logs:
/admin/reports/dblog
Anything like: "User warning: The following module is missing from the file system: ..."?
Have a great weekend!
Comment #14
hassebasse commentedHi
Did you recive the login details? If you want I can arrange to go in by the commande line, but then I need your IP adress.
Concerning my earlier question about Plupload, I used an old library version, 1.6 something. With that one it was very lilmited when it comes to charachters in the file name. Only small letters and _ could be used. After upgrading to 2.3.6 it works as it should, I can use any charachter in the file name.
Hans
Comment #15
nathaniel commentedThanks for sending admin access, that was helpful! After matching some of your site settings and running a few more tests I was finally able to reproduce the issue.
It's something to do with the language settings. I'm not sure exactly what yet:
1. /admin/config/regional/language/detection set "Account administration pages".
2. On user edit (this also happens for user 1 - super admin) select any "Administration pages language" other than no preference.
In the stack trace /admin/reports/dblog/event/68326 (for example) #10 (LanguageNegotiation) is returning access denied for some reason before it reaches the photos access check, so I will add the code from comment#2 above. But, this is still cryptic and doesn't explain why access is denied.
I stumbled on this issue trying to track down the problem from your stack trace:
#2706241: AccessAwareRouter does not respect HTTP method
The patch there does not fix this issue though.
Now the question is why do /edit /photos-rearrange etc. still work fine?
Comment #16
hassebasse commentedGreat that you are making progress! You ended with a question mark, but I hope you don't expect an answer from me as I don't know coding very much at all.
As you have been able to reproduce the issue, can I assume you don't need the access any more?
Hans
Comment #17
nathaniel commentedActually yes, the code from #2 fixes the issue. Odd. Okay, I'll get that submitted here shortly. After that is committed you can install the latest dev version 8.x-4.x dev, clear cache and it should be good to go.
Thanks for your help reporting / debugging the issue!
Comment #18
hassebasse commentedYou are welcome, it was my plesure.
Comment #21
nathaniel commentedNo longer need access thanks!
Comment #22
hassebasse commentedI have upgraded and it works perfectly. Well done!