Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Proposed commit message
Issue #2407361 by cilefen, JeroenT, hussainweb, neclimdul, ircmaxell, tim.plunkett, nlisgo, Crell: Move usages of drupal_html_id() to Html::getUniqueId()
Meta issue: #2205673: [meta] Remove all @deprecated functions marked "remove before 8.0"
drupal_html_id is deprecated and should be replaced by \Drupal\Component\Utility\Html::getUniqueId().
Comment | File | Size | Author |
---|---|---|---|
#51 | move_usages_of-2407361-51.patch | 25.39 KB | cilefen |
#51 | interdiff-35-51.txt | 5.14 KB | cilefen |
#35 | move_usages_of-2407361-35.patch | 25.27 KB | cilefen |
#26 | move_usages_of-2407361-26.patch | 25.38 KB | cilefen |
#26 | interdiff-24-26.txt | 4.91 KB | cilefen |
Comments
Comment #1
JeroenTComment #2
JeroenTFirst attempt
Comment #3
JeroenTComment #5
JeroenTComment #6
JeroenTRemoved testing code.
Comment #9
JeroenTComment #11
JeroenTWe're almost there.
Comment #13
JeroenTAssigned to the following CR: HTML functions moved to a component
Comment #14
JeroenTComment #15
LinL CreditAttribution: LinL commentedSadly, no longer applies.
Comment #16
piyuesh23 CreditAttribution: piyuesh23 commentedComment #17
hussainwebComment #18
hussainwebRerolling...
Comment #19
Fabianx CreditAttribution: Fabianx commentedRTBC, looks great and will make #1305882: drupal_html_id() considered harmful; remove ajax_html_ids to use GET (not POST) AJAX requests easier.
Clarifying title.
Comment #21
Fabianx CreditAttribution: Fabianx commentedComment #22
cilefen CreditAttribution: cilefen commentedComment #24
cilefen CreditAttribution: cilefen commentedIt helps to pull before rerolling!
Comment #25
Fabianx CreditAttribution: Fabianx commentedHTML -> Html
Add 'use' at top of file, then just Html::
Did not watch carefully enough the first time.
Comment #26
cilefen CreditAttribution: cilefen commentedComment #27
Fabianx CreditAttribution: Fabianx commentedCan you confirm there are no usages of drupal_html_id() left now?
Comment #28
cilefen CreditAttribution: cilefen commentedBesides the function declaration, the only place drupal_html_id is found is in ViewPreviewForm::init():
Comment #29
Fabianx CreditAttribution: Fabianx commentedYes, 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
Comment #30
cilefen CreditAttribution: cilefen commentedDone #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.
Comment #31
catchHow does this make #1305882: drupal_html_id() considered harmful; remove ajax_html_ids to use GET (not POST) AJAX requests easier?
Comment #32
Fabianx CreditAttribution: Fabianx commented#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 ...
Comment #33
catchHmm OK. When I opened this I thought it'd make that issue harder, so I'd settle for 'not harder'.
No longer applies though.
Comment #34
Fabianx CreditAttribution: Fabianx commentedComment #35
cilefen CreditAttribution: cilefen commentedComment #36
Fabianx CreditAttribution: Fabianx commentedBack to RTBC if tests pass.
Comment #38
catchCommitted/pushed to 8.0.x, thanks!
Comment #39
nlisgo CreditAttribution: nlisgo commentedSince 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
Comment #40
nlisgo CreditAttribution: nlisgo commentedResetting HEAD to 11e02a67 makes the install screen return.
Comment #41
nlisgo CreditAttribution: nlisgo commentedTried building 8.0.x on simplytest.me and can recreate the issue
Comment #42
cilefen CreditAttribution: cilefen commentedFixes the imports.
Comment #43
cilefen CreditAttribution: cilefen commentedComment #46
tim.plunkettComment #48
jhodgdonI have reverted the commit of the patch in #35. It broke HEAD for anyone not using opcaches.
Comment #49
tim.plunkettI 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:
ircmaxell said he'd file a PHP7 bug report tomorrow.
Comment #50
jhodgdonJust 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:
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.
Comment #51
cilefen CreditAttribution: cilefen commentedComment #52
mrjmd CreditAttribution: mrjmd commentedI 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:
I don't think this is relevant but wanted to point it out just in case. Marking RTBC.
Comment #53
cilefen CreditAttribution: cilefen commented@mrjmd We have an issue for that remaining thing. #1305882: drupal_html_id() considered harmful; remove ajax_html_ids to use GET (not POST) AJAX requests
Comment #54
cilefen CreditAttribution: cilefen commentedNope, this one #2443847: Remove dead HTML ID-tracking code from ViewPreviewForm
Comment #55
tim.plunkettIf 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
Comment #56
Fabianx CreditAttribution: Fabianx commentedComment #57
nlisgo CreditAttribution: nlisgo commentedDo we need to create a separate issue to address the fact that the testbot did not pick up on this?
Comment #58
tstoeckler@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.
Comment #59
catchArgh 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!
Comment #61
nlisgo CreditAttribution: nlisgo commented@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?
Comment #62
catchTesting 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.
Comment #63
neclimdulYeah, technically all versions of PHP would not have caught this because
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.
Comment #64
catchYes 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.
Comment #65
cilefen CreditAttribution: cilefen commented#2446719: Need test runners without bytecode caching
Comment #66
tim.plunkettHere's the fix for PHP https://github.com/php/php-src/pull/1149