Followup #2999721: [META] Deprecate the legacy include files before Drupal 9

Problem/Motivation

Avoid handling of update.inc file include and leave that task for autoloader.

This ticket will cover
update_check_requirements
update_do_one
update_system_schema_requirements

Proposed resolution

Convert functions of update.inc to a class and service.

Remaining tasks

Re-review

User interface changes

none

API changes

Deprecation of the above update_* functions from update.inc file.
New DatabaseUpdate class and database.update service.

Data model changes

none

Issue fork drupal-3391683

Command icon 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

smustgrave created an issue. See original summary.

smustgrave’s picture

https://www.drupal.org/node/3210925 removed update_set_schema

also crediting quietone for doing all the work.

smustgrave’s picture

Status: Active » Needs review

Would be nice to get this in first before the others to avoid merge conflicts in the new Update.php file.

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Needs framework manager review

This is presumably mostly just removed code, so I focused on the top-level naming and documentation. Few things to fix there.

This kind of issue would normally require subsystem maintainer review, but the database update system does not have a maintainer. So, in lieu of that, it gets escalated to framework managers. Thanks!

larowlan’s picture

Left a review

Prashant.c made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

mradcliffe made their first commit to this issue’s fork.

mradcliffe’s picture

Issue summary: View changes
Status: Needs work » Needs review

I finished the rebased and then worked on fixing phpcs and phpstan issues, and resolving review comments

I think the only comment that is pending is a question about making the doOne method static. This would require no longer calling object methods in that method and using static \Drupal calls.

I'll set this to Needs review, but it may not pass tests.

nicxvan’s picture

Status: Needs review » Needs work

A couple of failures and comments.

I think one call was missed.

Why would we make doOne static?

mradcliffe’s picture

Status: Needs work » Needs review

I fixed the update service and the suggestion from @nicxvan. Then I added a static method to instantiate the class for batch callbacks, and changed the doOne method to protected per @larowlan's review in 2024.

I think the other review comments can be resolved once someone reviews them.

mradcliffe’s picture

Status: Needs review » Needs work

More test failures so back to Needs work.

nicxvan’s picture

I'll take a look but there are some relevant test failures.

mradcliffe’s picture

Status: Needs work » Needs review

I fixed the kernel test. Then on self-review, I found some more missing doc block issues from where I picked up the merge request, and fixed those too.

FunctionalJavaScript tests are randomly failing throughout core.

Should the doc blocks in update.inc be truncated to avoid duplicate information?

mradcliffe’s picture

Issue summary: View changes
mradcliffe’s picture

Issue summary: View changes
dcam’s picture

Status: Needs review » Needs work

I found some things that need attention. I left comments on the MR.

I didn't leave an MR comment, but I don't think the new service needs an ID, database.update. I feel like I hardly ever see service IDs being added anymore, but checked recent commits to core.services.yml and apparently it does happen. Those may be instances where a class is associated with more than one service - I didn't check. I don't have an opinion about it. It just struck me as being unusual. I also noted that the MR inconsistently gets the service from the container by both its ID and class name. Again, it isn't really a problem, so I'm not going to insist on changes. I just wouldn't do it if I were authoring the changes.

mradcliffe’s picture

Thanks for the review, @dcam. I applied your suggestions to the MR.

I was reviewing the use of ClassResolver via \Drupal::classResolver(), and it suggests being used for procedural code only, which I haven't done. I think update.inc should use that rather than ::service, but should any non-static functions also use that? It seems to only be used in Hooks and not even tests. I think we should probably stick with \Drupal::service() and the id for now.

kim.pepper’s picture

ClassResolver is useful to instantiate classes that aren't services.

nicxvan’s picture

Made a bunch of comments before remembering @dcam already covered some of them here sorry.

We can avoid all of the class resolver stuff I think with my other comments and suggestions see https://www.drupal.org/node/3570904

Please let me know if you have any questions!

I also commented on the pt 3, I think we do this in two issues let's see if we can add another function or two here so this and the next issue handle update.inc 50 - 50.

Thanks for taking this on!

Edit: I think there is some confusion here about using classresolver vs service.

In the deprecated functions in all cases you should use ::service we don't need the factory or a static callback for the batch.

The batch callback method does need to be public, please ping me in slack if you need any clarification!

kim.pepper’s picture

Status: Needs work » Needs review

NR for the 3 remaining open comments.

mradcliffe’s picture

Issue summary: View changes

Thank you for the review and clarification, @nicxvan and @kimpepper. I understand. The newish CallbableResolver handles the previous issue of serializing the entire class in batch.

Updated issue summary to remove update_set_schema that was removed in #3210931: Remove deprecated update.inc functions.

nicxvan’s picture

Thanks guys, I resolved the two open comments on the MR since they weren't blocking just general comments I noticed.

Also I took a closer look, I think I'm going to retract my request to add another function here to even it out so we can do it in two issues.

This issue does 4 functions, there are 7 remaining functions, two of them are one line functions leaving 5 substantial functions. They have some complexity but I think we can fit them in the final issue.

I'll try to finish my review of this.

nicxvan’s picture

I think the CR needs an update.

Also added a few more suggestions for the deprecation messages and comments.

I think this is ready once these are applied and the CR is updated.

kim.pepper’s picture

Updated the CR

mradcliffe’s picture

I applied the comment suggestions via GitLab, but left the deprecation message suggestions for further discussion.

mradcliffe’s picture

Based on discussion in Slack, I updated the change record to have multiple tables for a table per issue with a jump menu. I am not sure what the issue split is going to be so I kept the functions divided at the current open issues (4 tables). And then added a code example section.

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

CR looks much better thanks guys!

The failure looks random
Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest

This looks great now, it's a pretty straightforward move over, the location and namespace looks right.

mradcliffe’s picture

Title: Convert the update.inc file functions to a class pt2 » Convert initial functions in update.inc file to a class

Renaming this so it's not as confusing what "pt2" means.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mradcliffe’s picture

Status: Needs work » Reviewed & tested by the community
needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mradcliffe’s picture

Status: Needs work » Needs review

I rebased to incorporate #3561302: Register equivalent updates on site install that was added to core yesterday. Setting to Needs review for someone to review that those changes made it correctly into the DatabaseUpdate before setting back to RTBC.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

I checked the change ported from #3561302: Register equivalent updates on site install and it was copied correctly. Thank you for doing the rebase.

amateescu’s picture

Status: Reviewed & tested by the community » Needs review

Reviewed and proposed a few code change on the MR. They're all mostly minor, so feel free to self-RTBC after reviewing/applying them.

mradcliffe’s picture

Status: Needs review » Reviewed & tested by the community

I re-reviewed my rebase + fixes to update.inc to DatabaseUpdate to check if there were any other issues. Setting this back to RTBC based on #37.

  • amateescu committed 0db31a32 on 11.x
    task: #3391683 Convert initial functions in update.inc file to a class...

  • amateescu committed 5ac5b9c3 on main
    task: #3391683 Convert initial functions in update.inc file to a class...
amateescu’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 5ac5b9c39bd to main and 0db31a323b1 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.