One deprecated library in Stark and one deprecated preprocess function in Stable.

Deprecated code in the Twig theme engine is being handled in #3011393: Remove twig_without() and manual inclusion of twig.engine TwigEnvironment

CommentFileSizeAuthor
#33 3097890-33.patch1.5 KBlongwave
#30 interdiff-3097890~26-30.txt2.88 KBmartin107
#30 3097890-30.patch23.19 KBmartin107
#26 interdiff-3097890-25-26.txt1.57 KBmartin107
#26 3097890-26.patch23.35 KBmartin107
#25 interdiff-3097890-21-25.txt8.5 KBmartin107
#25 3097890-25.patch23.35 KBmartin107
#21 3097890-21.patch23.35 KBmartin107
#21 interdiff-3097890-19-21.txt832 bytesmartin107
#19 interdiff-3097890-17-19.txt1.02 KBmartin107
#19 3097890-19.patch22.54 KBmartin107
#17 interdiff-3097890-14-17.txt2.17 KBmartin107
#17 3097890-17.patch21.52 KBmartin107
#14 3097890-14.patch19.34 KBmartin107
#14 interdiff-3097890-10-14.patch2.25 KBmartin107
#10 interdiff-3097890-8-10.txt9.14 KBmartin107
#10 3097890-10.patch17.09 KBmartin107
#8 interdiff-3097890-4-8.txt6.09 KBmartin107
#8 3097890-8.patch7.95 KBmartin107
#4 3097890-4.patch1.86 KBmartin107
#4 interdiff-3097890-2-4.txt358 bytesmartin107
#2 3097890.patch1.7 KBlongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
FileSize
1.7 KB

Status: Needs review » Needs work

The last submitted patch, 2: 3097890.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

martin107’s picture

FileSize
358 bytes
1.86 KB

looking at the test fails .. confusingly it is comparing two identical strings .. and failing

-'Configure blockEdit view'
+'Configure blockEdit view'

The errors seem unrelated to the changes.

So I am retesting.. but not before I make a minor unrelated correction.

the use html statement is now redundant.

martin107’s picture

.

andypost’s picture

Looks it needs to dig into issue with preprocess - all of failures are css class related

+++ b/core/themes/stable/stable.theme
@@ -23,23 +21,6 @@ function stable_library_info_alter(&$libraries, $extension) {
-function stable_preprocess_links(&$variables) {
-  // @deprecated in Drupal 8.0.x and will be removed before 9.0.0. This feature

I bet it not properly deprecated in #2402165: #theme => 'links' renders <li class="_"> when the #links array is not associative

Berdir’s picture

> -'Configure blockEdit view'
> +'Configure blockEdit view'

The trick here is that drupal.org removes the HTML wrapping these things, the difference is going to be in the classes added or whatever this function used to do.

martin107’s picture

Status: Needs work » Needs review
FileSize
7.95 KB
6.09 KB

The trick here is that drupal.org removes the HTML wrapping these things

Thanks for providing the solution ...

Bedir++

The differences show up nicely when one tests locally.

My summary might be that perhaps that some tests are too tightly coupled to the expected HTML.
We are in effect re validating the structural of contextual links over and over.

Anyway this will take careful detail work to unpick.

I am not finished, I am just posting as I go.

Status: Needs review » Needs work

The last submitted patch, 8: 3097890-8.patch, failed testing. View results

martin107’s picture

Status: Needs work » Needs review
FileSize
17.09 KB
9.14 KB

A few less errors.

Status: Needs review » Needs work

The last submitted patch, 10: 3097890-10.patch, failed testing. View results

longwave’s picture

+++ b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php
@@ -29,9 +29,9 @@ public function testCommentOperations() {
-    $operation = $this->cssSelect('.views-field-operations li.edit a');
+    $operation = $this->cssSelect('.views-field-operations li a:contains(\'Edit\')');

I do wonder if these sorts of changes will cause difficulty for theming or JavaScript targetting? While this is deprecated, I suspect people are relying on this when there is nothing else available to distinguish one list item from another except the text content?

martin107’s picture

I was thinking the same thing...

It will definitely be disruptive .. but we are at the point of incrementing the major release number.

So I would hope that turns the conversation to how do we communicate this to contrib.

In general, It is going to take bespoke fixes... not something we can automate.

Is there a tag for highlighting disruptive changes in the release notes/ migration guides?

martin107’s picture

Status: Needs work » Needs review
FileSize
2.25 KB
19.34 KB

CKEditorIntegrationTest now passes locally.

longwave’s picture

We are removing this from Stable because why should Stable be adding classes anyway, but would it be better to move this preprocess into Classy rather than remove it entirely?

Status: Needs review » Needs work

The last submitted patch, 14: 3097890-14.patch, failed testing. View results

martin107’s picture

Status: Needs work » Needs review
FileSize
21.52 KB
2.17 KB

would it be better to move this preprocess into Classy rather than remove it entirely?

-function stable_preprocess_links(&$variables) {
- // @deprecated in Drupal 8.0.x and will be removed before 9.0.0. This feature
- // of adding a class based on the associative key can cause CSS class name
- // conflicts.

I am happy that as we bump the major version number we take the opportunity to stop doing something dangerous.
Doing anything which will potentiality linger for another few years ( or however long the D9 to D10 interval is ), I would speak against

In relation to communicating with contrib .. which does really concern me : the slogan should be

"if you are looking for the the langcode in the classes look at the hreflang instead."

I just don't know the correct forum for that.

With that in mind I have made LanguageSwitchingTest.php pass by focusing on the hreflangs not the classes.

Status: Needs review » Needs work

The last submitted patch, 17: 3097890-17.patch, failed testing. View results

martin107’s picture

Status: Needs work » Needs review
FileSize
22.54 KB
1.02 KB

PreviewTest now passes

I am least happy this this change

In conversational english the new xpath search seeks to locate :-

A contextual link DOM structure where the anchor text contains "Add new" and the href contains the string '/filter'

I wanted to use xpaths ends-with() instead of a contains() call for the /filter condition but that is not available in the current mink version.

maybe I should completely specify the href from start to finish.

Status: Needs review » Needs work

The last submitted patch, 19: 3097890-19.patch, failed testing. View results

martin107’s picture

FileSize
832 bytes
23.35 KB

StatisticsLoggingTest is fixed.

This should all be green now... sorry this one came out in drips and drops.

martin107’s picture

Status: Needs work » Needs review
longwave’s picture

+++ b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php
@@ -29,9 +29,9 @@ public function testCommentOperations() {
+    $operation = $this->cssSelect('.views-field-operations li a:contains(\'Edit\')');

Can we double-quote these sorts of strings to avoid escaping the single quote?

Still not very happy about using :contains(), should we just test the raw HTML where possible?

martin107’s picture

Assigned: Unassigned » martin107

All resonable pushback .. thanks for the review.

Sure, double quotes it is...

should we just test the raw HTML where possible?

Yes, I am not happy about my cunning plan to "not too tightly" couple the test criteria to the underlying implementation.

There are multiple instances of 'Add new' on the page so I will have to lock things down to href and inner HTML

I will get to it on Sunday.

martin107’s picture

FileSize
23.35 KB
8.5 KB

Ahem finally found the time to work on this...

a) Fixed the double quotes issues.

b) PreviewTest now using the href attribute to lock down the required link

Still not very happy about using :contains(), should we just test the raw HTML where possible?

@longwave .. was that a comment about ALL conversions or the iffy PreviewTest

I see contains() being widely used in our caodebase?

martin107’s picture

FileSize
23.35 KB
1.57 KB

core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php

now passes locally

The lines I have altered are already using a mix of single and double quotes so I was forced to escape a least one of them.

I have checked that every altered file now passes lint checks :-

git diff op np --name-only | xargs -n1 php -l

where op and np are the branch names of the old patch and new patch

martin107’s picture

Assigned: martin107 » Unassigned

Ok I think this is good now.

longwave’s picture

Great work so far on this patch!

I feel that :contains() is OK when we are looking for something that coincidentally contains text - but in most of these cases we are actually looking for links, so why not use the dedicated assert methods for that?

  1. +++ b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php
    @@ -29,9 +29,9 @@ public function testCommentOperations() {
    -    $operation = $this->cssSelect('.views-field-operations li.edit a');
    +    $operation = $this->cssSelect('.views-field-operations li a:contains("Edit")');
         $this->assertEqual(count($operation), 1, 'Found edit operation for comment.');
    

    Can this just use assertLink()?

  2. +++ b/core/modules/media/tests/src/Functional/MediaOverviewPageTest.php
    @@ -133,10 +133,10 @@ public function testMediaOverviewPage() {
    -    $edit_link1 = $assert_session->elementExists('css', 'td.views-field-operations li.edit a', $row1);
    +    $edit_link1 = $assert_session->elementExists('css', 'td.views-field-operations li a:contains("Edit")', $row1);
         $this->assertSame('Edit', $edit_link1->getText());
    

    This seems a bit weird now, as it looks for an <a> that contains "Edit", and then asserts that it does indeed contain "Edit". Can we just use $assert_session->linkExists()?

  3. +++ b/core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
    @@ -308,20 +308,20 @@ public function testAllowedMediaTypes() {
    +        $assert_session->elementExists('css', 'li a:contains("Image")');
    +        $assert_session->elementExists('css', 'li a:contains("Arrakis")');
    

    Again, $assert_session->linkExists()?

martin107’s picture

Assigned: Unassigned » martin107

@longwave thank for the review

Before I start, out of context I have looked into the code and the css selector is autoconverted within symfony from

$this->cssSelect('.views-field-operations li.edit a');

to this

descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' views-field-operations ')]/descendant-or-self::*/li/descendant-or-self::*/a[contains(string(.), 'Edit')]

contains() in this context according to

https://www.w3.org/1999/07/WD-xpath-19990709.html#function-contains

return TRUE when the second string is found in the first. So it does behave as CSS's contains() does.

#28.1) Can this just use assertLink()

I have 2 separable objections :-

In the context of a conversion issue. I think we should try to neither
enhance or degrade the selectively of xpath or css statements.

In behat like language I read ".views.field.operations li a[contains('Edit')] " :-

CSS reads from right to left so

"Of all the links with the text 'Edit'(using wildcards). Return all those in a multi-select
pull down button within the operations section of a table"

Looking at assertLink() I dont think there is a way to preserve that multi select button context
and I a worried about introducing a test instability.

looking the the signature of assertLink()

protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {}

If you set the index to 9 then you are making an assertion that there must be at least 10 matching elements, maybe more.

What I am trying to say it ommiting it and letting the default(0) apply makes me uncomfortable
in senarios in which over time the number of links comes and goes.

For example say there are links with the text 'Edit', 'Editors', and 'Add Editors', 'Add'
that come and go on the page over time. Then selectors like a:contains('Edit') and a:contains('Add') will
maybe match more or less than expected so we can't set the index to a sensible value. We could easily over time add an extra link, then later corrupt the "link
under test" and silently end up with an assertion that falsely remains true.

Looking at the guts of assertLink() it does have one advantage over css contains() -- in xpath land text() matches text exactly.

  protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
    // Cast MarkupInterface objects to string.
    $label = (string) $label;
    $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
    $message = ($message ? $message : strtr('Link with label %label found.', ['%label' => $label]));
    return $this->assert(isset($links[$index]), $message, $group);
  }
  

Speaking constructively I think the best solution is, is to stop using contains() and copy the xpath/text() example from assertLink().

Alternatively we could copy the code which raised objections in your comments #28.2

$this->assertSame('Edit', $edit_link1->getText());

that snippet invokes the 'named_exact' convention and so also solves the wildcard 'Add Editors' problem.

3) Thank you... I think your suggestion is good. it will make the code cleaner

Finding time to work in this in the run up to Christmas is tricky, and so I am dividing my spare time up into thinking about the problem and creating the patch
I will find time to work on this soon

martin107’s picture

Assigned: martin107 » Unassigned
FileSize
23.19 KB
2.88 KB

Did not mean the Christmas break to extend so far into Jan...

So #29 is my response to #28 in word form.

This patch is my response in code form.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for working on this. I think this all looks clean enough with minimal changes to the tests. I hope this is OK for me to RTBC since I provided the first patch, let's see what the core committers think.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/stable/stable.theme
@@ -23,23 +21,6 @@ function stable_library_info_alter(&$libraries, $extension) {
-/**
- * Implements template_preprocess_links().
- */
-function stable_preprocess_links(&$variables) {
-  // @deprecated in Drupal 8.0.x and will be removed before 9.0.0. This feature
-  // of adding a class based on the associative key can cause CSS class name
-  // conflicts.
-  if (!empty($variables['links'])) {
-    foreach ($variables['links'] as $key => $value) {
-      if (!is_numeric($key)) {
-        $class = Html::getClass($key);
-        $variables['links'][$key]['attributes']->addClass($class);
-      }
-    }
-  }
-}
-

We shouldn't remove this from Stable. The comment is from a time before we had decided to create Stable 9 theme so that we wouldn't have to make changes to Stable. We can probably just remove the comment and be done.

longwave’s picture

Status: Needs work » Needs review
FileSize
1.5 KB

That makes this patch a whole lot simpler as we don't need to fix all those tests.

Wim Leers’s picture

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

Agreed with @lauriii in #32, and this now looks great!

But … this should then probably remove the now irrelevant // @deprecated … comment in stable_preprocess_links().

JeroenT’s picture

Assigned: Unassigned » JeroenT
JeroenT’s picture

Assigned: JeroenT » Unassigned
Status: Needs work » Needs review

@Wim Leers, The patch in #33 already removes the // @deprecated ... comment. Or am I missing something?

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

🤦‍♂️

Nope, you are not missing anything, it was me who was failing to see these lines in the patch 😞 Sorry about that!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 153d8af and pushed to 9.0.x. Thanks!

  • alexpott committed 153d8af on 9.0.x
    Issue #3097890 by martin107, longwave, andypost, lauriii: Remove all @...

Status: Fixed » Closed (fixed)

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