We have a lot of update functions in core that have been removed partially during the D7 cycle (and are now just stubs) or removed completely (so that the numbering is off).
This does have a real effect on site administrators: When they are updating their site and open the fieldset to see the list of updates, it will be confusing to have incorrect or out-of-date updates listed there, or to see updates with incorrect, out-of-sequence numbers (it will make it look like they did something wrong and don't have a complete set of updates to run). For more explanation, see the first part of my comment at #898520-58: Clean-up the upgrade path: comment and the subsequent discussion.
I think we should fix this throughout core, as has already been done for individual modules in some other issues (e.g. #898536: Clean-up the upgrade path: dblog).
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | no_stubs.patch | 6.09 KB | chx |
| #25 | no-stubs.patch | 24.95 KB | mikejoconnor |
| #22 | no-stubs.patch | 23.09 KB | mikejoconnor |
| #14 | stubs.patch | 4.94 KB | moshe weitzman |
| #12 | stubs.patch | 4.62 KB | moshe weitzman |
Comments
Comment #1
David_Rothstein commentedThis is not critical in the traditional sense, but it is critical based on the same logic that led people to mark #898558: Clean-up the upgrade path: node as critical: If we don't renumber these functions now (before the D7 HEAD-to-HEAD upgrade path is officially supported), we won't be able to do it all.
Comment #2
David_Rothstein commentedHere's a patch. Kind of mindless, but it seems to work :)
Notes:
Comment #3
David_Rothstein commentedThe HEAD to HEAD module already needs an issue as a result of previous rounds of update function renumbering that were committed to core. It will need it even more if this patch is committed :)
The existing issue for the HEAD to HEAD module is here: #909338: Fix the schema versions in the {system} table for dblog and comment update function renumbering (and now locale too!)
Comment #4
moshe weitzman commentedI'm OK with leaving stubs behind with PHPDoc about what they were. I think thats helpful for folks that track HEAD which some sites actually do and we don't want to discourage them. They are the brave canaries.
So, here is a patch which simply omits empty functions. This just required a fancy array_slice() using the reflelction api (which we used here already).
My patch does the plumbing work. Not sure if we need to edit any update functions as well.
Comment #5
moshe weitzman commentedThis one actually works.
Comment #6
moshe weitzman commentedsigh
Comment #7
David_Rothstein commentedInteresting. Although if you look at my patch, I'm not sure I removed anything that wasn't just pure cruft at this point - i.e., probably long past the point where it was useful to anyone. And it's consistent with some of the cleanups that have gone in elsewhere, for individual modules.
Also, if we don't do something like this then we'll have weird gaps in the update function numbering that makes it look like core developers don't know how to count :)
Perhaps it would make sense to combine the two approaches, though.
Comment #8
moshe weitzman commentedYeah, probably a combination of both.
Going forward, I'm fine with gaps that look like "core developers don't know how to count". Thats really a symptom of we don't know what we are doing.
Comment #9
chx commentedIt's completely fine if the list just contains arbitrary numbers IMO. Noone cares :)
Comment #10
catchYeah I don't see a problem with that either.
Comment #11
moshe weitzman commentedDavid's patch no longer applies cleanly. I went ahead and combined my patch with a cleanup of existing stub functions to match our proposed convention of keeping them around with Doxygen that explains where they went.
Comment #12
moshe weitzman commentedWoops. Still tripping up with git sometimes.
Comment #13
chx commentedInstead of rereading the file again and again what about a static $stub = TRUE and use getStaticVariables of the already ran Reflection?
Comment #14
moshe weitzman commentedHere is a patch which only calls file() when the .install file changes. I added some comments as well. I spoke with chx on IRC and he is OK with this approach.
Comment #15
chx commentedYes this is a nice patch.
Comment #16
David_Rothstein commentedHm, this looks a little like magic, though... Dumb question: Is there a way to check if the function body is empty of code (regardless of whether or not it has comments in it)? Seems like that's ideally what we want to check.
Also, if the consensus is to not bother renumbering the functions, then I think this isn't critical anymore (since it can be done at any time).
Comment #17
chx commentedDavid, after tonight you think you can demote criticals? Especially one that's ready despite you two doing everything to kill the morale of anyone trying to fix criticals? Get real.
And no, there is no way for that short of tokenizing the files which is too slow.
Comment #18
dries commentedCommitted to CVS HEAD. Thanks.
Comment #19
David_Rothstein commentedHm, I realized that this actually introduces a worse bug than it fixes, because it introduces a mismatch in the reported number of updates to be run (which everyone sees, not just the 2% of people who open up the fieldset to look at the details).
For example, updating from Drupal 6 to Drupal 7 it tells me "118 pending updates" before I run them, but then the progress bar shows 130 updates once they actually start running - the difference being due to the stub functions. (In an edge case, this could lead to even more confusion - if somehow you wind up with a site where the stub updates are the only ones that need to run, then your status report page will keep telling you your database is out-of-date but when you go to run updates it will tell you that you don't have any.)
I think there is no simple way to fix that, so probably we should roll this back and try something else. I think it's simplest if we just delete the obsolete functions. I don't think there's anywhere else in the code where we deliberately keep old, useless functions around, is there? So no need to do it here. And they're still available via CVS, of course, for developers who want to see the history.
Does that sound right? I'm not proposing renumbering the update functions anymore as I did originally (as it seems like most people think that's too much code churn now), just removing the 10 or so that are empty, as the simplest way to make them not appear anymore.
***
By the way, not that it matters much with the above plan, but I don't understand why tokenizing the file would have been necessary to find out if the function body only consists of code comments? (The code already defines $body as an array containing all lines of code in the function, so it seems like we could just look at the individual lines in that array and see which ones began with a comment marker, etc.)
Comment #20
damien tournoud commentedHuh. That makes very little sense to me.
This is our LAST CHANCE to renumber and clean up the installation process, as we should have done *long ago*.
Let's revert this. There is no reason to add more complexity to the upgrade process, while we can (and should) just renumber the functions.
Comment #21
mikejoconnor commentedComment #22
mikejoconnor commentedI reversed the patch in comment #14, removed the stub functions, and renumbered. Also updated the update_dependencies to match the new function names. It would be great if someone could verify that everything matches.
Comment #24
moshe weitzman commentedI'm fine with revert if that’s what folks want.
Comment #25
mikejoconnor commentedApparently I missed a dependency, lets try this.
Comment #26
David_Rothstein commented@mikejoconnor, thanks, but your patch file looks much smaller than my patch from comment #2. Did you deliberately leave parts of it out?
***
I'm still theoretically in favor of doing a full renumbering, but most other people above sounded opposed. Maybe we should come to consensus before writing more code. The choices are:
a. Revert #14 and just remove the stub functions (but leave the numbering incorrect).
b. Revert #14, remove the stub functions, and renumber the remaining ones.
Note that to do (b) properly, we also need some changes along the lines of those in my original patch such as these:
which might be considered a minor pseudo-API change at this point.
Comment #27
flevour commentedHow can we help on this issue? It seems to be stuck waiting opinionated comments from core developers on a/b choices in #26.
Comment #28
catchI like (a). I really don't see what the point of renumbering the functions is, it's purely cosmetic.
Comment #29
damien tournoud commentedFor the sake of getting a beta out, I can settle on just nuking the stub functions without renumbering.
Comment #30
chx commentedLet's do that then.
Comment #31
dries commentedYes, let's do (a). Committed to CVS HEAD. Thanks.