Followup #2999721: [META] Deprecate the legacy include files before Drupal 9
Problem/Motivation
Avoid handling of update.in file include and leave that task for autoloader.
This ticket can cover
update_already_performed
update_retrieve_dependencies
Additional scope added back to this issue
update_invoke_post_update
update_get_update_list
update_resolve_dependencies
update_get_update_function_list
update_build_dependency_graph
update_is_missing
Proposed resolution
Converts the remaining functions of update.inc to the DatabaseUpdate class.
Remaining tasks
User interface changes
none
API changes
Deprecation of the update_* functions from update.inc file.
New Update class.
Data model changes
none
| Comment | File | Size | Author |
|---|
Issue fork drupal-3012523
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
volegerFirst iteration
Comment #3
volegerComment #4
goodboy commentedChange call update_do_one to Update::doOne in triggerBatch()
Comment #5
volegerreplace
'Update'withUpdate::classto pass the full class name to the callable array.Comment #6
goodboy commentedChange to Update::class
Comment #7
volegerAttached interdiff for #4 and #6.
Replaced rest off the calls and updated docs.
Let's see if we ready for the further tasks.
Comment #8
goodboy commentedAdded deprecations
Comment #9
volegerAdd initial legacy test
Comment #10
goodboy commentedFix deprecations errors
Comment #11
goodboy commentedAdd legacy tests for update_fix_compatibility() and update_check_incompatibility()
Comment #12
volegerInterdiff
Comment #13
volegerThis functionality depends on the
systemmodule. Let's enable the module in the tests.Comment #14
goodboy commentedAdd tests for 3 functions. Intediff has #13 and #14.
Comment #15
goodboy commentedAdd new test methods and fix exists methods
Comment #16
goodboy commentedAdd new test methods and fix exists methods
Comment #17
goodboy commentedAdd new test methods and fix exists methods
Comment #18
volegerFixed tests.
Also figured out that update_replace_permissions() used immutable configs to update them later. So I had fixed this issue too. Looks like there are no usages of that function and that function is not covered with tests.
Comment #19
volegerAll functions covered in legacy tests. One more thing that I changed in the tests is the update number to lower and not existent to avoid the potential match with future update number.
Comment #20
volegerComment #21
volegerComment #22
andypostInitial review, thanks for great work!
- lots of
\Drupal::calls inside loops - needs refactor- probably this class needs split into static methods (batch related) and service to properly inject dependencies, guess multiple classes
- usage needs better analysis, if there will be a service it needs injection
- naming - requirements could use "get" or "build"... like #2620304: htaccess functions should be a service
will check deeper later
All this dependencies makes me think about service, OTOH there still procedural things used that means it will be hard to test this new class
Comment #23
volegerJust reroll.
Comment #24
volegerComment #25
volegerAdd new usage.
Comment #26
volegerUpdated docs and removed include of the file.
Comment #27
andypostChecked new class and I really like to split static methods from real service
Also new class should not use
module_load_include()and others functions which supposed to be deprecated in other "include conversions" - so better to add protected methods for them with @todo to related conversion issueAll this services & functions will need injection means this class can't be static
Comment #29
andypostIt needs reroll but maybe postpone it on other conversions?
Comment #30
volegerGood option. In that case, we need to clarify the issues which the issue have to be postponed on.
Comment #31
andypostI mean this 2
- #2124069: Convert schema.inc to the update.update_hook_registry service (UpdateHookRegistry)
- #2908886: Split off schema management out of schema.inc
Comment #34
andypostIt slightly related to #2908886-65: Split off schema management out of schema.inc
Comment #35
andypostComment #36
andypostComment #37
andypostI filed separate issue to remove the function without replacement #3150726: Deprecate update_check_incompatibility as unused
Comment #38
andypostThe next hunk to decouple is
update_system_schema_requirements(),update_check_requirements(),_update_fix_missing_schema()- the only usage found is\Drupal\system\Controller\DbUpdateController::handle()so this requirements could be moved to system moduleEDIT there's
\Drupal\Core\Updater\Module::getSchemaUpdates()so part of conversion could be moved to extension listsComment #40
longwaveOpened #3210900: Deprecate update_set_schema() for removal as I don't think that function is needed at all.
Comment #41
andypostRe #38 - there's usage of
update_check_requirements()in drush https://github.com/drush-ops/drush/blob/dbdb6733655231687d8ab68cdea6bf9f...Probably better to file separate issue as well
Comment #43
volegerPostponing this issue due to:
- #697946: Properly deprecate module_load_include() and move it into \Drupal::moduleHandler() service
- #2010380: Deprecate module_load_install() and replace it with ModuleHandler::loadInstall
- #2932518: Deprecate watchdog_exception
Comment #45
volegerComment #46
volegerComment #47
andypostComment #48
danielvezaAccording to #43, this was postponed on a number of other issues. All those issues are now committed, so I think work can continue on this one.
Comment #49
andypostPatch needs update as there is only left - update requirements and batch to run'em
Comment #50
elberHi @andypost can you give more details about it ?
Comment #51
volegerUpdating the patch
Comment #52
volegerComment #53
andypostNow everything goes to 11.x https://www.drupal.org/about/core/blog/new-drupal-core-branching-scheme-...
Comment #55
volegerOpened MR, rebased initial work against 11.x branch. Ready for the review.
Comment #56
smustgrave commentedReran the tests and the 1 failure seems legit.
Did not review.
Comment #57
volegerAddressed review comments
Comment #58
smustgrave commentedWonder if the CR needs updating searching for
update_fix_compatibility
update_check_incompatibility
update_set_schema
update_replace_permissions
I don't find them in updates.inc maybe deprecated and removed already?
Comment #59
andypostAdded suggestion and tests should compare result of old vs new function calls
CR needs clean-up as since 8.7 core already deprecated and removed some functions, for example via related
Comment #61
quietone commentedI removed the todo in \Drupal\Core\Updater\Module::getSchemaUpdates because it didn't have an associated issue. Also, I can find no usages of the method either. That needs some investigation.
Comment #62
quietone commentedAh, there is an issue for that. #3050578: Remove unused function getSchemaUpdates()
Comment #63
quietone commentedThe MR is updated and tests are passing. Time to get another round of review.
Comment #64
quietone commentedI have updated the CR,
Comment #65
smustgrave commentedLeft some comments on the MR.
Comment #66
quietone commentedI am not sure about the testing being asked for. The testing being asked for is to compare result of the old function execution with the replacement result. However, there are no explicit tests of this legacy code. Any testing of it is implicit in other update tests which rely on this code. And we have all tests passing and I think that is the best we can do.
Then, that means that UpdateLegacyTest is only testing that the exception is thrown. I am not sure we need to do that in this case either. So, I discussed this with catch and he did say that UpdateLegacyTest can be removed.
Therefor, I have removed that test.
Comment #67
smustgrave commentedAll green and my feedback was addressed by #66, so marking this.
Comment #68
xjmThis will be good to clean up. That said, though, the diff is massive --
11 files, +868, −464. That is a total of 1332 changed lines, five to ten times as many lines as a reviewer can effectively review. (And it's exponential decay -- that means having this all lumped into one change set means a reviewer will find 1-5% of the bugs they would find if the scoping were better.) Especially since it's moved lines, which git does not deal well with.Is there any way we could split this up into stages?
Comment #69
smustgrave commentedI see your point @xjm but think the high number of changes is due to whole functions being moved. But if it's a blocker I imagine each function could be broken out to individual tickets.
Comment #70
xjmMoved functions are harder to review than changed ones. So I really would suggest splitting this into logical steps. What has to happen first? What's second? Etc. You can use the original MR to make sure everything will still end up in the same final state, but a little
git add -petc. could make this easier to get in.Comment #71
smustgrave commentedOpened
#3391680: Convert the update.inc file functions to a class pt1
#3391683: Convert initial functions in update.inc file to a class
#3391684: Convert the update.inc file functions to a class pt3
#3391685: Convert the update.inc file functions to a class pt4
3 functions per ticket.
Updated this ticket to include the last 3, if the MR could be updated for that.
Comment #74
mradcliffeupdate_replace_permissionswas removed in #3143605: Remove unused and broken update_replace_permissions(), which always throws an exception.Comment #76
mradcliffeThe remaining functions after #3391683: Convert initial functions in update.inc file to a class are 12 files changed, 677 insertions(+), 408 deletions(-), which is a bit large, but reviewable.
Comment #77
mradcliffeComment #78
nicxvan commentedBlocker is in!
Comment #79
mradcliffeI interactive rebased to remove the squashed commit from #3391683: Convert initial functions in update.inc file to a class, and then resolved the conflicts by re-adding the promoted constructor arguments for UpdateRegistry and ModuleExtensionList.
Comment #80
nicxvan commentedI think this is almost ready, one question about the constructor.
I pulled it down and all references to the functions have been replaced except a couple of comments in the file that is being deprecated.
I also used the zebra git command to compare and all changes line up as expected they are faithful conversions.
I think we just need to move the new arguments to the end and add BC.
Comment #81
nicxvan commentedNevermind about the constructor comment, that class is new and isn't in a release yet, as long as we get it in for 11.5 is clean!
Comment #82
nicxvan commentedAlso forgot to mention I checked all of the deprecation messages and versions and they look right.
CR looks good too.
Comment #83
mradcliffeSeems like an unrelated random functional javascript failure in
core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.phpComment #84
mradcliffeRebased and the random FunctionalJavascript test failure went away. Still RTBC.
Comment #85
mradcliffe@larowlan ran this passed release managers, and we're no longer need able to make 12.0.0/11.5.0 for this so we need to do the following:
Comment #86
mradcliffeOne task down, change record is split and set for 12.1.0 and 12.1.x
Comment #87
nicxvan commentedI added suggestions for the version and cr change!
Comment #88
mradcliffeBack to Needs review.
Comment #89
nicxvan commentedMoving to needs works cause technically we still need bc for the two new arguments, here is an example: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/user/...
The changes made look good other than that.
CR is good too.
Comment #90
mradcliffeArguments are now nullable with a trigger_error for BC.
Comment #91
nicxvan commentedPerfect thanks!
I think this is ready again!
Comment #92
larowlancouple of things in the MR - thanks
Comment #93
mradcliffeGoing back to Needs review first before RTBC.
Comment #94
nicxvan commentedAll feedback has been addressed!