Closed (fixed)
Project:
Simplenews
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Nov 2021 at 11:49 UTC
Updated:
4 Dec 2021 at 10:29 UTC
Jump to comment: Most recent
In SubscriberExportForm.php there are several uses of the $_GET super global, as indicated by running PHPCS with the DrupalPractice standard in the file, which can be seen in the attached screenshot. As stated by phpcs, $_GET super global must not be accessed directly, the request.stack service should be injected and $stack->getCurrentRequest()->query->get() should be used instead.
Inject the request.stack service and use $stack->getCurrentRequest()->query->get() instead.
| Comment | File | Size | Author |
|---|---|---|---|
| simplenews-get-super-global-phpcs.png | 146.04 KB | marcos_lima |
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
Comment #3
marcos_lima commentedRemoved the GET super global uses and opened an MR. Since the
request_stackalready has a blueprint to be injected inFormBase(see code below), which is extended bySubscriberExportForm.php, I used that to implement the injection.And since we cannot use isset() on the result of an expression, I needed to assign the request to a variable first so then we could keep the current logic, like:
Comment #4
marcos_lima commentedThank you kindly for the code review @Berdir. Assigning myself to implement and test the proposed changes.
Comment #5
marcos_lima commentedI made a commit implementing the changes that @Berdir proposed in the MR, which resulted in a much cleaner fix.
Comment #6
adamps commentedThanks looks good.
$this->getRequest()->queryis present 6 times in the same function so please can we save it in a local variable$query?Comment #7
marcos_lima commentedThanks for the review @AdamPS! Made a commit addressing what you suggested in #6.
Comment #10
adamps commentedThanks