Requests for comment/OutputPage refactor

From mediawiki.org
Request for comment (RFC)
OutputPage refactor
Component General
Creation date
Author(s) Owen Davis
Document status in draft

Summary[edit]

The current OutputPage class contains hard-coded HTML and header generation mixed with function calls and hooks in a way that makes it monolithic and hard to modify. Things also happen in a specific order and several stages are missing hooks so the data can't easily be changed or modified after being executed. Wikia has worked around many of these issues and added some features over time. We changed how redirects and head elements work, added configurable top/bottom page script injection, changed some session related code, changed the display of permissions errors, and added helper functions to manipulate the page meta keywords. Most of these changes could be merged to core or refactored to be hooks. Some of the remaining functions (like displaying permissions errors) inject raw HTML into the output buffer and should probably be treated as data until the skin rendering step.

Proposal[edit]

Ideally OutputPage will have no HTML or metadata that cannot be skipped or manipulated in some way, it will just pass data to the skin for inclusion in the page. One advantage of this is that since 100% of the data to render a page is prepared before page rendering, it provides another opportunity for caching.

Wikia Modifications to OutputPage[edit]

  • protected $mJQueryDone = true;
  • var $mRedirectsEnabled = true;
  • var $topScripts = ''; (we allow scripts to be loaded at top and bottom of page)
  • wfRunHooks('SkinGetHeadScripts', array(&$scripts));
  • $scripts = $this->topScripts . $scripts;
  • # Cache permanent redirects for 20 minutes
  • # Changed cache-control header for anon vs logged in users
  • Added hook: AfterFormatPermissionsErrorMessage
  • if( $wgDevelEnvironment ) { $this->addMeta( 'robots', 'noindex, nofollow' ); (headElement function)
  • $this->setHTMLTitle( $this->getWikiaPageTitle( $this->getPageTitle() ) );
  • $context->setSkipMessages(true); // in private modules, this caused performance problems
  • added functions: getScriptsOnly(), enableRedirects(), getWikiaPageTitle(), addKeywords( &$parserOutput ), tagWithSurrogateKeys()

Locations of hardcoded HTML/metadata/functions that need more flexibility[edit]

mVaryHeader

formatPermissionsErrorMessage()

readOnlyPage()

headElement()

getHeadLinks()

sendCacheControl()