New hook 'AfterFinalPageOutput' which is called at the end of OutputPage::output()
authorDaniel Werner <daniel.werner@wikimedia.de>
Thu, 5 Jul 2012 14:21:21 +0000 (16:21 +0200)
committerDaniel Werner <daniel.werner@wikimedia.de>
Fri, 7 Sep 2012 07:32:39 +0000 (09:32 +0200)
Called  before final ob_end_flush() which will send the buffered output to the client. This allows for last-minute modification of the output within the buffer by using ob_get_clean().

- patch-set2: moved the hook before OutputPage::sendCacheControl() is called, as suggested by Reedy.

Change-Id: I264a37ac74e0c18ff141f82156e669ece3212c2d

RELEASE-NOTES-1.20
docs/hooks.txt
includes/OutputPage.php

index 8dbb7de..ce40066 100644 (file)
@@ -99,6 +99,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
   replacement, and so on.
 * (bug 34678) Added InternalParseBeforeSanitize hook which gets called during Parser's
   internalParse method just before the parser removes unwanted/dangerous HTML tags.
+* Added new hook AfterFinalPageOutput to allow modifications to buffered page output before sent
+  to the client.
 * (bug 36783) Implement jQuery Promise interface in mediawiki.api module.
 * Make dates in sortable tables sort according to the page content language
   instead of the site content language
index 5b78ed9..3f32b80 100644 (file)
@@ -290,6 +290,12 @@ $revCount: Number of revisions in the XML file
 $sRevCount: Number of sucessfully imported revisions
 $pageInfo: associative array of page information
 
+'AfterFinalPageOutput': Nearly at the end of OutputPage::output() but
+before OutputPage::sendCacheControl() and final ob_end_flush() which
+will send the buffered output to the client. This allows for last-minute
+modification of the output within the buffer by using ob_get_clean().
+$output: The OutputPage object where output() was called
+
 'AjaxAddScript': Called in output page just before the initialisation
 of the javascript ajax engine. The hook is only called when ajax
 is enabled ( $wgUseAjax = true; ).
index b020a8e..7b67144 100644 (file)
@@ -1990,6 +1990,9 @@ class OutputPage extends ContextSource {
                        wfProfileOut( 'Output-skin' );
                }
 
+               // This hook allows last minute changes to final overall output by modifying output buffer
+               wfRunHooks( 'AfterFinalPageOutput', array( $this ) );
+
                $this->sendCacheControl();
                ob_end_flush();
                wfProfileOut( __METHOD__ );