Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JeroenT’s picture

Assigned: Unassigned » JeroenT
JeroenT’s picture

Status: Active » Needs review
FileSize
25.85 KB

First attempt

JeroenT’s picture

Assigned: JeroenT » Unassigned

Status: Needs review » Needs work

The last submitted patch, 2: remove_usages_of-2407361-2.patch, failed testing.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
26.04 KB
4.14 KB
JeroenT’s picture

Removed testing code.

The last submitted patch, 5: remove_usages_of-2407361-5.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 6: remove_usages_of-2407361-6.patch, failed testing.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
25.34 KB
1.06 KB

Status: Needs review » Needs work

The last submitted patch, 9: remove_usages_of-2407361-9.patch, failed testing.

JeroenT’s picture

Status: Needs work » Needs review
FileSize
738 bytes
25.36 KB

We're almost there.

JeroenT’s picture

Assigned to the following CR: HTML functions moved to a component

JeroenT’s picture

Issue summary: View changes
LinL’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Sadly, no longer applies.

piyuesh23’s picture

Issue tags: +#DCM2015
hussainweb’s picture

Assigned: Unassigned » hussainweb
hussainweb’s picture

Assigned: hussainweb » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
25.42 KB

Rerolling...

Fabianx’s picture

Title: Remove usages of drupal_html_id. » Move usages of drupal_html_id() to Html::getUniqueId()
Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: remove_usages_of-2407361-18.patch, failed testing.

Fabianx’s picture

Issue tags: +Needs reroll
cilefen’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
25.52 KB

Status: Needs review » Needs work

The last submitted patch, 22: move_usages_of-2407361-22.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review
FileSize
24.75 KB

It helps to pull before rerolling!

Fabianx’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Field/WidgetBase.php
    @@ -217,7 +217,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
    -        $wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
    +        $wrapper_id = HTML::getUniqueId($id_prefix . '-add-more-wrapper');
    

    HTML -> Html

  2. +++ b/core/lib/Drupal/Core/Render/Element/Link.php
    @@ -69,7 +69,7 @@ public static function preRenderLink($element) {
    -        $element['#id'] = $element['#options']['attributes']['id'] = drupal_html_id('ajax-link');
    +        $element['#id'] = $element['#options']['attributes']['id'] = \Drupal\Component\Utility\Html::getUniqueId('ajax-link');
    
    +++ b/core/lib/Drupal/Core/Render/Element/Radios.php
    @@ -65,7 +65,7 @@ public static function processRadios(&$element, FormStateInterface $form_state,
    -          '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
    +          '#id' => \Drupal\Component\Utility\Html::getUniqueId('edit-' . implode('-', $parents_for_id)),
    
    +++ b/core/lib/Drupal/Core/Render/Element/Table.php
    @@ -131,9 +131,10 @@ public static function processTable(&$element, FormStateInterface $form_state, &
    -        $row['#id'] = drupal_html_id('edit-' . implode('-', $element_parents) . '-row');
    +        $row['#id'] = \Drupal\Component\Utility\Html::getUniqueId('edit-' . implode('-', $element_parents) . '-row');
    
    @@ -171,7 +172,7 @@ public static function processTable(&$element, FormStateInterface $form_state, &
    -            '#id' => drupal_html_id('edit-' . implode('-', $element_parents)),
    +            '#id' => \Drupal\Component\Utility\Html::getUniqueId('edit-' . implode('-', $element_parents)),
    
    +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php
    @@ -236,7 +236,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st
    -              '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
    +              '#id' => \Drupal\Component\Utility\Html::getUniqueId('edit-' . implode('-', $parents_for_id)),
    

    Add 'use' at top of file, then just Html::

Did not watch carefully enough the first time.

cilefen’s picture

Status: Needs work » Needs review
FileSize
4.91 KB
25.38 KB
Fabianx’s picture

Can you confirm there are no usages of drupal_html_id() left now?

cilefen’s picture

Besides the function declaration, the only place drupal_html_id is found is in ViewPreviewForm::init():

    // Reset the cache of IDs. Drupal rather aggressively prevents ID
    // duplication but this causes it to remember IDs that are no longer even
    // being used.
    $seen_ids_init = &drupal_static('drupal_html_id:init');
    $seen_ids_init = array();
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Yes, that is another bug, but was already present before this, so can be followup IMHO.

Or you could fix it here, should be:

Html::resetIds(); IIRC (or ::resetSeenIds())

Can you open a normal bug report for that?

RTBC

cilefen’s picture

Done #2443847: Remove dead HTML ID-tracking code from ViewPreviewForm. And there are a lot of issues in the core queue referencing drupal_html_id that ought to be evaluated and probably closed.

catch’s picture

Fabianx’s picture

#31: Not that much, but easier to grep for Html::getUniqueId instead of that _and_ drupal_html_id.

I assumed it was converted already, so first got confused on that ...

catch’s picture

Status: Reviewed & tested by the community » Needs work

Hmm OK. When I opened this I thought it'd make that issue harder, so I'd settle for 'not harder'.

No longer applies though.

Fabianx’s picture

Issue tags: +Needs reroll
cilefen’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
25.27 KB
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC if tests pass.

  • catch committed 85b8c83 on 8.0.x
    Issue #2407361 by JeroenT, cilefen, hussainweb: Move usages of...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

nlisgo’s picture

Since the introduction of this fix the install screen is broken:

Fatal error: Cannot use Drupal\Component\Utility\Html as Html because the name is already in use in /vagrant_sites/drupal8.local/web/core/lib/Drupal/Core/Render/Element/Link.php on line 11

Will investigate further

nlisgo’s picture

Resetting HEAD to 11e02a67 makes the install screen return.

nlisgo’s picture

Tried building 8.0.x on simplytest.me and can recreate the issue

cilefen’s picture

Status: Fixed » Needs review
FileSize
5.69 KB
5.69 KB

Fixes the imports.

cilefen’s picture

Status: Needs review » Fixed

The last submitted patch, 42: move_usages_of-2407361-42.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 42: move_usages_of-2407361-42.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Fixed

  • jhodgdon committed a2defc6 on 8.0.x
    Revert "Issue #2407361 by JeroenT, cilefen, hussainweb: Move usages of...
jhodgdon’s picture

Status: Fixed » Needs work

I have reverted the commit of the patch in #35. It broke HEAD for anyone not using opcaches.

tim.plunkett’s picture

I think in the short term we should do the use \Drupal\Component\Utility\Html as UtilityHtml;

ircmaxell confirmed this is a bug in all versions of PHP.
http://lxr.php.net/xref/PHP_5_5/Zend/zend_compile.c#7039

I'm guessing the testbots use opcache, because that's the only way they'd pass:

The reason it works with opcache is that opcache removes the symbol table at compile time. So there is never a conflict

ircmaxell said he'd file a PHP7 bug report tomorrow.

jhodgdon’s picture

Just to clarify:

What happened with the patch that was committed is that it made at least one class in the Drupal/Core/Render/Element area, which has a class called Html already, fail. The Container render element class was given a line saying:

use Drupal\Component\Utility\Html;

And on an ordinary server without opcache, if you tried to install you'd get:

Fatal error: Cannot use Drupal\Component\Utility\Html as Html because the name is already in use in ..../core/lib/Drupal/Core/Render/Element/Container.php on line 10

Two possible fixes are possible:
a) Use aliases, so the use line would say something like "use ... as HtmlComponent".
b) Rename the render element Html class to something else so it doesn't conflict. This has ramifications though.

cilefen’s picture

Status: Needs work » Needs review
FileSize
5.14 KB
25.39 KB
mrjmd’s picture

Status: Needs review » Reviewed & tested by the community

I ran a test of 8.0.x with the patch from #35 and saw the error message as reported above. Ran another test with the patch from #51 and Drupal installs as expected. I also applied the patch locally and did a full grep of the code base for drupal_html_id. I only saw one remaining case:

+++ b/core/modules/views_ui/src/ViewPreviewForm.php
@@ -21 @@ public function form(array $form, FormStateInterface $form_state)
    $seen_ids_init = &drupal_static('drupal_html_id:init');

I don't think this is relevant but wanted to point it out just in case. Marking RTBC.

cilefen’s picture

cilefen’s picture

tim.plunkett’s picture

If the committers want to credit those who spent time today fixing HEAD and tracking down the reason for the bug, you can add these people to the commit message:

neclimdul, ircmaxell, tim.plunkett, cilefen, nlisgo, Crell

Fabianx’s picture

Issue summary: View changes
nlisgo’s picture

Do we need to create a separate issue to address the fact that the testbot did not pick up on this?

tstoeckler’s picture

@nlisgo: In general we would add tests directly to this issue so that this issue never crops up again. However, in this particular case it doesn't seem possible to write a test.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Argh sorry about this.

This might have been caught if we'd had #1867192: Testbots need to run on 5.4, 5.5, 5.6 and 7 - at least quickly after commit if not before.

Committed/pushed #52 (with the additional credits) to 8.0.x, thanks!

  • catch committed 975121d on 8.0.x
    Issue #2407361 by cilefen, JeroenT, hussainweb, neclimdul, ircmaxell,...
nlisgo’s picture

@tstoeckler: do you mean to say you do not feel it is possible to write a test as part of this issue or at all? I don't know enough about the testbot setup to comment about whether an adjustment could be made to the way the build is done to be sure that this type of issue does not re-occur. Is the build script for testbot available?

catch’s picture

Testing on all PHP versions would have caught this - either implicitly because PHP 5.4 wouldn't be running opcache, or if we had added no opcode cache vs. APC vs. opcache as explicit configurations. Probably only after commit though.

If I'd known this would break HEAD I'd have marked it postponed on #1305882: drupal_html_id() considered harmful; remove ajax_html_ids to use GET (not POST) AJAX requests since in the end this method will be barely used if at all.

neclimdul’s picture

Yeah, technically all versions of PHP would not have caught this because

PASSED: [[SimpleTest]]: [PHP 5.4 MySQL]

implies that testbots did test this on php 5.4. So despite not having opcache, they have another opcode cache that must be providing the same behaviour. ircmaxell mentioned doing a writeup today so once he does maybe we'll have a better view into the nitty gritties of the failure and have the details to build an explicit test to catch this.

catch’s picture

Yes I think we'd want a PHP environment that explicitly doesn't have an opcode cache configured to ensure any issues like this get caught.

cilefen’s picture

tim.plunkett’s picture

Status: Fixed » Closed (fixed)

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