I found out that there is an issue with the naming conventions of the post update. This issue occurred in the social installation profile. So basically we have the profile which is called just 'social'. On of the modules we've added is called 'social_post'. It's for posting on streams / profiles.
Now someone added an update hook to the social_post module: 'social_post_update_8001'. The update system showed the information like this:
The following updates are pending:
social_post module :
8001 - Update social_post existing content.
social module :
Update social_post existing content.
Do you wish to run all pending updates? (y/n):
So it basically recognised the update as being from the social_post module, but it also recognised it as a post update of the social profile. The main issue is that is stays there as an update forever. The social_post module is updated with the version number, but the profile keeps thinking it has a post update still open.
As a workaround we've moved the update hook to another module which fixed the issue.
Comments
Comment #2
jochemvn CreditAttribution: jochemvn for Open Social commentedLookin again, I think the issue is more that the social distro thinks that an update hook in social_post.install is part of its own social.install , which it's in fact not
Comment #3
KingdutchIt took a bit of digging. I believe this has the following cause but I'm unsure about a correct fix:
In
DbUpdateController::selection
both update and post_update functions are loaded one after another (in that order). For post_update functions the functionUpdateRegistry::getPendingUpdateInformation()
function is called which makes a call toUpdateRegistry::getAvailableUpdateFunctions()
. That function will return an array of functions based on the pattern/^(?<module>.+)_' . $this->updateType . '_(?<name>.+)$/
with$this->updateType == 'post_update'
. This causes the now loaded functionsocial_post_update_N
to register as an available update for thesocial
module.A way to fix this would be to add some inspection using the ReflectionFunction class to check if the update function is from the correct file (hook_update_N from module.install and hook_post_update_N from module.post_update.php).
Comment #4
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedThis architectural flaw affect all new Opensocial versions. I recommend to rename module social_post to other name. It's a relatively easier way to avoid problem.
Comment #7
basvredelingMoved from stale core issue to open social itself.
Comment #8
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedThis remains an issue as of 10.0.2
Comment #9
andrimont CreditAttribution: andrimont commented@basvredeling
As the issue block any update that request a database update this can become critical and @ carlos-miranda-levy indicate that the issue remains as of 10.0.2, is there a workaround ?
Can we by-pass this update 8801 ?
Thanks.
Comment #10
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedSee temp fix in: https://www.drupal.org/project/social/issues/3177521
Comment #11
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedThe issue remains as of 10.0.3.
We keep referring to closed issues.
Can the op of the patch on 3177521 please post it here for review and so that some action can take place on this matter.
The isue still remains.
Every fresh install returns the same error when trying to update.
Since there is no review or verification of the github posted patch, it's not being tested or validated, probably not even considered for inclusion -- there is no one assigned to this issue if you check.
It is still not clear what would the best course of action to take now:
https://github.com/vredeling/open_social/commit/d95b83412f21ae2aabe6fd9a...
Any advice on pros-cons?
I'm currently dealing with it after install or update and before running drush updb, otherwise it fails:
Thanks.
Comment #12
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedThis issue remains on 10.0.4
Still no best recommendation on how to deal with it.
The existing fixes are of course erased when updating the distribution code and the problem returns.
I'm currently dealing with it by running the following after install or update and before running drush updb, otherwise it fails:
But I'm still not sure if this is the best course of action.
This issue renders the distro unreliable and unsafe for anyone not willing to edit the code with an adventurous spirit.
Can someone provide a sound, trusting advice on how to deal with it until we get a fix?
Comment #13
Harlor CreditAttribution: Harlor at erdfisch commentedAs a workaround I created new sub-module that contains the social_post update hooks.
https://github.com/goalgorilla/open_social/pull/2281
Patch: https://github.com/goalgorilla/open_social/commit/a50e06b30109ac9e56399d...
Comment #14
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commented#13 seems to work for now and at least up to 10.0.5.
Comment #15
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedI'm concerned, as the patch proposed #13 seems to leave updates out.
I just did a fresh install of 10.0.5, followed by composer update.
The Status Dashboard reported that there were database updates available, so I ran drush updb and got this output:
I restored the database from the backup I made previous to attempting the update, applied the patch from #13 and ran drush updb again, only to be greeted with the news that there were no updates available!!!
So were 8804, 8901 and the other updates not valid/necessary updates?
Comment #16
bmango CreditAttribution: bmango commentedThanks very much @Harlor for the patch in #13. It seemed to work well for me. However, I ran it on 10.0.7 and hoping this won't cause any issues.
Comment #17
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedThis was an update of social 7 to social 8. I have not tried it on social 10.x
https://www.drupal.org/project/social/issues/3177521#comment-14138201
Hello all.... I could not get the updates to happen from the command line using drush.
They did work in the UI http://site/update.php did work
Comment #18
ronaldtebrake CreditAttribution: ronaldtebrake as a volunteer and at Open Social for Open Social commentedFirst of all thank you for all the work and input.
We are trying to still get this in to core, it's not an Open Social architectural flaw, it is an issue with the brittle way these hooks are being used and named.
You can see the work in progress in core here: https://www.drupal.org/project/drupal/issues/3236316
Our aim here is to make Drupal more flexible first, if it does not get accepted in there we will likely come up with our own way.
Creating a new module to deal with these update hooks is not going to be something we can work with, maintaining separate modules for this is not the way to go. It is also very prone to issues where the configuration and schemas are actually not part of that module but social_post itself still.
If we could get some reviews for the issue in core, to get some traction there that would be great!
You can find the merge request in there https://git.drupalcode.org/project/drupal/-/merge_requests/1215 where all the latest code, tests and fixes have been added.
Comment #19
ronaldtebrake CreditAttribution: ronaldtebrake as a volunteer and at Open Social for Open Social commentedComment #20
ronaldtebrake CreditAttribution: ronaldtebrake as a volunteer and at Open Social for Open Social commentedhttps://github.com/goalgorilla/open_social/pull/2508 you can find the PR in OS here :).
Comment #21
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedThanks for the writeup: @ronaldtebrake
After clicking through to the issue, I am left with a few questions.
I understand that you want to introduce a way in core for core to help determine if there is a conflict. I am all for it.
but there is a conflict now between open social social_post and drupal.org social post. How would what you outlined above deal with that.
Wouldn't the solution above just send an error message that there is a conflict? Is there an automated way to fix it?
For Open Social could all elements be prefixed with "os_" or just specifically social_post? So social_post would become os_social_post or it could be os_post.
Thanks for all that you do for the Open Social community.
Comment #22
ronaldtebrake CreditAttribution: ronaldtebrake as a volunteer and at Open Social for Open Social commentedNo problem, thanks for your input @SocialNicheGuru, let me try to answer your questions.
It wouldn't unfortunately, that is something the related issue #3167625: Deprecate/replace hook_update_N() in favor of an object-oriented approach similar to Laravel migrations would be able to deal with. Having it's own namespaces instead of using module naming / file naming conventions is a bigger architectural approach to this and would likely be taking a while to implement. My solution, in a nutshell, just says, post_update hooks should live in a post_update.php file, regardless of how you have named your module.
We have been thinking about this for a while now, but it isn't as straightforward as it sounds. Migrating that is very BC breaking, as people might have used things like:
$module_handler->moduleExists('social_post')
, all the alter hooks need to be rewritten, dependencies will break etc.And it's very brittle right, we can't be sure somebody won't start creating an os_post or os_social_group module either. Even if is very edge case that would likely happen, Drupal allows it. So it feels like we are chasing something that will never be fully fixed, if we don't fix it in Drupal Core itself.
See f.e. https://www.drupal.org/project/os_base which will conflict if we are going for a os_base module.
Comment #23
navneet0693 CreditAttribution: navneet0693 as a volunteer and at Open Social for Open Social commentedComment #24
navneet0693 CreditAttribution: navneet0693 as a volunteer and at Open Social for Open Social commentedThe applied patch will land in Open Social10.3.x and above.
Comment #27
vishtg CreditAttribution: vishtg commentedThe issue is not fixed in 10.3.1
I am still getting it. I understand it will be instead fixed in drupal core
Thanks