With #2919891: Make Vocabulary use a route provider instead of hard-coded routes there is one usage of TaxonomyController::vocabularyTitle() left. We should replace that usage with the generic EntityController::title(). The only difference is that (weirdly) TaxonomyController::vocabularyTitle() actually returns HTML, i.e. if the vocabulary label contains HTML, that is actually put as HTML into the DOM.

Tasks

  1. Replace TaxonomyController::vocabularyTitle() with EntityController::title() in VocabularyRouteProvider::getOverviewPageRoute()
  2. Add a deprecation message to TaxonomyController::vocabularyTitle() pointing to EntityController::title() (see https://www.drupal.org/core/deprecation) for more information
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler created an issue. See original summary.

ioana apetri’s picture

Status: Active » Needs review
FileSize
1 KB

Here is my patch. I replaced with an un-deprecated function. Thanks.

tstoeckler’s picture

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

Thanks, that looks good for the first part of the issue.

Now we just need to add a @deprecated note to the function.

I fixed the formatting in the issue summary now, I had messed that up before.

ioana apetri’s picture

Status: Needs work » Needs review
FileSize
1.85 KB

I added the @deprecated note to the function.
See my patch and review it. Thanks

chr.fritsch’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

Deprecations also needs a change record.

tstoeckler’s picture

Issue tags: -Needs change record

Added a draft change record.

@yo30: You need to remove the parentheses ("()") at the end of:

    $route->setDefault('_title_callback', 'Drupal\Core\Entity\Controller\EntityController::title()');

It should be:

    $route->setDefault('_title_callback', 'Drupal\Core\Entity\Controller\EntityController::title');

instead. I think the patch will be green then.

ioana apetri’s picture

thanks, @tstoeckler , I was not a confirmed user, so no access to writing a change record.
I added the patch.

tstoeckler’s picture

Status: Needs work » Needs review

No worries, thanks for the updated patch. Let's see what the bot says.

chr.fritsch’s picture

Not sure if we should add a trigger_error to the deprecated method

tstoeckler’s picture

Status: Needs review » Needs work

Ahh, yes, you are right. So let's add a deprecation note as it is documented on https://www.drupal.org/core/deprecation

Are you up for that @yo30?

ioana apetri’s picture

Status: Needs work » Needs review
FileSize
2.13 KB

Sure,
Thanks, @tstoeckler.

tstoeckler’s picture

Status: Needs review » Needs work

Thanks @yo30!! Unfortunately, I found one more minor problem:

+++ b/core/modules/taxonomy/src/Controller/TaxonomyController.php
@@ -34,8 +34,14 @@ public function addForm(VocabularyInterface $taxonomy_vocabulary) {
+   * @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
+   *   Use Drupal\Core\Entity\Controller\EntityController instead.

This should be 8.5.0, as well, instead of 8.0.0.

ioana apetri’s picture

Status: Needs work » Needs review
FileSize
2.13 KB

Here is the modification.:)

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks perfect to me now!

Just for the record @yo30. Next time when working on a core patch it's best practice to create an interdiff when uploading multiple consecutive patches. See https://www.drupal.org/documentation/git/interdiff for more information. In this case it was not a big deal, because the patch was so small, but it's nice to keep that in mind. Thanks!

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Makes sense, thanks.

We should also add an @see to the CR in the docblock (same as the link that's already in the message).

xjm’s picture

Issue tags: +Needs manual testing

Hmm, wait, so if the vocabulary title is This <em>is</em> the title, will this replacement result in the markup being escaped?

There's an issue about markup in titles somewhere; we discussed it when we were working on the sanitization changes. There are actually lots of valid reasons to have HTML in titles. So let's make sure we're not regressing that.

xjm’s picture

There's #2563381: Hard to get page title and header both properly sanitized (very outdated) but that's not the one I was thinking of.

tstoeckler’s picture

Status: Needs work » Needs review
Issue tags: -Needs manual testing
FileSize
63.96 KB
64.62 KB
49.23 KB
50.26 KB

There are actually lots of valid reasons to have HTML in titles

That might be the case, but the fact of the matter is that entity labels are used in various contexts, not all of which are HTML. Or even if they end up being shown as part of the page, they might be already encapsulated in other HTML, as for example by t('Edit %title'). And by declaring the titles HTML we make all those use-cases either complicated or broken. Strictly speaking, what you are suggesting is that we treat the result of $entity->label() as HTML instead of plain text and that would be a huge API change at this point. Furthermore, we don't do this for any entity types. So if there really is such a compelling reason to do this, then we should discuss in a broader, more general issue as I don't see any reason why this would be valid (and important) for vocabularies, but not for node types, comment types, etc. And even if we do open up a generic issue that's all the more reason for this issue to go in, so that we have more standardization and we can more easily change things across all entities.

Attached are some before/after screenshots of the only visible changes of this patch: The page title on the term overview and the last breadcrumb component on the Manage fields/display/form display pages. As you can see both pages already show the escaped title, as well, making it clear that we are not in any way regressing, but in fact fixing an inconsistency here.

Going back to "Needs review" to hear your thoughts, but from my point of view this is still ready to fly.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tstoeckler’s picture

Status: Needs review » Needs work

Oh totally missed #15, sorry. That's certainly a "needs work", nice catch.

hussainweb’s picture

Status: Needs work » Needs review
Issue tags: +SprintWeekend2018
FileSize
1.3 KB
2.18 KB

Made the changes as per #15. I also found few typos in the message (extra spaces) and I fixed that.

Demonstrated in Drupal Global Sprint Weekend 2018.

tstoeckler’s picture

Status: Needs review » Needs work

Thanks for picking this up!

I guess since this is now targeting 8.6 we also need to update all the deprecation notices unfortunately.

akoe’s picture

Assigned: Unassigned » akoe
akoe’s picture

Status: Needs work » Active
akoe’s picture

Tested patch with core 8.6.x-dev and just updated core versions in comments.

akoe’s picture

Assigned: akoe » Unassigned
Status: Active » Needs review
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Perfect, thank you!

xjm’s picture

Hm, I still kinda disagree; this is definitely a (small) regression. It looks like #2919891: Make Vocabulary use a route provider instead of hard-coded routes introduced a regression for the breadcrumb, and this is extending that regression to the title. So yes, it's adding consistency, but it's being consistently disruptive to introduce escaping where it was not there previously. :) It's not that allowing markup would be a new decision. We already allow and sanitize the markup in 8.4.x and earlier.

Before

After

At a minimum the CR needs to be a bit clearer about what the site builder should do instead, but I'm still not convinced we should do this.

tstoeckler’s picture

I still don't understand why we have this feature for vocabularies if we don't have it anywhere else. Also not sure what specifically you would like to have in the change notice. We already note this change explicitly. What the site builders should do really depends on their use-case, but in all likelihood they should just remove the markup?!

larowlan’s picture

Status: Reviewed & tested by the community » Needs review

For #28

mohit1604’s picture

FileSize
1.41 KB

Thanks for the patch, providing interdiff of patch #21 and #25 :)

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

tstoeckler’s picture

Ha, thanks for catching this @smustgrave!

For anyone seeing this, the linked issue did in fact do the same change that was discussed here and was considered problematic here. The issue of HTML was not brought up there, so either it was missed there or not deemed important.