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.
Move memory protection and shutdown function into services
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff.txt | 3.06 KB | tedbow |
#10 | memory_protection-2688313-10.patch | 10.5 KB | tedbow |
| |||
#7 | interdiff.txt | 2.58 KB | tedbow |
#7 | memory_protection-2688313-7.patch | 10.51 KB | tedbow |
#5 | interdiff.txt | 3.47 KB | abhishek-anand |
Comments
Comment #2
abhishek-anand CreditAttribution: abhishek-anand at Acquia commentedComment #3
abhishek-anand CreditAttribution: abhishek-anand at Acquia commentedComment #5
abhishek-anand CreditAttribution: abhishek-anand at Acquia commentedComment #6
abhishek-anand CreditAttribution: abhishek-anand at Acquia commentedComment #7
tedbow@abhishek-anand this looks good but we don't need to use a $GLOBAL variable here I think.
Since the service locator will always bring back the same instance of our service then we could effectively use a protected variable inside our service class as global variable for registering shutdown calls.
Comment #9
tedbowActually I changed a method signature but didn't change the calls. Will update the patch when I am back in a hour.
Comment #10
tedbowOk clean up the functions calls.
So this patch is mostly what @abhishek-anand did in #5 but with removing the need to use $GLOBAL.
I also changed to the signature of registerShutdownFunction
public function registerShutdownFunction(callable $callback, $arguments = []) {
It seems better to have separate parameter for $arguments and have an explicit callable argument.
Comment #11
tedbow@abhishek-anand I think if my changes look good to you then it ready for RTBC
Comment #12
abhishek-anand CreditAttribution: abhishek-anand at Acquia commented@tedbow yes it looks good to me. Thanks!
Comment #13
BerdirI honestly don't know why we need all this code. It was added in a big commit (f39eef85b7eb1cc5048a0709f97637f71b81cc68), with no explanation on why the normal shut down functions isn't good enough.
Also, event subscribers are not the same, they are not guaranteed to run, which is exactly why core still uses drupal_register_shutdown_function() in e.g. the lock service.
how can we call a non-static method statically?