Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up of #1937600: Determine what services to register in the new Drupal class
Replace all calls to the flood service with Drupal::flood(). Postponed on #1938390: Convert contact_site_page and contact_person_page to a new-style Controller
Comment | File | Size | Author |
---|---|---|---|
#26 | drupal-replace-calls-to-flood-service-1957152-26.patch | 3.87 KB | saltednut |
#26 | interdiff.txt | 654 bytes | saltednut |
Comments
Comment #1
BerdirInstructions:
Search & replace all calls to drupal_container()->get('flood') or Drupal::service('flood') with the mentioned method. Note that calls within namespaced classes (have a namespace line and are in the lib/ folder) needs to be "\Drupal::...".
Comment #2
saltednutThere are no more calls to
drupal_container()->get('flood')
but there are 3 calls to\Drupal::service('flood')
$ ack -a "service\(\'flood"
Let's see how this goes...
Edit: I think this is open again since #1938390: Convert contact_site_page and contact_person_page to a new-style Controller is fixed? If not, feel free to postpone again.
Comment #3
dawehnerGiven that the patch is not really big we should inject the dependencies properly here.
Comment #4
saltednutGood point.
Comment #5
saltednut!
Comment #6
dawehnerNo reason to document this. just call parent::__construct($entity_manager);
So we should/could also inject config? I know we would need probably a lot more but this would be good for now.
Does anyone know why flood is part of \Drupal even it is certainly not used often in drupal sites?
Comment #7
saltednutShould we document the flood control mechanism or just pass them both in __construct() ?
I thought about that but I didn't know if I COULD inject config. Will look into that.
Your guess is as good as mine, working on this issue is the first time I've seen the flood control mechanism.
Comment #8
saltednutWould using the flood control mechanism help fix errors like this one that I see every time I load the testing suite for the first time?Edit: No, the Flood Control Mechanism does things like checking whether a user is allowed to proceed with the specified event - ie: to prevent a user from spamming the contact form.
Comment #9
saltednutRe #6.1 and #6.2
Comment #10
saltednutComment #11
saltednutComment #12
dawehnerNitpick: Is there any special reason not lave out the documentation for the config factory?
Thank you!
Comment #13
saltednutDo you mean this? I thought it was best practice to include the @param docblocks but we can remove if thats the common pattern. Its just my ignorance, really.
Edit: worked this out in IRC, he was referring to the protected var...
Comment #14
saltednutAdding the variable.
Comment #15
saltednutComment #16
ianthomas_uk$entity_manager also needs documenting (you need to document the parameter, but you don't need to add or set the new member variable, becuase that's done by the parent class).
I expect this can be replaced with $this->containter->get('flood')
Comment #17
saltednutRe 16.1 - I think this patch should do it for the parameter documentation...
Re 16.2 - You were right!
Comment #19
ianthomas_uk#15 is a known random failure (i.e. not an issue with the patch). Hopefully #17 will be green.
Comment #20
dawehnerIn tests we though use \Drupal::flood() directly, for various reasons.
Comment #21
ianthomas_ukPlease can you explain or link to previous discussion? I thought we tried to use DI whereever possible.
Comment #22
dawehnerNote: This is a test class.
Comment #23
ianthomas_ukSee #2087751: [policy, no patch] Stop using $this->container in web tests
Comment #24
saltednutShould we change it back to \Drupal::flood() in /core/modules/system/lib/Drupal/system/Tests/System/FloodTest.php ?
Comment #25
ianthomas_ukYeah. It's not a biggie either way, but we probably shouldn't change that line until that debate is settled, so let's go back to what you had before.
Comment #26
saltednutComment #27
znerol CreditAttribution: znerol commented#26 addresses all the comments from previous reviews. Patch applies, verified the flood mechanism manually on local install, this is good to go.
Comment #28
dawehnerNice!
Comment #29
alexpottCommitted 8d98947 and pushed to 8.x. Thanks!