Problem/Motivation

Based on the #2999721: [META] Deprecate the legacy include files before Drupal 9 we can remove already deprecated include files and all related calls to the files or functions.

Proposed resolution

Remove related code from the codebase.

Remaining tasks

  • Remove include files that contains already deprecated and replaced API.
  • Remove related legacy test code.

User interface changes

-

API changes

Legacy API removal from deprected include files.

Data model changes

-

Release notes snippet

Comments

voleger created an issue. See original summary.

voleger’s picture

StatusFileSize
new127.07 KB

Just trying to remove first 4 fully deprecated files with Legacy API.

  • core/includes/database.inc
  • core/includes/entity.inc
  • core/includes/tablesort.inc
  • core/includes/unicode.inc
voleger’s picture

StatusFileSize
new128.6 KB
new1.31 KB

Missed a few includes.

voleger’s picture

StatusFileSize
new128.34 KB
new1.62 KB

Looks like we need to finish deprecation of user_delete_multiple (and user_delete).
The deprecated code shouldn't use deprecated API. I'll fill followup issue.

voleger’s picture

Title: Remove deprecated include files from Drupal 9 » Remove deprecated legacy include files from Drupal 9
voleger’s picture

Version: 9.x-dev » 9.0.x-dev

The 9.0.x branch will open for development soon, and the placeholder 9.x branch should no longer be used. Only issues that require a new major version should be filed against 9.0.x (for example, removing deprecated code or updating dependency major versions). New developments and disruptive changes that are allowed in a minor version should be filed against 8.9.x, and significant new features will be moved to 9.1.x at committer discretion. For more information see the Allowed changes during the Drupal 8 and 9 release cycles and the Drupal 9.0.0 release plan.

voleger’s picture

#3087546: Remove deprecated entity manager covers entity.inc file so it out of the scope of this issue.

voleger’s picture

Status: Active » Needs review
StatusFileSize
new299.48 KB

Here the patch.
There are removals of all deprecated API calls from include files except entity.inc file and REQUEST_TIME constant which is deprecated but actually not fully replaced.

berdir’s picture

Status: Needs review » Needs work

> PHP Fatal error: Uncaught Error: Call to undefined function drupal_set_time_limit() in /var/www/html/core/scripts/run-tests.sh:162

Looks like we missed a call ;)

That should be backported to D8 I suppose, so separate issue maybe?

voleger’s picture

Status: Needs work » Needs review
StatusFileSize
new300.09 KB
new1.34 KB

Replaced the last call of the drupal_set_time_limit() in run-test.sh

voleger’s picture

StatusFileSize
new300.74 KB
new1.17 KB

Update LoggingTest and remove call of removed function from the install tasks

Status: Needs review » Needs work

The last submitted patch, 12: 3062757-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

voleger’s picture

Status: Needs work » Needs review
StatusFileSize
new287.43 KB
new35.8 KB

Removed additional legacy tests that are related for current removals.
Also reverted some changes to simlpetest module. Just keep removed the required method and related call.

voleger’s picture

voleger’s picture

voleger’s picture

andypost’s picture

btw Maybe better to split this patch into per-file base to make it easy reviewable?

berdir’s picture

That's up to framework managers, but IMHO, this is pretty fine, these kind of patches are fairly easy to review. What's more important is that we separate non-test calls out into separate issues that can be backported, like already done in #17.

martin107’s picture

Thanks voleger -- for persisting with this issue.

I see 4 additional coding standard bugs in the test output

It is the curse of the unused used statement.

voleger’s picture

StatusFileSize
new287.41 KB
new1.8 KB

Addressed CS issues

andypost’s picture

I think it needs 2 follow-ups because there's a changes which are out of scope and they backportable

  1. +++ b/core/modules/file/file.module
    @@ -155,7 +155,7 @@ function file_load($fid, $reset = FALSE) {
    - * @see file_unmanaged_copy()
    + * @see \Drupal\Core\File\FileSystemInterface::copy()
    
    @@ -565,7 +565,7 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions
    - * @see file_unmanaged_save_data()
    + * @see \Drupal\Core\File\FileSystemInterface::saveData()
    
    +++ b/core/modules/toolbar/src/Controller/ToolbarController.php
    @@ -63,7 +63,7 @@ public function checkSubTreeAccess($hash) {
    -   * @see drupal_render()
    +   * @see \Drupal\Core\Render\RendererInterface::render()
    
    +++ b/core/scripts/run-tests.sh
    @@ -159,7 +160,7 @@
    -drupal_set_time_limit(0);
    +Environment::setTimeLimit(0);
    
    +++ b/core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php
    @@ -110,7 +110,7 @@ protected function tearDown(TestDatabase $test_database, $db_url) {
    -   * @see file_unmanaged_delete_recursive()
    +   * @see \Drupal\Core\File\FileSystemInterface::deleteRecursive()
    
    +++ b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
    @@ -308,7 +308,7 @@ public function testServerWithNoInstall() {
    -   * @see file_unmanaged_delete_recursive()
    +   * @see \Drupal\Core\File\FileSystemInterface::deleteRecursive()
    

    This needs separate issue to clean-up mentions of deprecated functions, it is backportable to 8.8.x at least

  2. +++ b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
    @@ -86,7 +66,7 @@ public function testHtmlEscapedText($text, $expected, $message) {
    -   * Data provider for testCheckPlain() and testEscapeString().
    +   * Data provider for testEscapeString().
        *
        * @see testCheckPlain()
    

    Probably it needs separate quickfix for this inconsistency

berdir’s picture

1.

time limit already has a (RTBC) issue.

The file comment references, yeah, maybe, not sure if it's worth it, it's nothing functional.

2. This referes IIRC a (legacy) test function that is removed in this patch, it still exists in 8.x and is not removed.

andypost’s picture

dww’s picture

Status: Needs review » Needs work
voleger’s picture

andypost’s picture

Pager also in separate issue #3087517: Remove BC layer for Pager service

berdir’s picture

And the issue in #24 is IMHO no longer a blocker, per my comment there. On 8.x, the method name is just wrong but still exists, so that issue fixes that and here we can remove it.

So, lets reroll this without the pager part :)

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new267.05 KB

Attempt to re-roll after pager fixed

berdir’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.2 KB

There are 141 @deprecated within core/includes before the patch and just one after applying it, that is the REQUEST_TIME constant that we can't remove yet. And there are no @trigger_error() left, 113 are removed by the patch.

What this issue doesn't cover is related constructor deprecations in services/controllers/forms/.. that were introduced as part of the deprecation removal of the functions that we remove here, e.g. file_system. But I think unlike the entity manager, where that included instanceof checks of the removed interface, these are easier to detect and remove in the issues for the respective modules/components.

I also had a look at the remaining contents of these include files and while it is unfortunate that we couldn't finish some of the ongoing deprecations in time, like drupal_get_filename(), render() related things or file_create_url(), there isn't too much left and I think we could in a follow-up see if some of the left-overs could be merged into common.inc, so have to load fewer files on every request.

There are still a handful of deprecated function removals that could possibly be backported to D8, I extracted them in the attached patch, with the following command. It's only pseudo-code in hook examples and documentation, so nothing functional:

git diff HEAD core/modules/toolbar/src/Controller/ToolbarController.php core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php core/modules/file/file.module core/lib/Drupal/Core/Utility/token.api.php core/lib/Drupal/Core/Form/form.api.php core/lib/Drupal/Component/FileSecurity/FileSecurity.php > patches/3062757-30-D8-reference-fixes.patch

I think getting this in asap is beneficial to being able to do real tests against D9 for contrib modules. According to https://dev.acquia.com/drupal9/deprecation_status/graphs#topErrorStatus, this removes 7 of the top 15 deprecated things, with only simpletest, getMock(), Drupal:: methods and Unicode left. And it looks ready to me, so RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 144c05e and pushed to 9.0.x. Thanks!

alexpott’s picture

I also committed #30... Committed and pushed 91f4c1edfe to 8.9.x and d68d8dfa42 to 8.8.x. Thanks!

As these are docs backports to 8.8.x and 8.9.x. I'm leaving the issue at 9.0.x because that's where the bulk of this work is done.

  • alexpott committed 144c05e on 9.0.x
    Issue #3062757 by voleger, Berdir, andypost: Remove deprecated legacy...

  • alexpott committed 91f4c1e on 8.9.x
    Issue #3062757 by voleger, Berdir, andypost: Remove deprecated legacy...

  • alexpott committed d68d8df on 8.8.x
    Issue #3062757 by voleger, Berdir, andypost: Remove deprecated legacy...
dww’s picture

Thanks for all the great work in here! Very exciting to see so much of this code going away.

I wish d.o made it easier to associate realistic git commit messages with individual patches, not the entire issue. Seeing commit d68d8df on the 8.8.x branch seems like a cherry-pick error:

"Issue #3062757 by voleger, Berdir, andypost: Remove deprecated legacy include files from Drupal 9"

That should have said something like:

"Issue #3062757 by voleger, Berdir, andypost: Fix documentation to not reference deprecated functions" (more or less).

Commenting here for posterity, in case anyone is looking at the git logs, confused, opens this issue, and happens to find this. ;)

Cheers,
-Derek

alexpott’s picture

@dww I should have fixed that on commit and put a better title in. My bad.

dww’s picture

@alexpott No worries! It totally happens. Y'all core committers have plenty to worry about, already. That's why I was saying I wished d.o made this task easier for you. Oh right, I (used to) maintain all those tools. Perhaps I should fix it. ;)

Cheers,
-Derek

Status: Fixed » Closed (fixed)

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