Following from #2908391: Add a rule for expected format of @deprecated and @trigger_error() text we need to fix core to adhere to the two new coding standards.

This issue will fix the @trigger_error() function calls to adhere to standards.
Ideally wait for #3041983: Fix unused imports and update Coder to 8.3.4 so that testing the new sniff will be simpler, but we can use the new coder code by patching it via drupalci - see comment #28. The patch in #28 can be used now to start fixing the standards.

Step 1: Preparation

Open the file core/phpcs.xml.dist and add a line for the sniff of this ticket. The sniff name is in the issue title. Make sure your patch will include the addition of this line.

Step 2: Install & configure PHPCS

Install PHP CodeSniffer and the ruleset from the Coder module:

$ composer install
$ ./vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer

Once you have installed the phpcs package, you can list all the sniffs available to you like this:

$ ./vendor/bin/phpcs --standard=Drupal -e

This will give you a big list of sniffs, and the Drupal-based ones should be present.

Step 3: Prepare the phpcs.xml file

To speed up the testing you should make a copy of the file phpcs.xml.dist (in the core/ folder) and save it as phpcs.xml. This is the configuration file for PHP CodeSniffer. We only want this phpcs.xml file to specify the sniff we're interested in. So we need to remove all the rule items, and add only our own sniff's rule. Rule items look like this:

<rule ref="Drupal.Semantics.FunctionTriggerError"/>

Remove all of them, and add only the sniff from this issue title. This will make sure that our tests run quickly, and are not going to contain any output from unrelated sniffs.

Step 4: Run the test

Now you are ready to run the test! From within the core/ folder, run the following command to launch the test:

$ cd core/
$ ../vendor/bin/phpcs -p

This takes a couple of minutes. The -p flag shows the progress, so you have a bunch of nice dots to look at while it is running.

Step 5: Fix the failures

When the test is complete it will present you a list of all the files that contain violations of your sniff, and the line numbers where the violations occur.

CommentFileSizeAuthor
#193 3048495-nr-bot.txt90 bytesneeds-review-queue-bot
#182 3048495-nr-bot.txt90 bytesneeds-review-queue-bot
#176 3048495-176.patch32.26 KBquietone
#176 3048495-176.patch32.26 KBquietone
#141 interdiff-3048495-138-141.txt1.8 KBPooja Ganjage
#138 interdiff-3048495-123-138.txt2.86 KBmsuthars
#138 3048495-138.patch65.77 KBmsuthars
#135 interdiff-134.txt20.11 KBPooja Ganjage
#135 3048495-134.patch65.47 KBPooja Ganjage
#131 interdiff_130.txt53.92 KBPooja Ganjage
#130 3048495-130.patch65.77 KBPooja Ganjage
#128 3048495-128.patch64.77 KBPooja Ganjage
#125 3048495-125.patch64.18 KBPooja Ganjage
#123 interdiff_121-123.txt1.7 KBkishor_kolekar
#123 3048495-123.patch65.75 KBkishor_kolekar
#121 3048495-121.patch65.75 KBayushmishra206
#121 interdiff_118-121.txt2.91 KBayushmishra206
#118 3048495-118.interdif-115-118.txt13.13 KBjonathan1055
#118 3048495-118.fix_trigger_error_standard.patch65.72 KBjonathan1055
#115 3048495-115.interdif-113-115.txt1.7 KBjonathan1055
#115 3048495-115.fix_trigger_error_standard.patch67.6 KBjonathan1055
#113 3048495-113.interdif-111-113.txt6.72 KBjonathan1055
#113 3048495-113.fix_trigger_error_standard.patch67.59 KBjonathan1055
#111 3048495-111.interdif-109-111.txt1.72 KBjonathan1055
#111 3048495-111.fix_trigger_error_standard.patch60.87 KBjonathan1055
#109 3048495-109.interdif-106-109.remove-from-ignored-list.txt1.93 KBjonathan1055
#109 3048495-109.interdif-106-109.fix-tests.txt4.96 KBjonathan1055
#109 3048495-109.fix_trigger_error_standard.patch60.8 KBjonathan1055
#106 3048495-106.interdif-104-106.txt3.1 KBjonathan1055
#106 3048495-106.fix_trigger_error_standard.patch56.11 KBjonathan1055
#104 3048495-104.interdif-103-104-reroll.txt18.86 KBjonathan1055
#104 3048495-104.fix_trigger_error_standard.patch57.97 KBjonathan1055
#103 3048495-103.interdif-102-103-grammar-fixes.txt11 KBjonathan1055
#103 3048495-103.interdif-102-103-four-new-warnings-corrected.txt3.36 KBjonathan1055
#103 3048495-103.interdif-102-103-do-not-ignore.txt2.55 KBjonathan1055
#103 3048495-103.fix_trigger_error_standard.patch56.45 KBjonathan1055
#102 interdiff_3048495_100-102.txt9.26 KBankithashetty
#102 3048495-102.patch53.29 KBankithashetty
#100 3048495-100.patch43.88 KBravi.shankar
#96 interdiff_85-93.txt12.07 KBrajandro
#94 interdiff_85-92.txt10.34 KBrajandro
#93 3048495-93.patch41.93 KBrajandro
#92 3048495-92.patch40.2 KBrajandro
#90 3048495-90.patch32.65 KBrajandro
#86 interdiff_82-85.txt2.89 KBrajandro
#85 interdiff_82-85.patch2.89 KBrajandro
#85 3048495-85.patch32.75 KBrajandro
#82 interdiff_80-82.txt2.55 KBrajandro
#82 3048495-82.patch30.63 KBrajandro
#80 interdiff_75-80.txt2.96 KBmunish.kumar
#80 3048495-80.patch31.57 KBmunish.kumar
#75 interdiff_71-75.txt6.73 KBrajandro
#75 3048495-75.patch32.75 KBrajandro
#71 interdiff_68-71.txt16.05 KBrajandro
#71 3048495-71.patch37.3 KBrajandro
#68 3048495-68.patch37.25 KBrajandro
#65 3048495-65.patch37.26 KBkishor_kolekar
#63 interdiff-58-55.txt19.12 KBkishor_kolekar
#62 interdiff-55-58.txt19.12 KBkishor_kolekar
#61 interdiff-58-55.txt25.29 KBkishor_kolekar
#61 3048495-58.patch36.11 KBkishor_kolekar
#55 3048495-55.patch34.59 KBandypost
#55 interdiff.txt25.46 KBandypost
#54 3048495-54.patch19.09 KBandypost
#53 3048495-53.patch20.94 KBandypost
#53 interdiff.txt18.61 KBandypost
#52 3048495-52.patch2.33 KBandypost
#50 3048495-50.show-trigger-error-coding-standards-messages.patch2.35 KBjonathan1055
#47 3048495-47.show-trigger-error-coding-standards-messages.patch2.21 KBjonathan1055
#46 3048495-46.show-trigger-error-coding-standards-messages.patch2.21 KBjonathan1055
#35 3048495-35.trigger_error_standard.patch123.48 KBjonathan1055
#33 3048495-33.trigger_error_standard.patch9.27 KBjonathan1055
#28 3048495-28.trigger_error_standard.patch9.74 KBjonathan1055
#27 3048495-27.fix_trigger_error_standard.patch10.41 KBjonathan1055
#25 3048495-25.fix_trigger_error_standard.patch9.93 KBjonathan1055
#23 3048495-23.fix_trigger_error_standard.patch9.92 KBjonathan1055
#19 3048495-19.fix_trigger_error_standard.patch9.22 KBjonathan1055
#5 3048495-5.fix_trigger_error_standard.patch9.28 KBjonathan1055
#21 3048495-21.fix_trigger_error_standard.patch9.7 KBjonathan1055
#4 3048495-phpcs-change.txt511 bytesnaveenvalecha

Issue fork drupal-3048495

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

naveenvalecha’s picture

Title: Fix core for @trigger_error coding standards » Fix Drupal.Semantics.FunctionTriggerError coding standard
Issue summary: View changes
Issue tags: +Coding standards
StatusFileSize
new511 bytes

Retitling to better reflect the issue.
Updating issue summary.Attaching the file which only includes the coding standard rule change

jonathan1055’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new9.28 KB

Thanks naveenvalecha.
Here's a patch which runs just the TriggerError sniff, and does not do any phpunit testing. "Build Sucessful" is what it will show when done.

jonathan1055’s picture

798 @trigger_error standards messages. Not too bad. 3mins run time.

Many of the messages contain text like "and will be removed in 9.0.0". As this is not part of the required standard for trigger_error, but is very useful info. I suggest that this is simply moved into the %extra-info% part of the message. Even though this is free text, it would be helpful to change "in" to "from" so that we start getting used to the standard which is used in @deprecated comment tags.

lendude’s picture

Some reporting weirdness, probably caused by sprintf() inside the trigger_error ?

FILE: /Applications/MAMP/htdocs/d8/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
-----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------
77 | ERROR | The deprecation message ) does not match the standard format: %thing% is deprecated in %in-version%. %extra-info%. See %cr-link%
-----------------------------------------------------------------------------------------------------------------------------------------------

Might need a tweak in the regex? Didn't investigate too deeply

jonathan1055’s picture

Thanks for the feedback. I'll check core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php and see what I can do.

jonathan1055’s picture

jonathan1055’s picture

@Lendude I've identified the problem and added a patch to fix it, plus test data coverage, on #3049093: Cater for sprintf() inside @trigger_error call

xjm’s picture

Hmmmm I was massively confused by #6 until I read through #2908391: Add a rule for expected format of @deprecated and @trigger_error() text again and saw that the IS of that issue is not accurate... or, at least, does not correspond to the coder rule that was committed. The rule that was committed is instead an implementation of an alternate proposal in #3024461-56: Adopt consistent deprecation format for core and contrib deprecation messages (that I actually think I disagree with).

Edit: Actually, looks like the IS is internally inconsistent, and that's caused the issue.

xjm’s picture

So under the proposal that the rule was implemented for, everything should become

It will be removed before 9.0.0. Other things you should know.

instead of

[...] and will be removed before 9.0.0. Other things you should know.

xjm’s picture

...OK so it looks like the trigger error format and deprecated docblock format don't match, which I think is totally wrong. Hrmmmmm....

Thanks @jonathan1055 for investigating this!

jonathan1055’s picture

Hi xjm,
I think you have answered your question in your comment in #13. The issue summaries of #2908391: Add a rule for expected format of @deprecated and @trigger_error() text and #3024461: Adopt consistent deprecation format for core and contrib deprecation messages do both match the new coder rules added. However, the agreed standard was that @trigger_error() would not force the second part of the text "and will be removed" whereas the docblock @deprecated tag does force this. I drew attention to this question in #71 before the consultation period started, but no further objections were raised.

No Core work has been committed to fix the messages, and I'd be quite happy to add that extra part into the sniff I wrote. But it would need full discussion on #3024461: Adopt consistent deprecation format for core and contrib deprecation messages before we did that.

lendude’s picture

FILE: core/modules/taxonomy/src/Entity/Term.php
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
276 | ERROR | The deprecation message '::bundle() instead to get the vocabulary ID.' does not match the standard format: %thing% is deprecated in %in-version%. %extra-info%. See %cr-link%
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Another one where at least the reporting is missing part of the actual trigger_error(). Again didn't dig too deep.

jonathan1055’s picture

Thanks for the alert. The fix for sprintf has been committed on #3049093-7: Cater for sprintf() inside @trigger_error call
Are you using the full release of coder, or can you try the -dev release which may have fixed this.

jonathan1055’s picture

Just checked and the existing fix does not cater for this, so could you open a new issue on the coder queue please
https://www.drupal.org/project/issues/coder

lendude’s picture

jonathan1055’s picture

Here's a re-roll, due to a committed change in phpcs.xml.dist
This patch is not to be committed, it will just show the current state of core with regard to the new TriggerError sniff.

jonathan1055’s picture

Status: Needs review » Postponed

There are now 826 warning messages for TriggerError in core.

However, work on fixing these should be postponed until any possible change in the standard is agreed and the sniff ammended. The standard was all agreed by 13 March at comment #68 on #3024461-68: Adopt consistent deprecation format for core and contrib deprecation messages but since implementaion of the coder rule there has been further disagreements - read from comment #86

jonathan1055’s picture

In preparation for resuming this issue, here is the same patch as #19 but with composer.json changed to load coder 8.x-3.x-dev not 8.3.2
Not sure if this will work, but it it needed for Klausi's suggested next steps in #2908391-53: Add a rule for expected format of @deprecated and @trigger_error() text

jonathan1055’s picture

That did not load the dev version, it just ran with 8.3.2. The patch to composer.json seemed to be applied ok but did not trigger a rebuild of the dependencies. Maybe the composer.lock file also needs to be updated? I don't have the means to do that currently.

jonathan1055’s picture

Another try

jonathan1055’s picture

The acual testbot build .yml file contained my change

assessment:
    validate_codebase:
      phplint: {  }
      csslint:
        halt-on-fail: false
      eslint:
        halt-on-fail: false
      phpcs:
        sniff-all-files: false
        halt-on-fail: false
        coder-version: ^8.3@dev
    testing: {  }

but coder 8.3 - dev was still not loaded.

jonathan1055’s picture

Status: Postponed » Needs review
StatusFileSize
new9.93 KB

Here's an attempt to require the specific commit in Coder which has the latest changes. Not sure if this is going to work though ...

jonathan1055’s picture

So the patch to composer.json did not affect the build environment. We get

Applying patch 3048495-25.fix_trigger_error_standard.patch
...
Finished patch
... Starting update_build
Replacing build:assessment stage with /var/lib/drupalci/workspace/jenkins-drupal_patches-99586/source/core/drupalci.yml
Finished update_build
... Starting update_dependencies
Finished update_dependencies

with no change to coder. Maybe within crupalci.yml I can apply a patch to coder 8.3.2 to get the latest changes.

jonathan1055’s picture

Before working on drupalci.yml I thought it may be that test dependencies are not recalculated if only /core/composer.json is changed, maybe it needs a change to the root level composer.json, Here's the patch in #25 with an additional (dummy) change to composer.json just to see what happens.

jonathan1055’s picture

StatusFileSize
new9.74 KB

So that made no difference. Now, try to patch coder in drupalci.yml

jonathan1055’s picture

Success! This is now running the latest version of the trigger_error sniff, patched during the host_command section of the drupalci build. The results show 765 coding standards violations, compared to 855 with the old code.

jonathan1055’s picture

Issue summary: View changes
Related issues: +#3048498: [≈Nov. 11] Fix Drupal.Commenting.Deprecated coding standard

Correct issue summary copy/paste typo to reference @trigger_error function not @deprecated doc tag.

gábor hojtsy’s picture

Status: Needs review » Needs work

Ok #3041983: Fix unused imports and update Coder to 8.3.4 just landed, so this can be updated to just enable the rule and see the fails.

gábor hojtsy’s picture

There is also a 103k patch on #3033332: [META] Fix language and consistency of deprecation messages and annotations that I created and may be possible to update to get a jumpstart on this issue :) I am not sure this is doable in one patch but if it is, then that should be closed as duplicate of this one.

jonathan1055’s picture

StatusFileSize
new9.27 KB

OK here is an updated version of the #63 patch with the drupalci.yml coder patch removed. It should give the same results now that core uses coder 8.3.4

I will have a look at that other issue and see. Many of the fixes need "Drupal 8.4.0" changing to "drupal:8.4.0" etc, so a script could be developed for that kind of change.

I may even see if I can utilise the phpcs automatic fixing to assist in making some of the changes, not to add this into coder permenantly, but use it to generate patches which we then apply manually to kick-start the fixing process.

The results above show 767 @deprecated messages, up from 765 yesterday. The sooner we can get this into core the better.

gábor hojtsy’s picture

Ok then. Closing #3033332: [META] Fix language and consistency of deprecation messages and annotations in favor of this one. If the 103k patch is any use from there, please do use it :) If not, then such is life. Carrying over related issues and tags.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new123.48 KB

Taking Gábor's patch as a starter, modifying for the current standard and adding a few more fixed trigger_error messages, here's a first attempt at fixing some of the violations. This only checks the new trigger_error standard, and I know that the full tests will need to be run to ensure that the tests for expected deprecations also match the new messages. But that can be done when the main work is complete, as the full test run takes much longer than just running phpcs.


[edit]
This patch has reduced the errors by 52, from 767 to 715, a reduction of 7%. Lots more work needed.
gábor hojtsy’s picture

Yeah the reason I made #3033332: [META] Fix language and consistency of deprecation messages and annotations a meta originally was that the total patch for fixing this would be a megabyte possibly :D I don't think maintaining that patch is sensible. So we probably want to break this down to smaller tasks.

Then we should figure out how to define if a part succeeded. This 123k patch reducing fails by 52 is useful.

  1. We can assume it did not introduce new ones and/or that it fixed all the ones it touched. Or we can build tooling around comparing the fails from before/after to be 100% sure.
  2. Or we can just say a reduction of 52 sounds good, let's commit this and when it goes down to real small numbers, if we need to touch one or two of these again because they were not completely fixed at first, that is accepted.

I would lean to this later method. That said, I was never involved with a coding style update in core of this magnitude. Its big, but its very useful also for building tooling around the resulting standard messages.

It makes automation of a report like http://hojtsy.hu/blog/2019-may-24/analysis-top-uses-deprecated-code-drup... a piece of cake :)

jonathan1055’s picture

Yes the patch will be huge, so I would also lean towards your option 2. Get some fixes committed, then it is easier to see the remaining ones.

We need to remember to run the legacy tests that check expected deprecation messages before any commit, to make sure that we have fixed both the source and the test at the same time. Maybe I can add that into the drupalci.yml change. Don't want to run the entire test suite as that uses unnecessary resource (and is slow)

I have had sucess on #3048498-17: [≈Nov. 11] Fix Drupal.Commenting.Deprecated coding standard where I have automated the fixing of common faults using the PHPCS fixable error functionality. 389 fixed out of 960 = 40.5% and I expect be able to use that functionality for the Trigger_error fixes too.

gábor hojtsy’s picture

@jonathan1055: thanks, running test would be important yeah otherwise we risk breaking branch tests.

This patch also fixes a bunch of @deprecated, so if we are to split along those lines, we need to make sure the two messages end up being the same across different patches and then remove those from this patch.

gábor hojtsy’s picture

Status: Needs review » Needs work

@jonathan1055 can you help break out a portion to an issue, maybe our current portion and make sure the core test suite also runs on it, then I can review and RTBC :D Thanks!

jonathan1055’s picture

Status: Needs work » Needs review

OK yes I could do. However, I have done more work on #3048498-20: [≈Nov. 11] Fix Drupal.Commenting.Deprecated coding standard and that automated patch now fixes 55% of the problems (520 / 930). Would you like me to break out that issue so we can fix that 55% first? I will also work on developing automated fixes for this trigger_error issue, but I've not started it yet. We'd have a bigger win with that other issue. Happy either way, just wanted to point it out.

[edit - unintentional change of status, that seems to happen a lot on d.o. when an issue page is refreshed to view a new comment]

jonathan1055’s picture

Status: Needs review » Needs work

Unintentional change of status above, that seems to happen a lot on d.o. when an issue page is refreshed to view a new comment.
Putting back to Needs Work.

jonathan1055’s picture

Re-ran patch #33 (the plain one with no code fixes) which now shows core is up to 793 trigger_error faults. I am going to work on automating the fixes for these.

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.

gábor hojtsy’s picture

jonathan1055’s picture

I am working on writing some automated fixes for @trigger_error like I did for @deprecated.

Changing parent issue to the general coding standards issue, as the original parent was a one-off, is closed, and is no longer the best parent.

jonathan1055’s picture

Patch #46 will show all the @trigger_error coding standards messages.

jonathan1055’s picture

StatusFileSize
new2.21 KB

Ignore #46, it produced no phpcs output due to

ERROR: Ruleset /var/www/html/core/phpcs.xml.dist is not valid
- On line 343, column 3: expected '>'
- On line 344, column 1: Premature end of data in tag ruleset line 2

because I missed the trailing backslash in the tag.

jonathan1055’s picture

Right, now have something to work with: 876 trigger_error messages, split as follows:
TextLayout - 640
See Url - 72
Deprecation-version - 90
Removal-version - 74

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jonathan1055’s picture

Here's a patch, same as #47, but for Core 9.1 and 9.0
There are some @trigger_error coding standards faults in D9 as we have not fixed any of these yet, in any core version.

andypost’s picture

Only 41 left and all of them are deprecated formatting

andypost’s picture

StatusFileSize
new2.33 KB

checking now

andypost’s picture

StatusFileSize
new18.61 KB
new20.94 KB

Fix wording and messages to have less remains

andypost’s picture

StatusFileSize
new19.09 KB

One more patch to make sure nothing broken (full CI tests run)

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new25.46 KB
new34.59 KB

Added remaining 30 places to ignore (inline) and tuned messages for methods

jungle’s picture

Thanks @andypost!

+++ b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module
@@ -14,9 +14,10 @@
+  // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/system/tests/modules/deprecation_test/src/Deprecation/DrupalStandardsListenerDeprecatedClass.php
@@ -2,6 +2,7 @@
+// phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/system/tests/modules/deprecation_test/src/Deprecation/FixtureDeprecatedClass.php
@@ -2,6 +2,7 @@
+// phpcs:ignore Drupal.Semantics.FunctionTriggerError

Ends with a full stop?

+++ b/core/lib/Drupal/Component/Render/FormattableMarkup.php
@@ -241,6 +241,7 @@ protected static function placeholderFormat($string, array $args) {
+            // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/lib/Drupal/Component/Utility/DeprecatedArray.php
@@ -31,6 +31,7 @@ public function __construct(array $values, $message) {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -39,6 +40,7 @@ public function offsetExists($offset) {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -47,6 +49,7 @@ public function offsetGet($offset) {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -55,6 +58,7 @@ public function offsetSet($offset, $value) {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -63,6 +67,7 @@ public function offsetUnset($offset) {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -71,6 +76,7 @@ public function getIterator() {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -79,6 +85,7 @@ public function unserialize($serialized) {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -87,6 +94,7 @@ public function serialize() {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/lib/Drupal/Core/Asset/LibraryDiscovery.php
@@ -60,6 +60,7 @@ public function getLibraryByName($extension, $name) {
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php
@@ -20,6 +20,7 @@ public function __get($name) {
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -445,6 +445,7 @@ private function triggerDeprecationError($description, $hook) {
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -558,6 +559,7 @@ public function alterDeprecated($description, $type, &$data, &$context1 = NULL,
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php
@@ -87,6 +87,7 @@ public function doTrustedCallback(callable $callback, array $args, $message, $er
+        // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php
@@ -45,6 +45,7 @@ public function __invoke() {
+                      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module
@@ -14,9 +14,10 @@
+  // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/system/tests/modules/deprecation_test/src/Deprecation/DrupalStandardsListenerDeprecatedClass.php
@@ -2,6 +2,7 @@
+// phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/system/tests/modules/deprecation_test/src/Deprecation/FixtureDeprecatedClass.php
@@ -2,6 +2,7 @@
+// phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
@@ -161,7 +161,9 @@ public function metaRefresh() {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError
...
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php
@@ -126,6 +126,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/modules/views/src/ViewsConfigUpdater.php
@@ -243,6 +243,7 @@ protected function processEntityLinkUrlHandler(array &$handler, $handler_type, V
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -300,6 +301,7 @@ protected function processOperatorDefaultsHandler(array &$handler, $handler_type
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -448,6 +450,7 @@ protected function processMultivalueBaseFieldHandler(array &$handler, $handler_t
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
@@ -96,6 +96,7 @@ protected function tearDown() {
+          // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/tests/Drupal/Tests/ExpectDeprecationTest.php
@@ -18,6 +18,7 @@ class ExpectDeprecationTest extends UnitTestCase {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -29,7 +30,9 @@ public function testExpectDeprecation() {
     @trigger_error('Test isolated deprecation', E_USER_DEPRECATED);
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

+++ b/core/tests/Drupal/Tests/SkippedDeprecationTest.php
@@ -13,6 +13,7 @@ class SkippedDeprecationTest extends UnitTestCase {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

@@ -23,6 +24,7 @@ public function testSkippingDeprecations() {
+    // phpcs:ignore Drupal.Semantics.FunctionTriggerError

Ends with a full stop? If you agree, to search "phpcs:ignore Drupal.Semantics.FunctionTriggerError" and replace with "phpcs:ignore Drupal.Semantics.FunctionTriggerError." would be quick probably.

jonathan1055’s picture

Status: Needs review » Needs work

Why is this being ignored?

--- a/core/modules/views/src/ViewsConfigUpdater.php
+++ b/core/modules/views/src/ViewsConfigUpdater.php
@@ -243,6 +243,7 @@ protected function processEntityLinkUrlHandler(array &$handler, $handler_type, V
     $deprecations_triggered = &$this->triggeredDeprecations['2857891'][$view->id()];
     if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
       $deprecations_triggered = TRUE;
+      // phpcs:ignore Drupal.Semantics.FunctionTriggerError
       @trigger_error(sprintf('The entity link url update for the "%s" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.', $view->id()), E_USER_DEPRECATED);
     }

It should be fixed properly, and all it needs is a seperate sentence for the 'See %url%'

@trigger_error(sprintf('The entity link url update for the "%s" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2857891', $view->id()), E_USER_DEPRECATED);

passes the standard.

Same goes for the other two messages in that file.

kishor_kolekar’s picture

Working on it

jonathan1055’s picture

Thanks kishor_kolekar,
Just a reminder, please add back the temporary change to /core/drupalci.yml which you can find in patch #53. This will mean your tests run only the code validation section, much quicker and save d.o. resource. Then only when we agree that the changes are good, we can remove that temp change and run the full phpunit suite.

jonathan1055’s picture

Also, re @jungle in #56

Ends with a full stop? If you agree, to search "phpcs:ignore Drupal.Semantics.FunctionTriggerError" and replace with "phpcs:ignore Drupal.Semantics.FunctionTriggerError." would be quick probably.

Before you go too far adding the periods at the end, are we sure we actually want this? Core does not currently adhere to that rule anyway, and you can see in phpcs.xml.dist
<exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
Does phpcs understand the sniff if it has a period at the end? Maybe try it with just one of the // phpcs:ignore lines first, don't change them all until we agree. Thanks.

kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new36.11 KB
new25.29 KB

Addressed comment #56,#57,#59
Thanks, jonathan1055
please review the patch.

kishor_kolekar’s picture

StatusFileSize
new19.12 KB

updated inter diff

kishor_kolekar’s picture

StatusFileSize
new19.12 KB
jonathan1055’s picture

Your change to core/drupalci.yml does not look right. Please see how it was done in patch #53

kishor_kolekar’s picture

StatusFileSize
new37.26 KB

please review the patch.

jonathan1055’s picture

Status: Needs review » Needs work

please review the patch.

I will when it applies OK ;-)

rajandro’s picture

Assigned: kishor_kolekar » rajandro

Checking the failed issue for the current(latest) version.

rajandro’s picture

StatusFileSize
new37.25 KB

Reroll the last patch (3048495-65.patch) to apply it with the current version.
Please find the attached patch for more details.

Thanks
Rajandro

cburschka’s picture

Status: Needs work » Needs review

Set to NR to trigger the test.

jonathan1055’s picture

Status: Needs review » Needs work

Nice work @Rajandro now we can see what work needs to be done.
Look back to my comment in #60 and compare patch #55 to #58. You will see my hunch was right that we should not add a period at the end of each of the // phpcs:ignore comments, as that means they are not picked up by phpcs and the line is not ignored. I did try to save @kishor_kolekar from doing this unnecessary work.

When that is done, you can address the three messages which should not be ignore, from #57

rajandro’s picture

Status: Needs work » Needs review
StatusFileSize
new37.3 KB
new16.05 KB

Thank you @jonathan1055 for such detailed input, I have update the patch, let's have a look on this and let me know if you find any discrepancies.

Thanks
Rajandro

rajandro’s picture

@jonathan1055, Please review it once and let me know if I reset drupalci.yml for a complete CI process to test the patch.

Thanks
Rajandro

jonathan1055’s picture

Status: Needs review » Needs work

Thanks @Rajandro this is much better. You have removed the period from the end of 30 'phpcs:ignore' tags, fixed a couple of spaces after // and moved one :ignore to the correct place in SkippedDeprecationTest.php. Good work.

However, there are a few things that still need to be done before you remove the drupalci.yml temporary change:

  1. The three trigger_error calls in core/modules/views/src/ViewsConfigUpdater.php should not be ignored (as I said in #57) so you need to remove those three
    // phpcs:ignore lines in that file.
  2. In core/modules/system/src/Controller/SystemController.php the trigger_error has lost the @ (this was not your error, it was done in patch #58 by accident) and should be put back in.
    -      @trigger_error('The extension.list.module service must be passed to ...
    +      trigger_error('Calling ' . __METHOD__ . '() without $module_extension_list ...
    
  3. in core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php should this really be ignored? There must be a drupal version in which this deprecation was added, can that be found and added?
    +++ b/core/lib/Drupal/Core/DependencyInjection/DeprecatedServicePropertyTrait.php
    @@ -20,6 +20,7 @@ public function __get($name) {
         if (isset($this->deprecatedProperties[$name])) {
           $service_name = $this->deprecatedProperties[$name];
           $class_name = static::class;
    +      // phpcs:ignore Drupal.Semantics.FunctionTriggerError
           @trigger_error("The property $name ($service_name service) is deprecated in $class_name and will be removed before Drupal 10.0.0.", E_USER_DEPRECATED);
           return \Drupal::service($service_name);
         }
    
  4. in core/tests/Drupal/Tests/Core/Theme/RegistryLegacyTest.php and core/tests/Drupal/KernelTests/Core/Theme/RegistryLegacyTest.php the @expectedDeprecation text has been changed (in some earlier patch above) from 'Unsilenced deprecation: Theme functions are deprecated in drupal:8.0.0' but the text is not changed anywhere else. The original message passes standards so there is no need for this change, and it is out of scope and should be removed.
  5. In core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php the @expectedDeprecation text is changed from "Passing a 'transactions' connection option to Drupal\Core\Database\Connection::__construct" but only adds '()'. This message did not fail standards before. However there is no actual @trigger_error for this message in any other D91 file. Has the actual deprecation already been removed? Either way, we do not need to make this change.

Thanks for working on this.

rajandro’s picture

Thank you jonathan1055 again for your guided response. I will work on this and update the patch soon.

rajandro’s picture

StatusFileSize
new32.75 KB
new6.73 KB

Hi @jonathan1055,

I have addressed point 1, 2, 4 and 5 as per your comment #73. Point 3 is still pending, this needs some time to update. I am checking this however meantime if someone has already done this then he/she can take this up.

Please find the updated patch and interdiff with the last patch.

Thanks
Rajandro

rajandro’s picture

Assigned: rajandro » Unassigned
jonathan1055’s picture

Status: Needs work » Needs review

Thanks @rajandro. I've compared the patches and checked the interdiff, and #73 points 1, 2, 4 and 5 have all been addressed.
Regarding #73.3 I am now not sure about this. The version may not be specific as this is a generic function which looks like it is used for many deprecations. I have queued the patch for testing.

jonathan1055’s picture

Status: Needs review » Needs work

That's good.

  1. Just two errors with the new @trigger_error message, remove the period at the end of the see url in ViewsConfigUpdater.php
  2. I also spotted another unrequired change in core/lib/Drupal/Core/Theme/Registry.php where the text has been changed
    -  trigger_error(sprintf('Theme functions are deprecated ...
    +  trigger_error(sprintf('Usage of theme functions is deprecated ....
    

    The message followed standards before, so we should not be changing it here. Sorry I did not spot that before.

Thanks.

munish.kumar’s picture

Assigned: Unassigned » munish.kumar
munish.kumar’s picture

Assigned: munish.kumar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new31.57 KB
new2.96 KB

Hi @jonathan1055

#78 feedback has been addressed, Please review the patch

rajandro’s picture

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

Working on the error will apply the final patch

rajandro’s picture

Assigned: rajandro » Unassigned
Status: Needs work » Needs review
StatusFileSize
new30.63 KB
new2.55 KB
jonathan1055’s picture

Status: Needs review » Needs work

Thanks munish.kumar.

@Rajandro you can't just add // phpcs.ignore to get round the problem. If you look closely it is because the standard requires "is" not "are". This is possibly a failing of the 'relaxed' standard, and that could be improved. However, for this issue maybe we should go back to the changed message that was in patch #75 (that is, forget my point #78.2 and put back the change as it was in patch #75)

rajandro’s picture

Assigned: Unassigned » rajandro

You are right @jonathan1055, It's my bad that I was thinking this is an addition as it was throwing in my local as well. When I deep dive after your comment I noticed this error. Let me work on it.

rajandro’s picture

Assigned: rajandro » Unassigned
Status: Needs work » Needs review
StatusFileSize
new32.75 KB
new2.89 KB

Please review the update patch, I have readded the changes for drupalci.yml to save the test time resources.

Thanks
Rajandro

rajandro’s picture

StatusFileSize
new2.89 KB
jonathan1055’s picture

Thanks @Rajandro this looks good. Comparing #75 to #85 is as expected. All clean regarding coding standards now.

So now looking at the 156 test failures from #82

Remaining self deprecation notices (4)
  1x: The operator defaults update for the "test_content_moderation_state_filter_base_table" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168
    1x in ModerationStateAccessTest::testViewShowsCorrectStates from Drupal\Tests\content_moderation\Functional

Most (if not all) must be to do with this change:

--- a/core/modules/views/src/ViewsConfigUpdater.php
+++ b/core/modules/views/src/ViewsConfigUpdater.php
@@ -300,7 +300,7 @@ protected function processOperatorDefaultsHandler(array &$handler, $handler_type
     $deprecations_triggered = &$this->triggeredDeprecations['2869168'][$view->id()];
     if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
       $deprecations_triggered = TRUE;
-      @trigger_error(sprintf('The operator defaults update for the "%s" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.', $view->id()), E_USER_DEPRECATED);
+      @trigger_error(sprintf('The operator defaults update for the "%s" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168', $view->id()), E_USER_DEPRECATED);
     }

It would be worth trying to fix those in the next patch which runs the full test without the drupalci.yml changes. I have just searched for 2869168 in the entire 9.1.x code source and you'll find it mentioned in core/modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php and in core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php. Same goes for 2857891. Those messages need to be altered to match the same changes as the new @trigger_error text.

Interesting that this shows 156 places where core 9.1 is using the deprecated code but hiding the messages.

rajandro’s picture

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

Let me check those failed test cases now.

jonathan1055’s picture

Thanks. It should be easy, it is just a case of altering the expected deprecation text, as explained in #87

rajandro’s picture

StatusFileSize
new32.65 KB

I am updating the patch for test case fixing as per findings on #82 and addressing #87 and #89, It will cover the deprecation notice though some Failure cases are still there and I am still working on it.

jonathan1055’s picture

Thanks @rajandro. Yes you fixed the messages for 2857891 and 2869168 in /DeprecationListenerTrait.php and that has had a big improvement, 156 failures down to just 4. It looked like those two were going to cover the majority of the failures.

Done a quick scan of the test failures.

  • Fail 1 KernelTests\Core\Database\ConnectionTest involves 2278745
  • Fail 2 KernelTests\Core\Theme\RegistryLegacyTest involves 1831138 'Theme functions are deprecated' -> 'Usage of theme functions is deprecated'
  • Fail 3 Tests\views\Kernel\ViewsConfigUpdaterTest 2857891 x2, 2869168, 2900684
  • Fail 4 Tests\Core\Theme\RegistryLegacyTest involves 1831138 'Theme functions are deprecated'

You can search for those numbers to find the places in the codebase where the expected deprecation messages need to be altered to match the new text. Hope that helps to give you a starter for where to find the lines to change.

rajandro’s picture

StatusFileSize
new40.2 KB

Hi @jonathan1055, I have done this fixing and updating the patch now. Though now checking your message with all details, thank you.

PS: In addition to your comment of #91, the period at the end of the line was throwing error on my local, I have updated it as well

Let's see how this patch works for this fixing.

rajandro’s picture

StatusFileSize
new41.93 KB

Fixing those two errors. Let's check the updated patch.

rajandro’s picture

Assigned: rajandro » Unassigned
Status: Needs work » Needs review
StatusFileSize
new10.34 KB

Seems everything looks fine now, moving this to NR

jonathan1055’s picture

Thanks @rajandro, this is good. I presume the interdiff is just named wrong, I've compared and I think it is from 85 to 93 (not 92)

The only thing I want to check is

--- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -116,8 +116,8 @@ public static function isDeprecationSkipped($message) {
-      '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.%',
-      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.%',
+      '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2857891.%',
+      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168.%',

I don't know exactly how the DeprecationListener works, but it would appear that the period after the two urls should be removed to match the actual message. But then, I don't know why the tests did not fail, unless of course those listeners are not actually checked for. The % is just a wild-card and I do not think that the period in .% is part of the pattern matching. Needs someone with more knowledge of DeprecationListenerTrait to answer this.

rajandro’s picture

StatusFileSize
new12.07 KB

Sounds fine to me jonathan1055. Let's see if this needs any changes.
I am adding the interdiff of #85 to #93

Thanks
Rajandro

jonathan1055’s picture

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

I re-tested patch #93 and it needs a re-roll

ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar
jonathan1055’s picture

Hi ravi.shankar
When you do the re-roll, please can you also include add in the changes to drupalci.yml that are at the top of patch #85. This will mean we get quicker test results and do not waste resources on drupal.org testbot. Then only when the coding standards all pass, we can re-run without the drupalci.yml changes, to actually run the full test suite. Thanks.

ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new43.88 KB

Hi jonathan1055

Here I have added the reroll of patch #94 and also included the changes of drupalci.yml file from patch #85 as you suggested in comment #99.

jonathan1055’s picture

Status: Needs review » Needs work

Thanks for the re-roll, that's great. At least the patch applies now and with the drupalci changes we get quick coding standards output and do not waste resources.

However, you can see there are 12 trigger_error coding standards. These must be new faults in the core source code, added since patch #93 on 17 June. This shows the benefit of trying to get these coding standards fixed and then the Coder sniff enabled for Core. We now have to fix these 12 messages here, instead of on the various issues where they were introduced.

To test this sniff locally, you can run

phpcs --standard=Drupal --sniffs=Drupal.Semantics.FunctionTriggerError -s --colors .

Without any patch, we get

---------------------------------------------------------
A TOTAL OF 46 ERRORS AND 5 WARNINGS WERE FOUND IN 32 FILES
---------------------------------------------------------

and with patch #100 we get

---------------------------------------------------------
A TOTAL OF 10 ERRORS AND 2 WARNINGS WERE FOUND IN 9 FILES
---------------------------------------------------------

So at least we are fixing 39 messages. Just these 12 new ones to sort out. Who wants to take this on? Just assign yourself, so that we don't double up and duplicate effort.

ankithashetty’s picture

Status: Needs work » Needs review
StatusFileSize
new53.29 KB
new9.26 KB

Made the required changes mentioned by @jonathan1055 in #101 in the following patch. Kindly review. Attached an interdiff as well.

Thank you!

jonathan1055’s picture

Hi ankithashetty, thanks for the new patch, which fixes the 12 new warnings from #101. I have made some changes and decided to show them in three separate interdif files, to make it easier to see what has been done.

1. Your changes are all good apart from two, where you have added
// phpcs:ignore Drupal.Semantics.FunctionTriggerError when in fact the message can be corrected and we do not need to ignore it. I have made these corrections (in FormattableMarkup.php and TaxonomyIndexTid.php) and this is shown in 3048495-103.interdif-102-103-do-not-ignore.txt

2. Since your patch on 9th September there are now four new coding standards warning (one can be fixed, the other three have to be ignored). I've done this - see 3048495-103.interdif-102-103-four-new-warnings-corrected.txt

3. I have also spotted some other minor things, grammar improvements, making messages consistent, etc, and these are shown in 3048495-103.interdif-102-103-grammar-fixes.txt

There are a couple of other points outstanding, but I want to test this patch first, so let's see how it runs on drupal.org.

jonathan1055’s picture

There's a lot going on at 9.1.x My branch was up-to-date as at 15 Oct 13:53, but the very next commit 15 Oct 14:00 (just 7 minutes later) was on #3172438: Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead. which caused the re-roll work. Talk about close timing!

andypost’s picture

Sniffers returns 1 error but while patch changes mostly all constructors with this mamba

I think wording needs change to "is required in drupal:10.…"

+ @trigger_error('Calling ' . __METHOD__ . '() without the $file_system argument is deprecated in drupal:9.1.0 and will throw an error in drupal:10.0.0. See https://www.drupal.org/node/2630230',

jonathan1055’s picture

StatusFileSize
new56.11 KB
new3.1 KB

Thanks for the review.

Sniffers returns 1 error

Yes, but confusingly that is nothing to do with this patch, and I have reported it on #3008028-112: Migrate D7 i18n menu links where the fault originated. This is odd, because the core/drupalci.yml file has sniff-all-files: false and that file was not touched in the patch, so should not have been checked.

I think wording needs change to "is required in drupal:10.…"

OK, I have changed that.

Also now that all texts pass the standards patch #106 will run the full set of tests, to check for any place where expected deprecations in tests are not matching the new messages.

Status: Needs review » Needs work

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

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new60.8 KB
new4.96 KB
new1.93 KB

Patch #109 fixes the message in the four failed tests from 106. Also I have removed two dynamic exception messages from DeprecationListenerTrait isDeprecationSkipped() as these are tested explicitly. Those were added in 9.0 but they may not be needed to be ignored anymore in 9.1+

Status: Needs review » Needs work

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

jonathan1055’s picture

OK those dynamic deprecations definitely do still need to be ignored, sorry for the noise. I have put them back in DeprecationListenerTrait.php isDeprecationSkipped(). The pattern was causing confusion earlier (see #95) where the final dot looked like part of the deprecation message but was actually useless as it was a single match-anything character. So I have removed them, and also changes the delimiter to ~ which is very obviously not a wildcard or anything in these two deprecation messages.

-      '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.%',
+      '~The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2857891~',

For info, to test these locally I used --filter=PathPluginTest which is quick and contains both of the deprecations.

jonathan1055’s picture

Status: Needs work » Needs review
jonathan1055’s picture

StatusFileSize
new67.59 KB
new6.72 KB

All the tests pass, but we now have four new @trigger_error deprecation messages to fix, all in a recent commit in #3174662-89: Encapsulate \PDOStatement instead of extending from it. It shows the benefit of getting this patch committed.

Note that I fixed two of the warning messages by changing the string variable interpolation into using sprintf(). There is an open issue in Coder to allow variable interpolation within the trigger_error text - #3178199: Cater for variable interpolation strings in @trigger_error sniff

Status: Needs review » Needs work

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

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new67.6 KB
new1.7 KB

I missed altering two expected deprecations in the tests.

jonathan1055’s picture

All @trigger_error messages adhere to coding standards and all tests pass, so I consider this ready for review by someone else now.

The one coding standard messsage is unrelated and I've reported it on #3178338: Fix coding standard fail committed to core 9.1 and 9.2

longwave’s picture

Status: Needs review » Needs work

Thanks for fixing this up, this is a great help to standardise these messages.

  1. +++ b/core/lib/Drupal/Component/Utility/DeprecatedArray.php
    @@ -31,6 +31,7 @@ public function __construct(array $values, $message) {
    +    // phpcs:ignore Drupal.Semantics.FunctionTriggerError
    

    Should we just use phpcs:disable to ignore this sniff across this entire file?

  2. +++ b/core/lib/Drupal/Core/Database/StatementWrapper.php
    @@ -60,7 +60,7 @@ public function __construct(Connection $connection, $client_connection, string $
    +      @trigger_error(sprintf('StatementWrapper::%s is deprecated in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488', "\${$name}"), E_USER_DEPRECATED);
    

    The string interpolation is a bit weird here, why not just say sprintf('StatementWrapper:$%s...', $name)?

  3. +++ b/core/lib/Drupal/Core/Database/StatementWrapper.php
    @@ -310,7 +310,7 @@ public function getIterator() {
    -    @trigger_error("StatementWrapper::bindColumn should not be called in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488", E_USER_DEPRECATED);
    +    @trigger_error('StatementWrapper::bindColumn is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488', E_USER_DEPRECATED);
    
    @@ -357,7 +357,7 @@ public function bindColumn($column, &$param, int $type = 0, int $maxlen = 0, $dr
    -    @trigger_error("StatementWrapper::bindParam should not be called in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488", E_USER_DEPRECATED);
    +    @trigger_error('StatementWrapper::bindParam is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488', E_USER_DEPRECATED);
    

    bindColumn and bindParam are methods and so should both end in (), as we are touching these lines let's fix this here too.

  4. +++ b/core/lib/Drupal/Core/Theme/Registry.php
    @@ -495,7 +495,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path)
    +          trigger_error(sprintf('Usage of theme functions is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use Twig templates instead of %s(). See https://www.drupal.org/node/1831138', $info['function']), E_USER_DEPRECATED);
    

    Not sure this is quite correct, it's the declaration of theme functions that is the trigger here. Does "Declaring theme functions..." sound better?

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new65.72 KB
new13.13 KB

Thanks @longwave, great review.

  1. Should we just use phpcs:disable to ignore this sniff across this entire file?

    Yes definitely. I had not noticed that the single ignore had been added 8 times and that there are no other deprecations that should be checked. Fixed

  2. The string interpolation is a bit weird

    I agree. I think it ended up that way because initially I just took what was inside the main string in double quotes. Fixed.

  3. bindColumn and bindParam are methods and so should both end in (), as we are touching these lines let's fix this here too.

    Agreed. Done. For accuracy and completeness I have also added () to the deprecation message in function __call($method, $arguments) because that $method argument will only be the plain string

  4. Does "Declaring theme functions..." sound better?

    Yes it does. Fixed.

I've made these required changes to the expected deprecation tests, but only run those specific tests locally (and they pass). Running the full core test suite locally takes too much time and resource, but hopefully all should pass on d.o.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Good spot on the __call() for #118.3.

This looks great now, RTBC from me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
    @@ -74,8 +74,8 @@ public static function isDeprecationSkipped($message) {
    -      '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.%',
    -      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.%',
    +      '~The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2857891~',
    +      '~The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168~',
    

    Why the change to ~ as opposed to %? Looks unnecessary. I don't agree with justification in #111. Yes the . was confusing but actually that's the same ALL the dots in these dynamic deprecation messages. The other dynamic messages have dots properly escaped. Imo using % is fine and inline with the other dynamic messages... but we should escape all the other dots here.

  2. +++ b/core/tests/Drupal/Tests/Listeners/DrupalListener.php
    @@ -97,14 +97,14 @@ public function startTest(Test $test): void {
    -            @trigger_error("Declaring ::$method without a void return typehint in " . get_class($test) . " is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724", E_USER_DEPRECATED);
    +            @trigger_error("Declaring ::$method without a void return typehint in " . get_class($test) . " is deprecated in drupal:9.0.0 and Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724", E_USER_DEPRECATED);
    

    Capital T should lowercased.

ayushmishra206’s picture

Status: Needs work » Needs review
StatusFileSize
new2.91 KB
new65.75 KB

Made the changes requested in #120

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -74,8 +74,8 @@ public static function isDeprecationSkipped($message) {
+      '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2857891~',
+      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168~',

The final character here should be a % too. Plus all the dots should be escaped. See the other dynamic messages skipped above in the code.

kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new65.75 KB
new1.7 KB

worked on comment #122

jonathan1055’s picture

Status: Needs review » Needs work

Plus all the dots should be escaped. See the other dynamic messages skipped above in the code

In addition to escaping the dots, there should be no final dot for these two messages.

-      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168~',
+      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168.%',

That was the source of confusion in #95 and #111 above. The deprecation standard requires no dot at the end of the url (so that the actual usable url could be parsed out if required). The message now has no trailing dot (see core/modules/views/src/ViewsConfigUpdater.php) but the deprecation tests were not failing even when the expected message had a trailing dot. Then I realised that this ending dot simply matches any character as in standard regex syntax.

Pooja Ganjage’s picture

StatusFileSize
new64.18 KB

Hi,

Creating a patch as per the #124 comment.

Please review the patch.

Thanks.

Pooja Ganjage’s picture

Status: Needs work » Needs review
jonathan1055’s picture

Status: Needs review » Needs work

From #122

Plus all the dots should be escaped. See the other dynamic messages skipped above in the code.

Please can you escape the dots as per Alexpott's request in #122 and mentioned again in #124

Pooja Ganjage’s picture

StatusFileSize
new64.77 KB

Hi,

Creating a patch as per the #127 comment.

Please review the patch.

Thanks.

alexpott’s picture

+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -74,8 +74,8 @@ public static function isDeprecationSkipped($message) {
+      '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2857891%',
+      '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described in the change record. See https://www.drupal.org/node/2869168%',

The dots in these strings are still not escaped. Escaped in this instance means drupal:10.0.0. becomes drupal:10\.0\.0\.

Also can an interdiff from #123 to the next patch be created so we can see what's changed. This is a large patch.

Pooja Ganjage’s picture

StatusFileSize
new65.77 KB
Pooja Ganjage’s picture

StatusFileSize
new53.92 KB

interdiff provided for above patch.

jonathan1055’s picture

Hi Pooja,

In #125 the test failed because you have lost one of the changes in core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php

In #128 the additional four test failures was because you removed dots from the messages unnecessarily, and then these did not match with the expected deprecation messages in the tests.

In #130

-      @trigger_error('Calling LibraryDiscoveryParser::__construct() without the $libraries_directory_file_finder argument is deprecated in drupal:8.9.0. The $libraries_directory_file_finder argument will be required in drupal:10.0.0. See https://www.drupal.org/node/3099614', E_USER_DEPRECATED);
+      @trigger_error('Calling ' . __METHOD__ . '() without the $libraries_directory_file_finder argument is deprecated in drupal:8.9.0 and this argument will be required in drupal:10\.0\.0\. See https://www.drupal.org/node/3099614', E_USER_DEPRECATED);

The dots in the actual @trigger_error calls should not be escaped. You only need to escape the two dynamic text messages as explained in #120, #124 and #127. You have done it for every @trigger_error call. Also the patch does not apply, but I've not investigated exactly what is wrong.

Are you happy to continue with this task? That's fine if you do want to, but it is taking a lot of your time, and if you'd prefer me to help get it back to a working patch with all tests passing, just let me know. Or if you want to ask questions, please do, instead of just posting another patch which is not going to work. Happy to help you get this sorted :-)

Jonathan

msuthars’s picture

Assigned: Unassigned » msuthars
Pooja Ganjage’s picture

Updated patch.

Pooja Ganjage’s picture

StatusFileSize
new65.47 KB
new20.11 KB
msuthars’s picture

Assigned: msuthars » Unassigned
Status: Needs work » Needs review
jonathan1055’s picture

Status: Needs review » Needs work

Thank you Pooja and msuthars. This looks nearly right, although the interdiff was no help, as I could not see from which point it was diff'd from. I was expecting only a small set of changes. I manually compared the patches and I think you have fixed the problems introduced since #125.

However, as alexpott said in #122 and I repeated in #124:

all the dots should be escaped.

You need to escape all the dots, so it should be:

 in drupal:9\.0\.0 and is removed from drupal:10\.0\.0\. Module-provided Views configuration should be updated to accommodate the changes described in the change record\. See https://www\.drupal\.org/node/2869168%',

For the next patch, please could you create your interdiff against #123, as requested by alexpott, as that was the last full-reviewed patch. If you have difficulty in making interdiffs, please let me know and I can help, but I don't want to take the work from you if you are doing it.

msuthars’s picture

Status: Needs work » Needs review
StatusFileSize
new65.77 KB
new2.86 KB

@jonathan1055 I made changes in the patch as mentioned in #129 by @alexpott.

alexpott’s picture

#138 looks correct and I've run phpcs locally and it reports no warnings or errors.

jonathan1055’s picture

Yes, the patch #138 looks good. I'm happy for this to be RTBC based on @longwave's RTBC from #119 everything has been addressed that was raised since then.

The interdiff was slightly odd with that single deletion and addition in core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php. I checked the actual patch and there is only one change, and that matches what we had before, so I think it was just a bug in how the interdiff was created, because that code block is repeated incorrectly in the interdiff.

Pooja Ganjage’s picture

StatusFileSize
new1.8 KB

Hi,

@jonathan, I have provided interdiff for the #138 comment as showing only one change into the interdiff file.

Please review the interdiff.

Thanks.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed all the changes since #118 and all looks good to me, so this is RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
+++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
@@ -99,6 +99,7 @@ public function dispatch($event/*, string $event_name = NULL*/) {

@@ -99,6 +99,7 @@ public function dispatch($event/*, string $event_name = NULL*/) {
       // Trigger a deprecation error if the deprecated Event class is used
       // directly.
       if ($class_name === 'Symfony\Component\EventDispatcher\Event') {
+        // phpcs:ignore Drupal.Semantics.FunctionTriggerError
         @trigger_error($deprecation_message, E_USER_DEPRECATED);
       }
       // Also try to trigger deprecation errors when classes are in the Drupal
@@ -108,12 +109,13 @@ public function dispatch($event/*, string $event_name = NULL*/) {

@@ -108,12 +109,13 @@ public function dispatch($event/*, string $event_name = NULL*/) {
       // bridge class as a special case, otherwise it's pointless.
       elseif ($class_name !== 'Drupal\Component\EventDispatcher\Event' && strpos($class_name, 'Drupal') !== FALSE) {
         if (get_parent_class($event) === 'Symfony\Component\EventDispatcher\Event') {
+          // phpcs:ignore Drupal.Semantics.FunctionTriggerError
           @trigger_error($deprecation_message, E_USER_DEPRECATED);
         }
       }

The number of phpcs:ignore lines in this patch, in our own home-grown code as opposed to forked stuff, makes me think we shouldn't add this rule at all. Or if we do, find some way to make it target only @trigger_error() calls with the word 'deprecated' in. This isn't really enforcing code style as it currently is.

alexpott’s picture

One potential improvement would be to update the rule to only check strings... so if it detects a variable then admit defeat and move on.

andypost’s picture

I think if it detects variable in trigger error, it should complain as well but with different message because otherwise we'll never start catch proper messages for it

jonathan1055’s picture

The number of phpcs:ignore lines in this patch, in our own home-grown code as opposed to forked stuff, makes me think we shouldn't add this rule at all.

Just to get some perspective on this, using a quick search in /core there are 227 calls to @trigger_error.*E_USER_DEPRECATED over 84 files. This patch fixes 26 of those and ignores another 26 (over 19 files). That means the standard is already being followed for 77% of the calls and we can increse this to 88% with the patch, and only have to ignore 12%

The individual ignored lines are probably ignored for a variety of different reasons. Some may be able to be changed to follow the standards - the 'ignore' lines were added possibly casually by a variety of developers contributing to the above patches, where the easy fix was not possible. Some of these might be able to be fixed.

IIRC, one of the main points of this rule, when Gabor encourged its introduction, was to make it easy to exract deprecation data for analysis of versions, etc. In those 88% of calls this will be useful and can be done. In the remaining 12% there woud not be any info to gain anyway, because the drupal version is not included.

Should we start to look in detail at those 19 files which have the ignore, to see what can be done to improve the 88% level?

longwave’s picture

Symfony has added a new single-function package to generate deprecation messages in a standard format: https://github.com/symfony/deprecation-contracts/blob/main/function.php

Maybe we should consider adopting this or something similar?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

I've closed #3191426: Change 'will be' to 'is' in deprecation error message as a duplicate. Adding credit here for adityasingh

longwave’s picture

I think the idea in #144 will let us fix most of the ignored cases here. While @andypost has a point in #145 we hopefully will catch most cases of variables being used where they could be fixed strings in code review. The case pointed out in #143 probably should be switched to use fixed strings.

I opened #3226902: @trigger_error deprecation sniff is too strict - allow the message to start with a variable to explore this change.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jonathan1055’s picture

Assigned: Unassigned » jonathan1055
Related issues: +#3226902: @trigger_error deprecation sniff is too strict - allow the message to start with a variable

The last patch was at 9.2 and the issue is now at 9.4. Also #3226902: @trigger_error deprecation sniff is too strict - allow the message to start with a variable is fixed, so here is a plan:

  1. Convert this issue to a fork with MR, to save having to create interdiffs each time
  2. Change drupalci.yml to not run phpunit tests for quicker response and to save resources
  3. Start with initial commit at patch #138 which had general approval
  4. Fix new deprecation coding standards faults introduced since last patch
  5. Remove as many phpcs:ignore as possible, and demonstrate coding standards failures
  6. Change drupalci.yml to load latest Coder -dev and show that those warnings are no longer displayed
  7. Run phpunit tests and correct any deprecation text assertions

jonathan1055’s picture

:-( There are 39 new deprecation failures since the last patch. This is getting tedious to stay on top of.

#153 steps 1,2 and 3 done. Added step 4 to correct new deprecation messages.

jonathan1055’s picture

The current 9.4.x branch has

A TOTAL OF 68 ERRORS AND 16 WARNINGS WERE FOUND IN 60 FILES

With the commit as at patch #138 (which was clean) we get

A TOTAL OF 29 ERRORS AND 10 WARNINGS WERE FOUND IN 32 FILES

I have now fixed the 39 new failures.

jonathan1055’s picture

This commit fixes the messages I missed earlier. For some as-yet unknown reason running phpcs on my local machine ignores the file.module file completely and does not attempt to check it. Renaming to file.module.inc detected the problems, so could fix them. Then I renamed the file back to file.module. That needs investigation, but its a distraction for now.

jonathan1055’s picture

OK. That's clean, so #153 step 4 is done. Now remove some of the phpcs:ignore Drupal.Semantics.FunctionTriggerError lines where the message is just a variable. This will show some failures because we are still using Coder 8.3.14 which does not have the that latest fix yet.

jonathan1055’s picture

#153 step 5 is done.
As expected we get failures where the message is a variable. Now to atempt to run with the latest Coder 8.3.x dev

berdir’s picture

Is it really worth doing that for D9? Wouldn't it be a lot easier to enforce the rule for new deprecations in D10 and onward? It would have to land there first anyway, no?

yogeshmpawar’s picture

Status: Needs review » Needs work
longwave’s picture

Version: 9.4.x-dev » 10.0.x-dev

Agree with @Berdir that we have to do this in 10.0.x first, and the patch there will be mostly completely different - we could decide after that whether it is worth pulling this back to 9.4.x as well.

spokje’s picture

#3262874: Update Coder to 8.3.15 landed, which means Core now comes with drupal/coder 8.3.15 which includes the fix in sniff Drupal.Semantics.FunctionTriggerError #3226902: @trigger_error deprecation sniff is too strict - allow the message to start with a variable

bbrala’s picture

spokje’s picture

Assigned: jonathan1055 » spokje
Issue tags: -Drupal 9

spokje’s picture

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

New MR for 10.0.x-dev based on MR!1894, with significant less changes (since significant less deprecations left in D10) and no drupal/coder:dev trickery needed any more.

bbrala’s picture

Status: Needs review » Reviewed & tested by the community

Went through the changes. I understand why we need to ignore a set of errors in the tests. It might be an option to change them to fit the sniff, but I understand the reasoning to keep them as is.

Changes look good, tests are green. Changing to rtbc :)

daffie’s picture

Status: Reviewed & tested by the community » Needs work

For the 2 nitpicks.

bbrala’s picture

Hmm, think you are right, nice catch.

longwave’s picture

We relaxed the sniff a bit over in https://github.com/pfrenssen/coder/pull/154/files so I think/hope some of the skips can be removed.

spokje’s picture

Thanks @daffie and @longwave.

I've now used Drupal.Semantics.FunctionTriggerError suppression only where it is needed now.
Looking into specific cases as we speak (or rather: as you read).

Any thoughts on if and how we should backport this into the land of 9.x.x-dev?
- Only backport the changed deprecation errors and _not_ the PHPCS sniff?
- Add PHPCS sniff and change all deprecation errors?
- Something completely different?

longwave’s picture

I would go for either "add the sniff and change all errors" or "do nothing in 9.x, make this 10.x only" - core committers tend not to like doing only part of the work and leaving it open for things to be undone later, which could happen in the first option.

jonathan1055’s picture

I would definitely recommend backporting to 9.x otherwise things like #3033165: Parse more information out of deprecation messages will have less value.

quietone’s picture

Version: 10.0.x-dev » 10.1.x-dev
Status: Needs work » Needs review
StatusFileSize
new32.26 KB
new32.26 KB

Once again I can't push after rebasing. I am uploading a patch.

spokje’s picture


Once again I can't push after rebasing.

When that happens to me, I always have success with git push --set-upstream drupal-3048495 HEAD -f
So basically the command from "Or push your current local branch from your Git clone" followed by a -f (for force, use it Luke...)

Probably to late for this occasion, but you might wanna give it a go next time.

Nvm, changing branches is another matter.

The last submitted patch, 176: 3048495-176.patch, failed testing. View results

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Wasn't terrible to review as most of the files were 1 line.

Changes look good and like that it will capture good trigger_error messages.

I haven't seen it before for other coding standard tickets but would a change record be worth it?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

quietone’s picture

Assigned: Unassigned » quietone

I am assigning to myself because I have local changes that I am not able to push. I'll un-assign once that is fixed.

In the meantime there are two new errors that need a link to the CR. The issue, #2551419: Abstract RenderCache into a separate service that is capable of cache redirects in a non-render array-specific way has two CR's but neither of them directly address the removal of the constructor parameter. I'm not sure if one of the CR's should change or a new one is needed. Suggestions?

Here are the errors,

FILE: /var/www/html/core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 88 | ERROR | The trigger_error message 'Injecting  __CLASS__  with the "cache_factory" service is deprecated in drupal:10.1.0, use "variation_cache_factory" instead.'
    |       | does not match the relaxed standard format: %thing% is deprecated in %deprecation-version% any free text %removal-version%. %extra-info%. See
    |       | %cr-link% (Drupal.Semantics.FunctionTriggerError.TriggerErrorTextLayoutRelaxed)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/core/lib/Drupal/Core/Render/RenderCache.php
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 50 | ERROR | The trigger_error message 'Injecting  __CLASS__  with the "cache_factory" service is deprecated in drupal:10.1.0, use "variation_cache_factory" instead.'
    |       | does not match the relaxed standard format: %thing% is deprecated in %deprecation-version% any free text %removal-version%. %extra-info%. See
    |       | %cr-link% (Drupal.Semantics.FunctionTriggerError.TriggerErrorTextLayoutRelaxed)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 25.68 secs; Memory: 6MB
quietone’s picture

Status: Needs work » Needs review

Tests are passing so time for reviews.

spokje’s picture

Status: Needs review » Needs work

I'm afraid the commit of #3375454: Fix version number in deprecation messages for #2551419, ironically an issue by @quietone, now clashes with this MR and it needs Yet Another Rebase (Yar!....)

quietone’s picture

Status: Needs work » Needs review

Rebased the MR

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

All green with the new rule added. So assuming this is good.

longwave’s picture

Status: Reviewed & tested by the community » Needs work

Added some feedback.

quietone’s picture

Status: Needs work » Needs review

Tests are passing, back to NR.

quietone’s picture

Assigned: quietone » Unassigned
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Threads appear to be addressed.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

spokje’s picture

Status: Needs work » Reviewed & tested by the community

Rebased MR, back to RTBC

lauriii made their first commit to this issue’s fork.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

Looks like new non-compliant deprecation messages sneaked in 😅

spokje’s picture

Status: Needs work » Reviewed & tested by the community

Since I was responsible for the faulty new ones, it seems fitting to fix those myself.

Think this can go back to RTBC, since the changes are checked by the new PHPCS rule?

quietone’s picture

Yes, that make sense. And I read the last 3 commits to confirm. This is still RTBC.

quietone’s picture

Status: Reviewed & tested by the community » Needs review

This needed a rebase. Because there were a lot of conflicts, I am setting back to Needs Review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Reading the commits after 198 and changes still look good.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed fd2c134 and pushed to 11.x. Thanks!

I'm not sure we need to enable the new coding standard in 10.1.x but we might choose to backport the fixed strings for consistency. Not sure.

  • alexpott committed fd2c1341 on 11.x
    Issue #3048495 by jonathan1055, quietone, rajandro, Spokje, Pooja...
jonathan1055’s picture

Great to see this committed. Thank you everyone who contributed.

As someone who worked on the original coding standard, the Coder sniff and the early patches on this issue, I would recommend back-porting the strings and enabling the rule in 10.1. One of the original purposes of the standard was to be able to scan source code and get metrics on how many things are deprecated and how many cause triggerError in a particular version of core. That would help with 10 -> 11 upgrades.

alexpott’s picture

@jonathan1055 10.2.x will be cut from the 11.x branch (which really should be named "main" but we can't do that cause reasons).

longwave’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Fixed » Patch (to be ported)

I think we should backport the message changes - usually we do not backport string changes due to translations but these messages do not get translated, and it will make other backports easier.

We don't usually enable new coding standards in patch releases and I see no need to do so here, given any new deprecations will only appear in 11.x.

jonathan1055’s picture

10.2.x will be cut from the 11.x branch (which really should be named "main" but we can't do that cause reasons).

OK, thanks for explaining that. Yes, therefore fix the strings in 10.1 but no need to implement the Coder rule.

jonathan1055’s picture

The commit in #201/202 did not make any changes to phpcs.xml.dist. Earlier patches and MRs contained

--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -123,6 +123,7 @@
   <rule ref="Drupal.Semantics.FunctionT">
     <exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
   </rule>
+  <rule ref="Drupal.Semantics.FunctionTriggerError"/>
   <rule ref="Drupal.Semantics.FunctionWatchdog"/>
   <rule ref="Drupal.Semantics.InstallHooks"/>
   <rule ref="Drupal.Semantics.LStringTranslatable"/>

but this is not present in the commit. So the new Coder rule has not yet been implemented in Core 11.x

What was the source of the commit in #201? Was it MR4216? That had 56 changed files but the commit seems to have only 20.

jonathan1055’s picture

Actually the rule is enabled in core
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/phpcs.xml.dis...
It's just that it was not in the commit shown in #201. Sorry for the noise.

longwave’s picture

@jonathan1055 GitLab only shows 20 files changed per page, if you go to page 3 then you can see the changes to phpcs.xml.dist: https://git.drupalcode.org/project/drupal/-/commit/fd2c13413a20941c10dd0...

jonathan1055’s picture

@longwave Thank you. I should have spotted that.

longwave’s picture

Issue tags: +10.2.0 release notes

Coding standards changes go in the release notes.

longwave’s picture

Version: 10.1.x-dev » 10.2.x-dev
Status: Patch (to be ported) » Fixed

Probably too late to consider backporting this now, let's just mark this as fixed in 10.2.0.

Status: Fixed » Closed (fixed)

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