Comments

ianthomas_uk’s picture

Here is my removal patch, along with a version for the test bot that includes the latest patches from all the other uncommitted sub-issues of the meta.

The patch:
- Moves PASS_THROUGH to Component\Utility\Title::PASS_THROUGH and updates all uses.
- Removes drupal_set_title and drupal_get_title.
- Removes calls to drupal_get_titles where it is one of a variety of places to get the title from, on the assumption that the title will always have been moved to one of the alternative locations in an earlier sub-issue.
- Defaults $variables['title'] to an empty string in template_preprocess_page to ensure it is always set (this may not be necessary).
- Removes check_plain/xss tests of drupal_set_title. We need to ensure these have been replaced, maybe by phpunit tests of \Drupal\Core\Page\HtmlFragment.
- Leaves one remaining comment mentioning drupal_set_title() in \Drupal\system\Tests\System\PageTitleTest as I don't understand what the comment means.

dawehner’s picture

+++ b/core/includes/authorize.inc
@@ -290,10 +290,6 @@ function authorize_run_operation($filetransfer) {
 
-  if (!empty($operation['page_title'])) {
-    drupal_set_title($operation['page_title']);
-  }
-

Do we really want to drop it?

+++ b/core/includes/theme.inc
@@ -2220,7 +2214,7 @@ function template_preprocess_page(&$variables) {
   else {
-    $variables['title'] = new RenderWrapper('drupal_get_title');
+    $variables['title'] = '';
   }

I wonder whether we can/should add a default 'title' variable into system_element_info instead

ianthomas_uk’s picture

I assume you looked at the -combined patch, authorize_run_operation was changed in #2192653-7: Remove drupal_set_title from authorize.php.

Yes, I agree we should add a default title variable (of empty string) to system_element_info. We should also move the line you quoted higher up the function, to just below

  // Move some variables to the top level for themer convenience and template cleanliness.
  $variables['show_messages'] = $variables['page']['#show_messages'];

Status: Needs review » Needs work

The last submitted patch, 1: drupal-2209595-remove-drupal_set_title-1-combined.patch, failed testing.

The last submitted patch, 1: drupal-2209595-remove-drupal_set_title-1-combined.patch, failed testing.

ianthomas_uk’s picture

ianthomas_uk’s picture

Status: Needs work » Needs review
StatusFileSize
new2.37 KB
new13.44 KB
new49.17 KB

Revised patch addressing #2/#3 and fixing the failing test (the other failure is random and unrelated)

Status: Needs review » Needs work

The last submitted patch, 7: drupal-2209595-remove-drupal_set_title-7-combined.patch, failed testing.

wim leers’s picture

#2192649: Remove drupal_set_title() from installation and update process landed! This is the last one :)

It seems the patch here includes #2192649 though?

ianthomas_uk’s picture

@Wim Leers, the patch depends on #2192649: Remove drupal_set_title() from installation and update process, so I uploaded both versions.

I'm looking at the failing test (minor), but I'd appreciate reviews and help with the two points I raised earlier:

- Removes check_plain/xss tests of drupal_set_title. We need to ensure these have been replaced, maybe by phpunit tests of \Drupal\Core\Page\HtmlFragment.
- Leaves one remaining comment mentioning drupal_set_title() in \Drupal\system\Tests\System\PageTitleTest as I don't understand what the comment means.

wim leers’s picture

Status: Needs work » Needs review
wim leers’s picture

Aha! Re-testing in that case now that that is committed, I will review/help ASAP :)

Status: Needs review » Needs work

The last submitted patch, 7: drupal-2209595-remove-drupal_set_title-7-combined.patch, failed testing.

ianthomas_uk’s picture

It's the -do-not-test.patch you need to look at, which should pass except for one issue that I'm looking into. I'll upload a new patch when I've fixed that.

wim leers’s picture

Oh, ok — sorry!

ianthomas_uk’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new13.52 KB

Here is my new patch, note the interdiff is to patch #1 as I've undone the change made in #7.

Previously it made up a $head_title if there was nothing in drupal_get_title(). There is now never anything in drupal_get_title(), which means the title was effectively untested. I've therefore updated the test to pass a test title as part of the render array.

ianthomas_uk’s picture

Removes check_plain/xss tests of drupal_set_title. We need to ensure these have been replaced, maybe by phpunit tests of \Drupal\Core\Page\HtmlFragment.

#title is not escaped, so we don't need to test the escaping. We already have some tests for this in Drupal\system\Tests\Common\RenderElementTypesTest, so we need any more?

sun’s picture

This looks good to me, borderline RTBC. Two considerations:

  1. Hrm, Drupal\Core\Utility\Title just contains constants; that should not exist — let's create a follow-up issue to eliminate that utility class and move those constants to a proper home. It would actually be best if those constants would not exist in the first place; now that we have class methods, we can simply have separate getRawTitle(), getPlainTitle(), getXssSafeTitle() methods.
  2. I'm slightly concerned about the empty string default value. — Previously, if there was no page title, then the page title was just the site name. Is that behavior still the same?
ianthomas_uk’s picture

#18.1 Sounds reasonable, I have opened #2214525: Remove unused Drupal\Core\Utility\Title. In the meantime, this at least brings some consistency to the constants that we do have.
#18.2 Yes, that happens about 50 lines into template_preprocess_html() in core/includes/theme.inc. I can't find a page without a title, but it does work correctly if I force it to fall through to the default.

wim leers’s picture

If #18.2 is still working, can't we simply add a super short test for it? Probably in RenderElementTypesTest, where similar things are already being tested.

Otherwise: if sun is happy, then I am also :)

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, and sorry for my confusion; indeed, that default page title is handled in the template preprocess function - I forgot about that. And I'm fairly sure that we have tests for that.

ianthomas_uk’s picture

Assigned: ianthomas_uk » Unassigned
Priority: Normal » Critical
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.75 KB
new15.39 KB

This shuffles RenderElementTypesTest around a little bit so we first test without a page title, and then with one.

I've also removed the comment I was unsure of earlier. I traced it to #461938-13: Core should consistently filter_xss_admin() on $site_slogan and check_plain $site_name and I think it's related to the that has been put at the start of the test string. In any case, we should be checking for the text as the full title tag, so I've included that in the assertion and clarified the messages.

Setting to critical as this will close a beta blocker.

Status: Needs review » Needs work

The last submitted patch, 22: drupal-2209595-remove-drupal_set_title-22.patch, failed testing.

ianthomas_uk’s picture

Status: Needs work » Needs review
StatusFileSize
new4.09 KB
new15.49 KB

I swear that passed locally before...

We can't add to that test because we're testing using the site name rather than the page title. The is because the title is output as the heading on the page.

wim leers’s picture

Status: Needs review » Needs work

Sorry, nitpick review only. I'll leave the actual review to sun, who knows the installer much better. Setting to NW so that the nitpicks are definitely out of the way, so that sun can hopefully RTBC.

+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php
@@ -252,6 +248,11 @@ function testMaintenancePage() {
+    // Testing with a page title, which should be combined with the site name

Missing period.

+++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleTest.php
@@ -43,32 +43,13 @@ function setUp() {
+   * Tests the handling of HTML in node titles

Missing period.

ianthomas_uk’s picture

Status: Needs work » Needs review
StatusFileSize
new15.5 KB

Added those full stops, no other changes.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: drupal-2209595-remove-drupal_set_title-26.patch, failed testing.

ianthomas_uk’s picture

Status: Needs work » Needs review

26: drupal-2209595-remove-drupal_set_title-26.patch queued for re-testing.

Drupal\toolbar\Tests\ToolbarAdminMenuTest->testCacheClearByCacheTag() triggered a fatal error.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

This was RTBC at #27, and as per #29 it was only demoted to NW due to a random testbot fail. Back to RTBC!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome work, all! https://drupal.org/node/2067859 covers the change in a change notice already.

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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

chx’s picture

Issue tags: +sad chx