Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Jul 2015 at 07:18 UTC
Updated:
9 Oct 2015 at 16:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerThis isn't that bad, given how few strings we render on the frontpage.
Comment #2
jibranComment #3
jibranNeeds rebase.
Comment #4
dawehner. Yeah we just need the html related changes.
Comment #6
fabianx commentedAdded beta eval
Comment #7
fabianx commentedComment #8
dawehnermeh
Comment #9
fabianx commentedThanks, RTBC!
Comment #10
alexpottI think in this case a comment would be worth it here
Comment #11
dawehnerMaybe something like this?
Comment #12
dawehnerUpload #8 with the interdiff from #11
Comment #14
fabianx commentedThat works for me.
Comment #15
dawehnerJust a quick update. I did some profiling of /node/1 as a non admin user and there this strtr() call was almost a 1ms out of 140ms in total.
Comment #16
alexpottIf the passed in
$filter = ['__'=>'_'];this does does something different than before. Why is $filter configurable?Comment #17
joelpittetThese both together is a pain in the ass, it's a legacy workaround for BEM support. I wonder how much damage it would be if we removed both?
I can open a new issue for that but just wanted to bring this up in light of the un-RTBC marked by it.
Comment #18
hussainwebAddressing the concern in #16, I want to see what fails if we remove the $filter parameter. From what I could see in PHPStorm, nothing is using it. It is probably a BC break, but I want to see if something breaks in core.
Comment #20
hussainwebThe only things failing are situations we are checking only in tests. These are the two replacements that fail.
Both of these replacements are passed in with an empty array for filter, which means there should no replacements. I am not sure if this is a required use case.
Of course, another option is that we only do
str_replace('__', '##',...)if it is not set in $filter. Does that sound workable?Comment #21
john cook commentedI have undone patch #18 and wrapped the double underscore replacements in a conditional statement.
I have also added a test to ensure that
$filter = ['__'=>'_'];works as expected - from #16Comment #22
john cook commentedThe other way to fix #18 would be to change the tests.
Either
\Drupal\Tests\Component\Utility\HtmlTest::testCleanCssIdentifier()should also test for!empty($filter)or\Drupal\Tests\Component\Utility\HtmlTest::providerTestCleanCssIdentifier()should provideNULLas the third parameter in the arrays.Also, removing $filter from the
\Drupal\Component\Utility\Html::cleanCssIdentifier()definition would be an API change.Comment #23
john cook commentedComment #24
joelpittetJust some more backup for this issue, noticed Twig is doing this change as well:
https://github.com/twigphp/Twig/pull/1818
Benchmark https://3v4l.org/PXWDg/perf#tabs vs https://3v4l.org/iuq1Z/perf#tabs
Comment #25
dawehner@joelpittet
That is interesting!
Comment #26
fabianx commentedRTBC, looks great to me now.
Comment #27
alexpottGiven this is about a micro-optimisation we can actually go further.
str_replace()has another parameter which is a count of how many replacements made. So we could define a variable $double_underscore_replacements and pass it to the firststr_replace()and then only do the final str_replace() if it is greater than 0.Comment #28
hussainwebGreat idea.
Comment #29
alexpottThe isset check here now is not needed.
Comment #30
hussainwebTrue.
Comment #31
dawehnerIndeed nice idea!
Does someone mind adding a quick comment about that micro opt?
Comment #32
cilefen commentedComment #33
dawehnerI'd be more explicit: '... only if the starting string contained '__'
Comment #34
john cook commentedChanged the comment to be more specific as suggested in #33.
Comment #35
dawehner80 chars :(
Comment #36
john cook commentedAdded the documentation tag for the DrupalCon sprint.
Comment #37
joshi.rohit100Comment #38
cyberschorschReviewing this at drupalcon barcelona
Comment #39
cyberschorschThis looks good, liked the idea of alex :)
Comment #40
alexpottCommitted 7ae23ca and pushed to 8.0.x. Thanks!