When I implemented the ParserOutput merge logic in OutputPage (I0909ac85c6c785d9089b077a16923c61d6a09996) I realized that consistent "combine with OR" merge logic for the TOC flag is obtained only if we invert the flag; that is, the existing code showed a TOC *if any ParserOutput contained a shown TOC* otherwise the TOC was hidden. I'd originally implemented this in I35e199cca40c0e4359ac493e5806dcf4ae49321c with the opposite sense in order to avoid having to wait for ParserCache contents to expire: since the default on most pages was to have the TOC shown anyway, if "out of date" parser cache entries were missing a HIDE_TOC flag, it wouldn't be a big deal, whereas if a SHOW_TOC flag were required then upon deploy all cached pages would lose their TOC rendering. BUT a better solution is just to let a "parser cache expiration time" elapse between the time we start generating this flag and the time we start using it. The existing patch to export this (I6cf76c870124c162dc1bcbc2f7e9ca0c5fdcd10e) uses ParserOutput::getTOCHTML() anyway, so we can just wait to switch this over to use the SHOW_TOC flag (I10c3d06fb162103c06395bf9d1d27ac3c199d7b6) until the parser cache has expired. Anyway, this is a bit of a hassle to switch now, but I think having consistent merge semantics for ParserOutput flags is worth the short-term pain. Bug: T310083 Change-Id: I3b76010f1e2283add629b84bf3824f215f932903
181 lines
5.1 KiB
PHP
181 lines
5.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Registry of flags used with ParserOutput::setOutputFlag() within
|
|
* MediaWiki core.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
*
|
|
* @since 1.38
|
|
*
|
|
* @file
|
|
* @ingroup Parser
|
|
*/
|
|
|
|
namespace MediaWiki\Parser;
|
|
|
|
/**
|
|
* Registry of flags used with ParserOutput::{get,set}OutputFlag() within
|
|
* MediaWiki core.
|
|
*
|
|
* All flags used should be defined in this class.
|
|
*
|
|
* It is recommended that new flag names in core should begin with 'mw-'
|
|
* in order to prevent namespace conflicts with legacy flags.
|
|
*
|
|
* @package MediaWiki\Parser
|
|
*/
|
|
class ParserOutputFlags {
|
|
|
|
// These flags are currently stored as ParserOutput properties
|
|
|
|
/**
|
|
* @var string No gallery on category page? (__NOGALLERY__).
|
|
* @see \ParserOutput::getNoGallery()
|
|
* @see \ParserOutput::setNoGallery()
|
|
*/
|
|
public const NO_GALLERY = 'mw-NoGallery';
|
|
|
|
/**
|
|
* @var string Whether OOUI should be enabled.
|
|
* @see \ParserOutput::getEnableOOUI()
|
|
* @see \ParserOutput::setEnableOOUI()
|
|
*/
|
|
public const ENABLE_OOUI = 'mw-EnableOOUI';
|
|
|
|
/**
|
|
* @var string Force index policy to be 'index'
|
|
* @see \ParserOutput::getIndexPolicy()
|
|
* @see \ParserOutput::setIndexPolicy()
|
|
*/
|
|
public const INDEX_POLICY = 'mw-IndexPolicy';
|
|
|
|
/**
|
|
* @var string Force index policy to be 'noindex'
|
|
* @see \ParserOutput::getIndexPolicy()
|
|
* @see \ParserOutput::setIndexPolicy()
|
|
*/
|
|
public const NO_INDEX_POLICY = 'mw-NoIndexPolicy';
|
|
|
|
/**
|
|
* @var string Show a new section link?
|
|
* @see \ParserOutput::getNewSection()
|
|
* @see \ParserOutput::setNewSection()
|
|
*/
|
|
public const NEW_SECTION = 'mw-NewSection';
|
|
|
|
/**
|
|
* @var string Hide the new section link?
|
|
* @see \ParserOutput::getHideNewSection()
|
|
* @see \ParserOutput::setHideNewSection()
|
|
*/
|
|
public const HIDE_NEW_SECTION = 'mw-HideNewSection';
|
|
|
|
/**
|
|
* @var string The prevent-clickjacking flag
|
|
* @see \ParserOutput::getPreventClickjacking()
|
|
* @see \ParserOutput::setPreventClickjacking()
|
|
*/
|
|
public const PREVENT_CLICKJACKING = 'mw-PreventClickjacking';
|
|
|
|
// These flags are stored in the ParserOutput::$mFlags array
|
|
|
|
/**
|
|
* @var string Show the table of contents in the skin?
|
|
*/
|
|
public const SHOW_TOC = 'show-toc';
|
|
|
|
/**
|
|
* @var string Used to suppress language conversion in ToC contents.
|
|
*/
|
|
public const NO_TOC_CONVERSION = 'no-toc-conversion';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
public const VARY_REVISION = 'vary-revision';
|
|
|
|
/**
|
|
* @var string Similar to VARY_REVISION, but used if we didn't
|
|
* guess the ID correctly. Informs the edit saving system that
|
|
* getting the canonical output after revision insertion requires
|
|
* a parse that used that exact revision ID.
|
|
*/
|
|
public const VARY_REVISION_ID = 'vary-revision-id';
|
|
|
|
/**
|
|
* @var string Similar to VARY_REVISION, but used if we didn't
|
|
* guess the timestamp correctly. Informs the edit saving system
|
|
* that getting the canonical output after revision insertion
|
|
* requires a parse that used an actual revision timestamp.
|
|
*/
|
|
public const VARY_REVISION_TIMESTAMP = 'vary-revision-timestamp';
|
|
|
|
/**
|
|
* @var string Similar to VARY_REVISION, but used if we didn't guess the
|
|
* content correctly.
|
|
*/
|
|
public const VARY_REVISION_SHA1 = 'vary-revision-sha1';
|
|
|
|
/**
|
|
* @var string Similar to VARY_REVISION
|
|
*/
|
|
public const VARY_REVISION_EXISTS = 'vary-revision-exists';
|
|
|
|
/**
|
|
* @var string Similar to VARY_REVISION, but used if we didn't guess the
|
|
* page id correctly. Informs the edit saving system that getting the
|
|
* canonical output after page insertion requires a parse that used that
|
|
* exact page id.
|
|
*/
|
|
public const VARY_PAGE_ID = 'vary-page-id';
|
|
|
|
/**
|
|
* @var string Similar to VARY_REVISION. Informs the edit saving
|
|
* system that getting the canonical output after revision
|
|
* insertion requires a parse that used the actual user ID.
|
|
*/
|
|
public const VARY_USER = 'vary-user';
|
|
|
|
/**
|
|
* @var string Used to avoid extremely stale user signature timestamps
|
|
* (T84843). Set if the signature wikitext contains another '~~~~' or
|
|
* similar (T230652).
|
|
*/
|
|
public const USER_SIGNATURE = 'user-signature';
|
|
|
|
public static function cases(): array {
|
|
return [
|
|
self::NO_GALLERY,
|
|
self::NO_TOC_CONVERSION,
|
|
self::ENABLE_OOUI,
|
|
self::INDEX_POLICY,
|
|
self::NO_INDEX_POLICY,
|
|
self::NEW_SECTION,
|
|
self::HIDE_NEW_SECTION,
|
|
self::SHOW_TOC,
|
|
self::PREVENT_CLICKJACKING,
|
|
self::VARY_REVISION,
|
|
self::VARY_REVISION_ID,
|
|
self::VARY_REVISION_TIMESTAMP,
|
|
self::VARY_REVISION_SHA1,
|
|
self::VARY_REVISION_EXISTS,
|
|
self::VARY_PAGE_ID,
|
|
self::VARY_USER,
|
|
self::USER_SIGNATURE,
|
|
];
|
|
}
|
|
}
|