Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aburrows created an issue. See original summary.

aburrows’s picture

Issue summary: View changes
aburrows’s picture

Issue tags: +Novice
aburrows’s picture

Issue summary: View changes
muschpusch’s picture

Assigned: Unassigned » muschpusch

ok working on this with stmh at drupalcon dublin

muschpusch’s picture

Ok the more easy part of removing the class and use statements is done. There is actually one file where the AllowedTagsXssTrait::fieldFilterXss should have been used but since it's deprecated maybe the values should be filtered by FieldFilteredMarkup. Could somebody confirm that?

muschpusch’s picture

Status: Active » Needs review

Sorry the code i'm talking about is in here: core/modules/options/options.module

/**
 * Returns the array of allowed values for a list field.
 *
 * The strings are not safe for output. Keys and values of the array should be
 * sanitized through \Drupal\Core\Field\AllowedTagsXssTrait::fieldFilterXss()
 * before being displayed.
 *

Status: Needs review » Needs work

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nickmans’s picture

Hi,

Looks like you do need to change it to FieldFilteredMarkup::create.

twfahey’s picture

Using muschpusch's previous patch as a base, and based on the feedback provided, I *believe* I have added the appropriate changes here to the comments. Hope I'm not stepping on any toes, I am just eager to become more proficient with Drupal patching and contributing, and hopefully I have done things correctly here, but please, any and all feedback at this point is welcome!

tstoeckler’s picture

Issue tags: +dcruhr18
Mike Lewis’s picture

Working on this at Drupalcon Nashville. This is a little more complicated than just removing the use statements. Looks like the patches in #6 and #13 tried that ok, but the reason the tests are failing is that the classes are still trying to use the functions from the trait. So we need to go through and refactor it a little further to replace those with the updated methodology per #12

Mike Lewis’s picture

Issue summary: View changes

Updated issue summary.

dmitryl’s picture

Status: Needs work » Needs review
FileSize
9.85 KB

Applying patch

Mike Lewis’s picture

Issue summary: View changes

#17 solves the test failures. dmitryl is re-rolling a patch that removes the trait's php file.

dmitryl’s picture

Remove AllowedTagsXssTrait.php from the codebase.

dmitryl’s picture

Remove AllowedTagsXssTrait.php from the codebase.
Add missing file deletion from #19

borisson_’s picture

I don't think we can just remove the trait from core. As it's possible that this is used by contrib. We can remove the usages but removing the trait seems dangerous.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jcnventura’s picture

Issue tags: +DrupalEurope

Mentoring this at DrupalEurope with @iampuma

jcnventura’s picture

Status: Needs review » Needs work

Indeed, as specified, it is "@deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0."

We can't remove it in the 8.x branch. But we can remove the usages of this in preparation of Drupal 9.

iampuma’s picture

Status: Needs work » Needs review
FileSize
1.67 KB
9.82 KB

Reverted deletion of the AllowedTagsXssTrait.php in the codebase.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

The changes look better now, Thanks!

catch’s picture

Status: Reviewed & tested by the community » Needs review

--- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php

--- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php

+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
@@ -2,7 +2,6 @@

@@ -2,7 +2,6 @@
 
 namespace Drupal\options\Plugin\Field\FieldType;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -15,8 +14,6 @@

@@ -15,8 +14,6 @@
  */
 abstract class ListItemBase extends FieldItemBase implements OptionsProviderInterface {
 
-  use AllowedTagsXssTrait;
-
   /**
    * {@inheritdoc}
    */

I'm not 100% about removing this from ListItemBase because it's designed to be extended. Could we split this hunk out to a separate issue?

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

Issue summary: View changes
FileSize
5.04 KB

Yeah we can't remove the trait usage. We can only deprecate all the methods properly.

No interdiff because the approach is different and inline with current deprecated code best practices.

alexpott’s picture

Title: Remove deprecated AllowedTagsXssTrait from ListItemBase » Properly deprecate AllowedTagsXssTrait

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mradcliffe’s picture

Tagging this for drupalcon amsterdam 2019.

We need to review @alexpott's code and update the issue summary to include the consensus in #28 and #30.

mradcliffe’s picture

Assigned: muschpusch » Unassigned

Removing assigned property.

louisnagtegaal’s picture

I'm working on it on DrupalCon Amsterdam2019

nickmans’s picture

I tested and applied this patch on DrupalCon Amsterdam 2019 on 8.9.x-dev and it's working fine.

louisnagtegaal’s picture

I have reviewed the patch in 2809237-30.patch. To get proper deprecation warnings in unit tests (like the one I added) an extra parameter must be added tot the @trigger_error-calls in core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php

I have added a new patch which includes this extra parameter and added an unit test to check for the deprecation messages.

alexpott’s picture

Here's a fixed up test.

  1. @louisnagtegaal great catch and good call to add a test.
  2. +++ b/core/tests/Drupal/Tests/AllowedTagsXssTraitDeprecateTest.php
    @@ -0,0 +1,28 @@
    +namespace Drupal\Tests;
    

    This needs to go in a better namespace - for example Drupal\Tests\Core\Field

  3. +++ b/core/tests/Drupal/Tests/AllowedTagsXssTraitDeprecateTest.php
    @@ -0,0 +1,28 @@
    +
    +class FieldDeprecateAllowedTagsXssTraitTest extends UnitTestCase {
    

    This classname needs to match the filename and it needs an @group annotation otherwise test discovery breaks and you see what you see on your patch's test run.

  4. +++ b/core/tests/Drupal/Tests/AllowedTagsXssTraitDeprecateTest.php
    @@ -0,0 +1,28 @@
    +
    +  public function testDeprecation(){
    

    We need to add @expectedDeprecation annotations to test the deprecation.

  5. +++ b/core/tests/Drupal/Tests/AllowedTagsXssTraitDeprecateTest.php
    @@ -0,0 +1,28 @@
    +    $deprecated->fieldFilterXss('Test string');
    +    $deprecated->allowedTags();
    +    $deprecated->displayAllowedTags();
    +    $this->assertTrue(TRUE);
    

    Instead of doing $this->assertTrue(TRUE); we can make assertions against the return values of the deprecated calls.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

This should go in so we can remove these in Drupal 9.

catch’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 3791e77 and pushed to 9.0.x. Thanks! Cherry-picked to 8.8.x and 8.9.x

  • catch committed 8d5344c on 9.0.x
    Issue #2809237 by dmitryl, alexpott, iampuma, muschpusch, louisnagtegaal...

  • catch committed 2bbee70 on 8.9.x
    Issue #2809237 by dmitryl, alexpott, iampuma, muschpusch, louisnagtegaal...

  • catch committed 855f3b9 on 8.8.x
    Issue #2809237 by dmitryl, alexpott, iampuma, muschpusch, louisnagtegaal...
catch’s picture

Status: Fixed » Closed (fixed)

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