Needs work
Project:
Gutenberg
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Dec 2021 at 19:42 UTC
Updated:
25 Oct 2025 at 11:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
andregp commentedI'm working on this :)
Comment #3
andregp commentedHere is a partial solution (this patch solves all errors/warnings besides the dependency injection ones). I'll talk with the maintainer to see if he's interested on fixing the dependency injection warnings too.
Comment #4
andregp commentedTalked with @marcofernandes on slack and he said I can keep with the fixes. So, I'll work on these dependency injection changes.
Comment #5
andregp commentedFinally I did it.
I replaced the code and made the necessary changes to solve all 14 warnings of dependency injection on the files:
src/Controller/SearchController.php
src/Controller/ReusableBlocksController.php
src/Controller/BlocksController.php
src/BlockProcessor/ReusableBlockProcessor.php
src/BlocksRendererHelper.php
src/Service/MediaService.php
I'm sending the patch to solve all issues, an inter-diff between #3 and #5 patches, as well a .txt file with some of the links/documents/patches that I used to learn how to replace and fix the calls that needed dependency injection.
Comment #6
andregp commentedJust a tip for whoever will review, to test the changes in each class I used the following paths:
Comment #7
tmaiochi commentedComment #8
tmaiochi commentedHey @andregp, the branch was updated recently, so I couldn't applied the patch. I think you'll need to do some updates in patch.
Comment #9
marcofernandes commentedYep, sorry about that. I had to merge the Gutenberg core library update.
Comment #10
andregp commentedNo problem, I'll work on a reroll.
Comment #11
andregp commentedHere is it! :)
Comment #12
tmaiochi commentedI'll review this.
Comment #13
andregp commentedSorry, fixing a typo on previous patch.
Comment #14
andregp commentedSo, the patch #13 only solves the old phpcs errors. If we run the phpcs check in the src/ directory again (after applying the patch #13) we get more errors (as you can see on the txt file bellow).
Here is a patch that addresses all the errors (the "old" and "new" ones).
Comment #15
andregp commentedI'm sorry I should review my patches more carefully before sending them here...
Another typo fixed (I hope it's the last one).
Comment #16
tmaiochi commentedSteps performed:
(1) Installed module
(2) Reproduced the issue.
(3) Applied patch.
(4) Code review on changes.
(5) Tested again with patch, issue resolved.
The patch #15 resolve all phpcs messages, and the module still work well.
Comment #18
marcofernandes commentedThanks andregp and tmaiochi.
Valeu, cara. 😇
Comment #19
marcofernandes commentedI missed this on my review:
And it's breaking the media browser.
Comment #20
marcofernandes commentedAlso, it seems, since we don't have a dependency with Media and Media Library, dependency injection for MediaLibraryUiBuilder will fail if those modules are disabled.
Comment #22
marcofernandes commentedComment #23
marcofernandes commentedComment #24
andregp commented@marcofernandes oh, sorry. I'll fix it...
Comment #25
andregp commentedHere is the new patch. I fixed the error on
if (in_array($media->getSource()->getPluginId(), [. And reverted the dependency injection for MediaLibraryUiBuilder.I also added a @codingStandardsIgnoreLine and a comment with this issue's link so people know why the dependency was left there.
There is also a new case of Drupal calls (which is accused by the phpcs) on src/Controller/SearchController.php, line 57 (84 after this patch), but I left it there as it's from a recent commit and also seems temporary (there is already a @todo tag to improve the code).
Comment #26
tmaiochi commentedI'll do this review!
Comment #27
tmaiochi commentedSteps performed:
(1) Installed module
(2) Reproduced the issue.
(3) Applied patch.
(4) Code review on changes.
(5) Tested again with patch, issue resolved.
The patch fixed all PHPCS messages in src, except by a Drupal calls, but how was said in comment #25 seems temporary. And fixed the error on
if (in_array($media->getSource()->getPluginId(), [.. The module is working fine as far as I can test.Comment #28
avpadernoThe issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, report which command has been used, which arguments have been used, and which report that command shown.
Comment #29
avpadernoComment #30
indrapatil commentedComment #31
indrapatil commentedComment #32
avpadernoComment #33
arpitk commentedWorked on fixing remaining issue after patch #25. fixed Drupal calls. Please review.
Thanks!
Comment #34
yashaswi18 commentedTried applying the patch provided in #33, got the following error :
Comment #35
nikolay shapovalov commentedI think no changes to vendor folder needs to be made
Please use command and ignore vendor folder.
I update IS.
Comment #36
nikolay shapovalov commentedI suggest to move to MR workflow to be able to run Gitlab CI phpcs check.
And the status of this task will be transparent.
Set to NW, because patch #33 is not applicable.
Comment #41
avpadernoComment #43
avpadernoThe issue summary has been updated to link to the GitLab CI report for PHP_CodeSniffer. It lists all the PHP_CodeSniffer errors/warnings that should be fixed.
Comment #44
avpadernoFurthermore, looking at #3255691: [META] PHPCS errors on code, which is linked as parent issue, it seems it has been decided to fix the PHP_CodeSniffer errors/warnings in batches, while this issue seems to fix all the the PHP_CodeSniffer errors/warnings at once.
I guess the issue summary needs to be updated.
I would rather fix all the PHP_CodeSniffer errors/warnings in a single issue, since that would mean check the GitLab CI report only once, instead of reading it multiple times to just fix a sub-set of all the reported errors/warnings.