From 2f6430d40d7e7cabbe0524533de4c05b49126f4b Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Thu, 5 Jul 2012 16:21:21 +0200 Subject: [PATCH] New hook 'AfterFinalPageOutput' which is called at the end of OutputPage::output() 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 | 2 ++ docs/hooks.txt | 6 ++++++ includes/OutputPage.php | 3 +++ 3 files changed, 11 insertions(+) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 8dbb7ded77..ce400668a6 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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 diff --git a/docs/hooks.txt b/docs/hooks.txt index 5b78ed98a3..3f32b80f11 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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; ). diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b020a8e7eb..7b67144b30 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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__ ); -- 2.20.1