Subtask of #1830588: [META] remove drupal_set_title() and drupal_get_title()

Problem/Motivation

Using procedural drupal_set_title() inside controller class is not encouraged.

Proposed resolution

Replace drupal_set_title() with #title in page return array.

Remaining tasks

Issue patch

User interface changes

Refer parent issue at #1830588: [META] remove drupal_set_title() and drupal_get_title()

API changes

Refer parent issue at #1830588: [META] remove drupal_set_title() and drupal_get_title()

Comments

internetdevels’s picture

Status: Active » Needs review
StatusFileSize
new918 bytes
claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Looks good and I test it manually. Thank you!

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.85 KB
new828 bytes

Lets add a test as we don't test this title anywhere

alexpott’s picture

Actually that'd add the possibility of random fails due to the label contain < or > so let's use random name here instead.

claudiu.cristea’s picture

+++ b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
@@ -189,7 +189,8 @@ function testStyle() {
+    $this->assertResponse(200, format_string('Image style %original renamed to %new', array('%original' => $style->id(), '%new' => $style_name)));

String::format()?

dawehner’s picture

Theoretically it would be enough to use a _title_callback as you can pull somehow the upcasted entity from there.

alexpott’s picture

Out of scope (I think) I was was just resolving the confusion between id and label that the original message had - which I believe was in scope as it caused me to write an incorrect title assertion the first time around.

alexpott’s picture

My comment in #7 about out-of-scope refers to #5 not @dawehner's comment.

claudiu.cristea’s picture

Status: Needs review » Needs work

Sorry, I think I'm missing something, or... Why not intentionally testing with "<" or ">" or even unsafe names? The new "set title" (in fact $this->t()) should sanitize the value, no? And format_string() does the same. So we should end every time with a true assertion.

vijaycs85’s picture

Status: Needs work » Needs review

+1 to RTBC.

Reg #9:
@claudiu.cristea, we are just trying to remove the drupal_set_title() and making sure the test cases around drupal_set_title is updated to pass the same way it used to.

If you think, we are missing tests to check #title with unsafe value, we may need to raise it as separate issue and work on it (make sure we don't have coverage on main drupal_set_title() removal issue - here is change notice #2067859: drupal_set_title() and drupal_get_title() were removed)

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

I'm OK with the initial patch, that's why I'd RTBC it. #9 was a proposal for a better test.

So, yes, RTBC again :)

xano’s picture

dries’s picture

Committed to 8.x.

How do I mark this 'fixed'? It looks like the 7.x upgrade degraded the contributor experience on drupal.org. :-/

dries’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed
eliza411’s picture

#2128721: No follow button is a recent regression, fwiw, but there is much contributor feedback about the experience that is being gathered with the D.o UX tag.

Edit: both the Follow and the "Update this issue" link have gone missing.

Status: Fixed » Closed (fixed)

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