[wp-hackers] is there a hook firing right after the </html>?

Nikola Nikolov nikolov.tmw at gmail.com
Mon Feb 2 23:02:47 UTC 2015


Quote from http://php.net/manual/en/function.register-shutdown-function.php
:

"The shutdown callbacks are executed as the part of the request, so it's
possible to send output from them and access output buffers."

Nikola

On Tue, Feb 3, 2015 at 1:00 AM, Haluk Karamete <halukkaramete at gmail.com>
wrote:

> Otto,
>
> Are you saying that by the time ( shutdown_action_hook ) runs, PHP has
> already cleared the output_buffer automatically? or am I misunderstanding
> you?
> I though PHP's internal shutdown functions would run only and only after
> the last line of script has been executed...  Since wordpress is still
> running at that time, why would PHP clear the output buffer?
>
> In that case, I won't be able to use the 'shutdown' hook for my purpose.
>
>
>
>
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L601
>
> 601
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L601
> >
> /**602
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L602
> >
> *
> Runs just before PHP shuts down execution.603
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L603
> >
>  *604
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L604
> >
> *
> @since 1.2.0605
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L605
> >
> *
> @access private606
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L606
> >
>  */607
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L607
> >
> function shutdown_action_hook() {608
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L608
> >
>       /**609
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L609
> >
>        * Fires just before PHP shuts down execution.610
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L610
> >
>        *611
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L611
> >
>        * @since 1.2.0612
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L612
> >
>        */613
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L613
> >
>       do_action( 'shutdown' );614
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L614
> >
> 615
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L615
> >
>       wp_cache_close();616
> <
> https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/load.php#L616
> >
> }
> That means,
>
> On Mon, Feb 2, 2015 at 1:34 PM, Otto <otto at ottodestruct.com> wrote:
>
> > On Mon, Feb 2, 2015 at 3:21 PM, Haluk Karamete <halukkaramete at gmail.com>
> > wrote:
> >
> > > > Output buffer callbacks are automatically called at the conclusion of
> > the
> > > > script.
> > >
> > > Automatically called bhy WordPress?
> >
> >
> >
> > No, by PHP itself, actually.
> >
> > When you create an output buffer using ob_start() and fail to clear it
> with
> > an appropriate ob_end_* call, then PHP will flush the output buffer at
> the
> > end of script execution.
> >
> > Notably, this actually happens before any callbacks that were passed to
> > register_shutdown_function() are called. Shutdown functions don't get the
> > contents of the output buffer.
> >
> > -Otto
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list