Make WordPress Core

Ticket #44445: 44445-restrict-call.patch

File 44445-restrict-call.patch, 923 bytes (added by MikeSchinkel, 6 years ago)

This patch restricts the call to register_shutdown_function() to be called only once.

  • wp-includes/cache.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    287287 */
    288288class WP_Object_Cache {
    289289
     290        /**
     291         * Enables register_shutdown_function to only be called once.
     292         *
     293         * @since 4.9.7
     294         * @var bool
     295         */
     296        private static $shutdown_registered = false;
     297
    290298        /**
    291299         * Holds the cached objects.
    292300         *
     
    740748                 * @todo This should be moved to the PHP4 style constructor, PHP5
    741749                 * already calls __destruct()
    742750                 */
    743                 register_shutdown_function( array( $this, '__destruct' ) );
     751                if ( ! self::$shutdown_registered ) {
     752                        register_shutdown_function( array( $this, '__destruct' ) );
     753                        self::$shutdown_registered = true;
     754                }
    744755        }
    745756
    746757        /**