Closed (fixed)
Project:
Flag Lists
Version:
4.0.0-rc2
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
24 Feb 2022 at 22:50 UTC
Updated:
31 May 2023 at 09:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sl27257Do you have the possibility to check if the -dev has the solution for this? If so I will push that ASAP.
BR
/Thomas
Comment #3
npcoder commented@sl27257: I uninstalled the flag_lists:^4.0@RC and reinstall flag_lists:4.0.x-dev@dev using composer.
I got the same error.
Comment #4
sl27257That you don't see any difference with the -dev indicates that you should have seen some kind of error earlier...
What I mean is that (sorry for the joke) "this error can't occur". So there must be something wrong with the database, because a Flagging Collection must have an owner. And checking for the owner should be a standard procedure.
Did you see any error when upgrading to rc2?
Have you removed any users from your installation?
The next step to trace your error would be to dig into your database to understand why there is a problem with the user. Do you have the possibility to run MySQL code?
/Thomas
Comment #5
tlwatsonI'm getting the same error on the Modules page after upgrading from 4.0.0.-rc1 to 4.0.x-dev (to get past the getUsername error for D9).
In fact, I'm getting a whole swath of errors when upgrading to dev. When I ran drush updb I got:
Call to a member function id() on null
/admin/modules :
Error: Call to a member function id() on null in Drupal\flag_lists\Permissions\FlagListsPermissionHandler->getPermissions() (line 52 of modules/contrib/flag_lists/src/Permissions/FlagListsPermissionHandler.php).
/flagging_collection :
Error: Call to a member function label() on null in Drupal\flag_lists\FlaggingCollectionListBuilder->buildRow() (line 80 of modules/contrib/flag_lists/src/FlaggingCollectionListBuilder.php).
/admin/structure/flags :
Error: Call to a member function getDisplayName() on null in Drupal\flag_lists\FlagListsFlagListBuilder->buildRow() (line 112 of modules/contrib/flag_lists/src/FlagListsFlagListBuilder.php).
Obviously for the time being I won't be using dev, but I've got at least one non-functioning admin page as it is...
It is very likely that users got deleted, but flags and flag lists/collections ought to be deleted along with them. If they do now but perhaps that was not the case in the past, could you provide a script to run for us to clean out orphaned flag list data? (I'd try to do it in the DB myself but I'd be nervous about missing something unless there's a proper delete/cleanup method).
Comment #6
sl27257I have now been able to reproduce the original error described. I did this by removing a user. There are four different possible ways to remove a user. Where I am using this module the heaviest the policy is to only inactivate the users, not to remove them. So I have never thought of this...
What is missing is a hook_ENTITY_predelete that remove all flagging collections belonging to a user when the user is deleted. There has never been such a functionality but of course there should be. There are two way of doing it, which is selectable when removing the user, either they are deleted or they are move to user 0, the anonymous user.
For the completeness I will also add an update in the code that fixes the orphaned flagging collections, flags and flag list items. That is the proper way to do it.
Regarding the errors in #5 the two first doesn't seem to be related to this. The the third definitely is.
Comment #7
sl27257Here is a "complete" patch. Please check it out!
It fixes the removal of users. It also contain two updates for removing orphaned Flag List Items and Flagging Collections due to removed users.
Comment #8
sl27257Hmmm, forgot to remove some debug dpm's... New try...
Comment #9
sl27257Comment #10
npcoder commentedThank you @sl27257 for the brief explanation of the issue. Now, I remember that I might have deleted some users.
Though I've not tested the patch you provided, I guess it must work as you have clearly described the cause of the issue. I will let you know.
Thank you!
Comment #11
npcoder commented@sl27257: The error still exists after applying your patches.
These were the errors and patches I made:
Error #1:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on null in flag_lists_flag_action_access() (line 244 of modules/contrib/flag_lists/flag_lists.module).
Solution:
L:243
if ($flagList->getRelatedFlag() !== NULL) {
...
...
}
Error #2:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on null in Drupal\flag_lists\FlagListsFlagLinkBuilder->build() (line 88 of modules/contrib/flag_lists/src/FlagListsFlagLinkBuilder.php).
Solution:
L: 88
if ($flagList->getRelatedFlag() !== NULL) {
...
...
}
I have attached the patch file too. After the above changes, my project ran.
Comment #12
npcoder commentedAfter #11 fix, I again got another issue
I have added a patch for this issue.
Comment #13
npcoder commentedComment #14
sl27257A question: Did you execute the update 8005?
Comment #15
npcoder commented@sl27257 Yes I had.
Comment #16
sl27257Unfortunately your patches doesn't fix the problem. They only mask it. The basic problem, which is an error in the database still is there.
I have some guesses what is causing them for some of the cases.
Error #1:
This I hope is fixed by #3257955: Error: Call to a member function isSyncing() on null in flag_lists_actions_flagging_collection_presave() (line 71 of modules/contrib/flag_lists/modules/flag_lists_actions/flag_lists_actions.module). This is NOT in rc2 but requires the dev. The easiest way to check it would be to disable the sub-module for action which is possible with the -dev. Are you using the actions?
For the others they might be related to #12 last sentence in #3257955: Error: Call to a member function isSyncing() on null in flag_lists_actions_flagging_collection_presave() (line 71 of modules/contrib/flag_lists/modules/flag_lists_actions/flag_lists_actions.module). Disable the sub module action and then re-enable it if you need it.
I would like to take it from there and see if they still remain.
/Thomas
BTW: Let me know if I shall make a "complete" dev-module with everything in it. There are some important issues missing currently.
Comment #17
npcoder commentedThanks, @sl27257 for the response.
I'm sure it's related to the database table, where I might have deleted some content that might be linked with the flag_lists. Once I have turned the tables using a DB tool (DBeaver).
I added those patches which I created and it worked.
Yes, that would be great, creating a dev-module with everything in it, and let's give it a try.
Thanks.
Comment #19
sl27257@npcoder!
I have assessed your corrections. From a user point the work because the error messages are hidden from the end user. But they mask a severe error in the database, which shouldn't (must not) be there and that will affect the behavior of the module. So that is why I don't have included them yet. A compromise, as I see it, one solution would be to add your code but instead of not executing the code add a error message to the log, for the administrator.
Either
"This error should not be here"
(old style Unix message :) )
"You have an error in your database, please investigate"
(more correct wording)
What are your comments to this?
BR
/Thomas
Comment #21
sl27257Two more places found where an empty related Flag protection could be needed.
Comment #23
sl27257