Problem/Motivation

Hello project maintainers,

This is an automated issue to help make this module compatible with Drupal 11.

Changes will periodically be added to this issue that remove deprecated API uses. To stop further changes from being posted, change the status to anything other than Active, Needs review, Needs work or Reviewed and tested by the community. Alternatively, you can remove the "ProjectUpdateBotD11" tag from the issue to stop the bot from posting updates.

The changes will be posted by the Project Update Bot official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated changes until this issue is closed

    If this issue is left open (status of Active, Needs review, Needs work or Reviewed and tested by the community) and the "ProjectUpdateBotD11" tag is left on this issue, new changes will be posted periodically if new deprecation fixes are needed.

    As the Drupal Rector project improves and is able to fix more deprecated API uses, the changes posted here will cover more of the deprecated API uses in the module.

    Patches and/or merge requests posted by others are ignored by the bot, and general human interactions in the issue do not stop the bot from posting updates, so feel free to use this issue to refine bot changes. The bot will still post new changes then if there is a change in the new generated patch compared to the changes that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated changes.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated changes, remove the "ProjectUpdateBotD11" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated changes again, add back the "ProjectUpdateBotD11" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful, they can close this issue (any status besides Active, Needs review, Needs work and Reviewed and tested by the community) and no more automated changes will be posted here.

    If the issue is reopened, then new automated changes will be posted.

    If you are using another issue(s) to work on Drupal 11 compatibility it would be very useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the latest patch in the comments by Project Update Bot or human contributors that made it better.
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.

Using the merge request

  1. Review the merge request and test it.
  2. Thoroughly test the changes. These changes are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the merge request, create a new branch and merge request and work from there.

Warning: The 'project-update-bot-only' branch will always be overwritten. Do not work in that branch!

Providing feedback

If there are problems with one of the changes posted by the Project Update Bot, such as it does not correctly replace a deprecation, you can file an issue in the Drupal Rector issue queue. For other issues with the bot, for instance if the issue summary created by the bot is unclear, use the Project analysis issue queue.

Issue fork toc_api-3455312

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

Project Update Bot created an issue. See original summary.

project update bot’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB
new2.89 KB

This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

It is important that any automated tests available are run and that you manually test the changes.

Drupal 11 Compatibility

According to the Upgrade Status module, even with these changes, this module is not yet compatible with Drupal 11.

Currently Drupal Rector, version 0.20.3, cannot fix all Drupal 11 compatibility problems.

Therefore, these changes did not update the info.yml file for Drupal 11 compatibility.

The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.

Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

Debug information

Bot run #11-199781

These packages were used to generate the fixes:

  1. drupal/upgrade_status: 4.3.2
  2. mglaman/phpstan-drupal: 1.2.11
  3. palantirnet/drupal-rector: 0.20.3

vladimiraus changed the visibility of the branch 3455312-automated-drupal-11 to hidden.

vladimiraus changed the visibility of the branch project-update-bot-only to hidden.

vladimiraus’s picture

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

Thanks all. Need to fix

  • phpstan
  • upgrade status

joseph.olstad made their first commit to this issue’s fork.

joseph.olstad’s picture

Status: Needs work » Needs review
joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Ok, it's as far forward as I can take it, this is probably "good enough" to merge. If someone can improve this then great. I say merge it, and cut an alpha or beta or rc release so that we can avoid doing overrides in our composer for Drupal 11 compatibility.

There's a multitude of fixes here. I fixed:

  • cspell
  • stylelint
  • many phpstan errors were fixed
  • deprecation fixes in the automated tests
  • deprecation fixes in the module code/classes.

Prior to these changes there was nothing but failures everywhere.

vladimiraus’s picture

Status: Reviewed & tested by the community » Needs review

Thanks for your contribution @joseph.olstad, but you cannot commit code and review it yourself.
Someone else need to review it and test it.

joseph.olstad’s picture

I recommend merging this and cutting a 1.6.0-beta1 release so that we can scrap our composer overrides (please!).

All you have to do is merge and tag the 8.x-1.x as 1.6.0-beta1

This way 1.5 stays as the recommended release and we can work on improving 1.6.0 in Drupal 11 without resorting to painful composer overrides that complicate upgrades for those using our distribution of Drupal (WxT).

the drupal ci/cd does the rest.

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

jurgenhaas’s picture

@joseph.olstad tests are almost green. There are just 2 phpunit tests that I don't know how to fix. There is 1 about a missing core service, that's confusing. And another 1 is about regex and I don't think we've changed anything there and this must have failed already before.

Could you probably have a look into that? Everything else is resolved.

joseph.olstad’s picture

Yes the missing core service is confusing. And for the regex, these tests were extremely broken prior to this merge request and they have deleted the historical jenkins results so I don't know when this was last working (if ever). This merge request is a vast improvement. With that said, we'll continue to use this merge request and review the results manually. Merging this would be good if we could merge and tag an alpha or beta or rc release for D11 that'd be a step in the right direction.

smulvih2’s picture

I'm testing this on core 11.1.1, using toc_api from this MR, along with toc_filter 2.3.0. I'm running into an error when saving a node that is using the [toc] token, assume the error is coming from toc_api:

TypeError: Drupal\Core\Render\MetadataBubblingUrlGenerator::generateFromRoute(): Argument #2 ($parameters) must be of type array, null given, called in /var/www/html/core/lib/Drupal/Core/Url.php on line 769 in Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() (line 104 of core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php).

Drupal\Core\Url->toString(1) (Line: 175)
Drupal\Core\Utility\LinkGenerator->generate(Object, Object) (Line: 102)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func_array(Array, Array) (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 825)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 387)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 203)
Drupal\Core\Render\Renderer->render(Array) (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 120)
__TwigTemplate_e9204f7060e2bc684929174b8b8efc1d->{closure}() (Line: 2058)
Twig\Extension\CoreExtension::captureOutput(Object) (Line: 88)
__TwigTemplate_e9204f7060e2bc684929174b8b8efc1d->macro_tree_links(Array) (Line: 67)
__TwigTemplate_e9204f7060e2bc684929174b8b8efc1d->doDisplay(Array, Array) (Line: 387)
Twig\Template->yield(Array, Array) (Line: 343)
Twig\Template->display(Array) (Line: 358)
Twig\Template->render(Array) (Line: 35)
Twig\TemplateWrapper->render(Array) (Line: 33)
twig_render_template('modules/contrib/toc_api/templates/toc-tree.html.twig', Array) (Line: 354)
Drupal\Core\Theme\ThemeManager->render('toc_tree', Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 203)
Drupal\Core\Render\Renderer->render(Array) (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 51)
__TwigTemplate_2dc37c9b3f055a0c562225983c06be41->doDisplay(Array, Array) (Line: 387)
Twig\Template->yield(Array, Array) (Line: 343)
Twig\Template->display(Array) (Line: 358)
Twig\Template->render(Array) (Line: 35)
Twig\TemplateWrapper->render(Array) (Line: 33)
twig_render_template('modules/contrib/toc_api/templates/toc-default.html.twig', Array) (Line: 354)
Drupal\Core\Theme\ThemeManager->render('toc_default', Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 203)
Drupal\Core\Render\Renderer->render(Array) (Line: 157)
Drupal\toc_api\TocBuilder->renderToc(Object) (Line: 184)
Drupal\toc_filter\Plugin\Filter\TocFilter->process

joseph.olstad’s picture

Hmm,
Seems there's smoke in the twig files?

templates/toc-tree.html.twig

and

templates/toc-default.html.twig

and this

#pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725',

joseph.olstad’s picture

Status: Needs review » Needs work

jurgenhaas, want to take a look?

jurgenhaas’s picture

I'm not deep into twig, so this is certainly a task for someone else.

joseph.olstad’s picture

ok @jurgenhaas, I'll have to go through the test scenarios manually in my environment. Hopefully some time this week or next week!

Thanks for your work on this!

vladimiraus’s picture

Status: Needs work » Needs review
vladimiraus’s picture

vladimiraus’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
liam morland’s picture

Re "these tests were extremely broken prior to this merge request": The current merge request adds the .gitlab-ci.yml file. I suggest committing #3384686: Add testing configuration. This adds .gitlab-ci.yml and gets the tests passing. Use that issue to get tests passing and then ensure that they keep passing in the current issue.

vladimiraus’s picture

Status: Needs review » Needs work

Need work based on CI.

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

danrod’s picture

I am looking at the PHPSTAN issues, is the disabledTestRender() test method really needed?

tests/src/Kernel/TocManagerTest.php

  /**
   * Tests TOC rendering. Temporarily disabled.
   *
   * @return bool|string
   *   This return a string or a boolean value.
   */
  public function disabledTestRender() {
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = \Drupal::service('renderer');
    /** @var \Drupal\toc_api\TocManager $toc_manager */
    $toc_manager = \Drupal::service('toc_api.manager');
    /** @var \Drupal\toc_api\TocBuilder $toc_builder */
    $toc_builder = \Drupal::service('toc_api.builder');
danrod’s picture

I fixed all of the PHPSTAN / PHPCS issues that were popping up in the tests/ directory, I ran the tests and they all passed now, I'm not familiar with ths module so I'll need to check if I broke other components of the module by fixing this:

daniel@drupal:/var/www/html$ ./vendor/bin/phpunit web/modules/contrib/toc_api/tests/ --verbose -c web/core/phpunit.xml
PHPUnit 10.5.45 by Sebastian Bergmann and contributors.

Unknown option "--verbose"
daniel@drupal:/var/www/html$ ./vendor/bin/phpunit web/modules/contrib/toc_api/tests/ -c web/core/phpunit.xml
HTML output directory sites/simpletest/browser_output is not a writable directory.

PHPUnit 10.5.45 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.14
Configuration: /var/www/html/web/core/phpunit.xml

.................................                                 33 / 33 (100%)

Time: 00:02.034, Memory: 6.00 MB

OK (33 tests, 178 assertions)
daniel@drupal:/var/www/html$ 

I am aware that they are other issues other than the CI messages and the test directory, for now I am moving this to "Needs Review"

danrod’s picture

Status: Needs work » Needs review
joseph.olstad’s picture

@danrod, great work, fixing the phpstan issues appears to have also fixed the automated tests. 33 tests pass.

dabbor’s picture

Hi everyone and thank you for your effort.

I'm trying to use patch from the MR: https://git.drupalcode.org/project/toc_api/-/merge_requests/16 but for some reason not having luck, getting conflicts (can not be applied). EDIT: Patch I tried to apply: https://git.drupalcode.org/project/toc_api/-/merge_requests/16.patch

I tried the following branches as base:
- 8.x-1.7 (meaning 8.x-1.x branch with tag 8.x-1.7)
- 2.0.x-dev#89c0b377 using the latest commit hash (meaning 2.0.x branch with commit hash 89c0b377). This seems to be having the same tag 8.x-1.7 as the 8.x-1.x branch has (which is confusing).

I git-cloned the MR branch and made the patch manually from branch 3455312-drupal11-fixes against branch 8.x-1.x as base. The 2.0.x branch does not exists in the MR request issue repository (not being up to date with the original).
- The patch did not work and I got conflicts to resolve.
- I can see that the MR started on version 1.5 or so and then the conflicts were resolved (merged back) for: 1.6 and 1.7. But maybe something went wrong with the merge conflicts resolutions, I do know exactly.

I appreciate any advice on getting this MR into patch that I can apply to toc_api contrib.

joseph.olstad’s picture

@dabbor , sometimes you'll get better results using the diff instead of the patch, especially if you're doing a --dry-run test of it.

https://git.drupalcode.org/project/toc_api/-/merge_requests/16.diff

I just did a dry run of the diff against 2.0.x, and it's 100% clean.

2.0.x ▶
 ╰❯ $ patch -p1 --dry-run < 16.diff
checking file .cspell-project-words.txt
checking file css/toc.tree.css
checking file js/toc.menu.js
checking file js/toc_type.js
checking file modules/toc_api_example/toc_api_example.info.yml
checking file modules/toc_api_example/toc_api_example.module
checking file phpstan.neon
checking file src/Entity/TocType.php
checking file src/Plugin/Block/TocBlockBase.php
checking file src/Toc.php
checking file src/TocBuilder.php
checking file src/TocBuilderInterface.php
checking file src/TocFormatter.php
checking file src/TocFormatterInterface.php
checking file src/TocInterface.php
checking file src/TocManager.php
checking file src/TocManagerInterface.php
checking file src/TocTypeForm.php
checking file src/TocTypeListBuilder.php
checking file templates/toc-menu.html.twig
checking file templates/toc-tree.html.twig
checking file tests/src/Kernel/TocBuilderTest.php
checking file tests/src/Kernel/TocManagerTest.php
checking file tests/src/Unit/TocFormatterTest.php
checking file tests/src/Unit/TocTest.php
checking file toc_api.info.yml
checking file toc_api.install
checking file toc_api.module

A full apply of the diff works just as expected

2.0.x ▶
 ╰❯ $ patch -p1 < 16.diff
patching file .cspell-project-words.txt
patching file css/toc.tree.css
patching file js/toc.menu.js
patching file js/toc_type.js
patching file modules/toc_api_example/toc_api_example.info.yml
patching file modules/toc_api_example/toc_api_example.module
patching file phpstan.neon
patching file src/Entity/TocType.php
patching file src/Plugin/Block/TocBlockBase.php
patching file src/Toc.php
patching file src/TocBuilder.php
patching file src/TocBuilderInterface.php
patching file src/TocFormatter.php
patching file src/TocFormatterInterface.php
patching file src/TocInterface.php
patching file src/TocManager.php
patching file src/TocManagerInterface.php
patching file src/TocTypeForm.php
patching file src/TocTypeListBuilder.php
patching file templates/toc-menu.html.twig
patching file templates/toc-tree.html.twig
patching file tests/src/Kernel/TocBuilderTest.php
patching file tests/src/Kernel/TocManagerTest.php
patching file tests/src/Unit/TocFormatterTest.php
patching file tests/src/Unit/TocTest.php
patching file toc_api.info.yml
patching file toc_api.install
patching file toc_api.module

Remember, you have to patch against the HEAD of 2.0.x, meaning, you need the latest 2.0.x, so get the latest before you try applying the patch.

dabbor’s picture

Hi @joseph.olstad,

Thank you very much for your advice, I'm happy to learn something new :)

I believe I understood the difference. The patch includes history of the commits and its application tries to do something like git merge while the diff provides just the differences which can be applied without any knowledge of commits or processes that led to the point.

The https://git.drupalcode.org/project/toc_api/-/merge_requests/16.diff works for me, so I'm adding a static patch file from it for referencing in composer (to have a static input that is not changing with the MR updates).

dabbor’s picture

StatusFileSize
new51.47 KB

It seems that while saving the https://git.drupalcode.org/project/toc_api/-/merge_requests/16.diff as a static patch I made a mistake copy pasting it into the file instead of savign the https://git.drupalcode.org/project/toc_api/-/merge_requests/16.diff from browser and as such I misses some character encoding or so making the previous patch not working so I'm replacing it now.

smulvih2’s picture

Ok all tests are now passing, functionally toc_api works as expected from my testing. This is ready for review and a new tagged release!

danrod’s picture

Yes !
Is there any chance to reach out to the maintainers for a tagged release?

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

We need this merged and a release tagged asap, this is a release blocker for our distribution and we're looking to publish our Drupal 11 release in the next week or two at the latest!

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

Merging

joseph.olstad’s picture

Creditting

joseph.olstad’s picture

joseph.olstad’s picture

Status: Fixed » Active

Checking crediting system.

joseph.olstad’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture

StatusFileSize
new907 bytes

patch for toc_filter