Support from Acquia helps fund testing for Drupal Acquia logo

Comments

abhishek-anand created an issue. See original summary.

abhishek-anand’s picture

abhishek-anand’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: memory_protection-2688313-2.patch, failed testing.

abhishek-anand’s picture

abhishek-anand’s picture

Status: Needs work » Needs review
tedbow’s picture

@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.

Status: Needs review » Needs work

The last submitted patch, 7: memory_protection-2688313-7.patch, failed testing.

tedbow’s picture

Actually I changed a method signature but didn't change the calls. Will update the patch when I am back in a hour.

tedbow’s picture

Status: Needs work » Needs review
FileSize
10.5 KB
3.06 KB

Ok 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.

tedbow’s picture

@abhishek-anand I think if my changes look good to you then it ready for RTBC

abhishek-anand’s picture

Status: Needs review » Reviewed & tested by the community

@tedbow yes it looks good to me. Thanks!

Berdir’s picture

Status: Reviewed & tested by the community » Needs work

I 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.

+++ b/src/Lock/LockMemcache.php
@@ -53,10 +54,10 @@ class LockMemcache {
     // First, ensure cleanup.
     if (!isset(self::$locks)) {
       self::$locks = array();
-      ultimate_cron_register_shutdown_function(array(
+      \Drupal\ultimate_cron\UltimateCronShutdown::registerShutdownFunction([
         'Drupal\ultimate_cron\Lock\LockMemcache',
-        'shutdown'

how can we call a non-static method statically?