Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ParserOutputFlags | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| values | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Registry of flags used with ParserOutput::setOutputFlag() within |
| 5 | * MediaWiki core. |
| 6 | * |
| 7 | * @license GPL-2.0-or-later |
| 8 | * @since 1.38 |
| 9 | * |
| 10 | * @file |
| 11 | * @ingroup Parser |
| 12 | */ |
| 13 | |
| 14 | namespace MediaWiki\Parser; |
| 15 | |
| 16 | /** |
| 17 | * Registry of flags used with ParserOutput::{get,set}OutputFlag() within |
| 18 | * MediaWiki core. |
| 19 | * |
| 20 | * All flags used should be defined in this class. |
| 21 | * |
| 22 | * It is recommended that new flag names in core should begin with 'mw-' |
| 23 | * in order to prevent namespace conflicts with legacy flags. |
| 24 | * |
| 25 | * Note that in order to provide forward compatibility with "new" flag |
| 26 | * values, any additions to ParserOutputFlags should be backported to |
| 27 | * all currently-active release branches before those flags are written |
| 28 | * into the parser cache. |
| 29 | * |
| 30 | * @since 1.38 |
| 31 | */ |
| 32 | enum ParserOutputFlags: string { |
| 33 | |
| 34 | // See note above about backporting any new flags added to this |
| 35 | // enumeration. |
| 36 | |
| 37 | /** |
| 38 | * Disable magic gallery on category page (__NOGALLERY__). |
| 39 | * |
| 40 | * This is used to selectively disable the auto-magic thumbnail |
| 41 | * gallery on thumbnail pages. |
| 42 | * |
| 43 | * @see MainConfigSchema::CategoryMagicGallery |
| 44 | * @since 1.38 |
| 45 | */ |
| 46 | case NO_GALLERY = 'mw-NoGallery'; |
| 47 | |
| 48 | /** |
| 49 | * Whether OOUI should be enabled. If set, OOUI is enabled in |
| 50 | * any OutputPage instance the ParserOutput containing this flag |
| 51 | * is added to. |
| 52 | * @since 1.38 |
| 53 | */ |
| 54 | case ENABLE_OOUI = 'mw-EnableOOUI'; |
| 55 | |
| 56 | /** |
| 57 | * Force index policy to be 'index'. |
| 58 | * @see ParserOutput::getIndexPolicy() |
| 59 | * @see ParserOutput::setIndexPolicy() |
| 60 | * @since 1.38 |
| 61 | */ |
| 62 | case INDEX_POLICY = 'mw-IndexPolicy'; |
| 63 | |
| 64 | /** |
| 65 | * Force index policy to be 'noindex'. |
| 66 | * @see ParserOutput::getIndexPolicy() |
| 67 | * @see ParserOutput::setIndexPolicy() |
| 68 | * @since 1.38 |
| 69 | */ |
| 70 | case NO_INDEX_POLICY = 'mw-NoIndexPolicy'; |
| 71 | |
| 72 | /** |
| 73 | * Show a new section link? |
| 74 | * @since 1.38 |
| 75 | */ |
| 76 | case NEW_SECTION = 'mw-NewSection'; |
| 77 | |
| 78 | /** |
| 79 | * Hide the new section link? |
| 80 | * @since 1.38 |
| 81 | */ |
| 82 | case HIDE_NEW_SECTION = 'mw-HideNewSection'; |
| 83 | |
| 84 | /** |
| 85 | * The prevent-clickjacking flag. |
| 86 | * |
| 87 | * If true, we emit an `X-Frame-Options` header appropriate for |
| 88 | * edit pages. The exact header value is controlled by |
| 89 | * `$wgEditPageFrameOptions`. This controls if anti-clickjacking |
| 90 | * / frame-breaking headers will be sent. This flag is set by |
| 91 | * default for special pages. For other pages where a |
| 92 | * CSRF-protect form is displayed (for example where edit actions |
| 93 | * are possible), you need to set this flag. |
| 94 | * |
| 95 | * @since 1.38 |
| 96 | */ |
| 97 | case PREVENT_CLICKJACKING = 'mw-PreventClickjacking'; |
| 98 | |
| 99 | /** |
| 100 | * Show the table of contents in the skin? |
| 101 | * |
| 102 | * This is a /suggestion/ based on whether the TOC is "large |
| 103 | * enough" and other factors, and is intended mostly for skins |
| 104 | * which want to match the behavior of the traditional inline ToC. |
| 105 | * @since 1.39 |
| 106 | */ |
| 107 | case SHOW_TOC = 'show-toc'; |
| 108 | |
| 109 | /** |
| 110 | * Suppress the table of contents in the skin? |
| 111 | * |
| 112 | * This reflects the use of the `__NOTOC__` magic word in the |
| 113 | * article (possibly modified by `__TOC__` or `__FORCETOC__`), and |
| 114 | * represents an explicit request from the author to hide the TOC. |
| 115 | * @since 1.41 |
| 116 | */ |
| 117 | case NO_TOC = 'no-toc'; |
| 118 | |
| 119 | /** |
| 120 | * Suppress the section edit links? |
| 121 | * |
| 122 | * This reflects the `ParserOptions::getSuppressSectionEditLinks()` |
| 123 | * flag and affects the default value of `enableSectionEditLinks` |
| 124 | * in `ParserOutput::getText()`. |
| 125 | * @since 1.42 |
| 126 | */ |
| 127 | case NO_SECTION_EDIT_LINKS = 'no-section-edit-links'; |
| 128 | |
| 129 | /** |
| 130 | * Are section contents wrapped to allow collapsing them? |
| 131 | * |
| 132 | * This reflects the ParserOptions::getCollapsibleSections() |
| 133 | * flag. |
| 134 | * @since 1.43 |
| 135 | */ |
| 136 | case COLLAPSIBLE_SECTIONS = 'collapsible-sections'; |
| 137 | |
| 138 | // See RenderedRevision::outputVariesOnRevisionMetadata for the |
| 139 | // VARY_* flags. |
| 140 | |
| 141 | /** |
| 142 | * Informs the edit saving system that the canonical output for |
| 143 | * this page may change after revision insertion; for instance |
| 144 | * if it uses some properties of the page itself (like categories) |
| 145 | * which will not be updated until the RefreshLinksJob is run after |
| 146 | * the revision is saved. |
| 147 | * @since 1.38 |
| 148 | */ |
| 149 | case VARY_REVISION = 'vary-revision'; |
| 150 | |
| 151 | /** |
| 152 | * Similar to VARY_REVISION, but used if we didn't |
| 153 | * guess the ID correctly. Informs the edit saving system that |
| 154 | * getting the canonical output after revision insertion requires |
| 155 | * a parse that used that exact revision ID, for instance if the |
| 156 | * page used {{REVISIONID}} to fetch its own revision ID. |
| 157 | * @since 1.38 |
| 158 | */ |
| 159 | case VARY_REVISION_ID = 'vary-revision-id'; |
| 160 | |
| 161 | /** |
| 162 | * Similar to VARY_REVISION_ID, but used if we didn't |
| 163 | * guess the timestamp correctly. Informs the edit saving system |
| 164 | * that getting the canonical output after revision insertion |
| 165 | * requires a parse that used an actual revision timestamp. |
| 166 | * @since 1.38 |
| 167 | */ |
| 168 | case VARY_REVISION_TIMESTAMP = 'vary-revision-timestamp'; |
| 169 | |
| 170 | /** |
| 171 | * Similar to VARY_REVISION, but used if we didn't guess the |
| 172 | * content correctly. For example, a self-transclusion will |
| 173 | * set this flag, since the lookup of the transcluded content |
| 174 | * (itself) will be stale until the new revision of this page |
| 175 | * is actually stored in the DB. |
| 176 | * @since 1.38 |
| 177 | */ |
| 178 | case VARY_REVISION_SHA1 = 'vary-revision-sha1'; |
| 179 | |
| 180 | /** |
| 181 | * Similar to VARY_REVISION, but used if the output will change |
| 182 | * once this page exists in the database. |
| 183 | * @since 1.38 |
| 184 | */ |
| 185 | case VARY_REVISION_EXISTS = 'vary-revision-exists'; |
| 186 | |
| 187 | /** |
| 188 | * Similar to VARY_REVISION, but used if we didn't guess the |
| 189 | * page id correctly. Informs the edit saving system that getting the |
| 190 | * canonical output after page insertion requires a parse that used that |
| 191 | * exact page id. |
| 192 | * @since 1.38 |
| 193 | */ |
| 194 | case VARY_PAGE_ID = 'vary-page-id'; |
| 195 | |
| 196 | /** |
| 197 | * Similar to VARY_REVISION. Informs the edit saving |
| 198 | * system that getting the canonical output after revision |
| 199 | * insertion requires a parse that used the actual user ID. |
| 200 | * @since 1.38 |
| 201 | */ |
| 202 | case VARY_USER = 'vary-user'; |
| 203 | |
| 204 | /** |
| 205 | * Used to avoid extremely stale user signature timestamps |
| 206 | * (T84843). Set if the signature wikitext contains another '~~~~' or |
| 207 | * similar (T230652). |
| 208 | * @since 1.38 |
| 209 | */ |
| 210 | case USER_SIGNATURE = 'user-signature'; |
| 211 | |
| 212 | /** |
| 213 | * Set when the parse is done in "preview mode". |
| 214 | * |
| 215 | * When the parse is done in "previous mode" various shortcuts are |
| 216 | * taken to work around the fact that the parsed text does not yet |
| 217 | * have an actual revision ID, revision time, etc. |
| 218 | * @see ParserOptions::getIsPreview() |
| 219 | * @since 1.42 |
| 220 | */ |
| 221 | case IS_PREVIEW = 'is-preview'; |
| 222 | |
| 223 | /** |
| 224 | * Set when the parse was done with parsoid; clear if the |
| 225 | * parse was done with the legacy parser (or unknown). |
| 226 | * |
| 227 | * @see ParserOptions::getUseParsoid() |
| 228 | * @since 1.45 |
| 229 | */ |
| 230 | case USE_PARSOID = 'use-parsoid'; |
| 231 | |
| 232 | /** |
| 233 | * Set if this page contains content which could be |
| 234 | * asynchronous, even if the content was "ready" at the time of |
| 235 | * the parse. |
| 236 | * |
| 237 | * This ensures that when the page expires from the |
| 238 | * cache and the page is reparsed, RefreshLinksJob will also be |
| 239 | * re-run since the content could be different from the last |
| 240 | * parse. (T373256) |
| 241 | * @since 1.44 |
| 242 | */ |
| 243 | case HAS_ASYNC_CONTENT = 'has-async-content'; |
| 244 | |
| 245 | /** |
| 246 | * Set if this page contains asynchronous content which |
| 247 | * was not ready by the time the output was generated. |
| 248 | * |
| 249 | * At present this reduces the cache TTL. (T373256) |
| 250 | * @since 1.44 |
| 251 | */ |
| 252 | case ASYNC_NOT_READY = 'async-not-ready'; |
| 253 | |
| 254 | /** |
| 255 | * Set if this page is unsafe for selective update. |
| 256 | * |
| 257 | * Generally this means a resource limit was reached, and so this |
| 258 | * page does not contain a full representation of the input wikitext. |
| 259 | * An update might resolve the excess resource use, but it wouldn't |
| 260 | * be able to replace the content that was lost when the limit |
| 261 | * was reached. (Duplicate or conflicting definitions constitute |
| 262 | * another form of "resource limit", since uniqueness limits us to |
| 263 | * only one of a given item.) |
| 264 | * |
| 265 | * Triggering other error conditions or the use of other unsafe features |
| 266 | * may also set this flag. |
| 267 | * @since 1.46 |
| 268 | */ |
| 269 | case PREVENT_SELECTIVE_UPDATE = 'prevent-selective-update'; |
| 270 | |
| 271 | /** |
| 272 | * Set if this page contains header placeholders (T200915). |
| 273 | * @since 1.46 |
| 274 | */ |
| 275 | case HAS_SLOT_HEADERS = 'has-slot-headers'; |
| 276 | |
| 277 | /** |
| 278 | * Return the ParserOutputFlags, as an array of string flag values. |
| 279 | * @return list<string> |
| 280 | */ |
| 281 | public static function values(): array { |
| 282 | return array_column( self::cases(), 'value' ); |
| 283 | } |
| 284 | } |