Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ParserOutput often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ParserOutput, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
24 | class ParserOutput extends CacheTime { |
||
25 | /** |
||
26 | * @var string $mText The output text |
||
27 | */ |
||
28 | public $mText; |
||
29 | |||
30 | /** |
||
31 | * @var array $mLanguageLinks List of the full text of language links, |
||
32 | * in the order they appear. |
||
33 | */ |
||
34 | public $mLanguageLinks; |
||
35 | |||
36 | /** |
||
37 | * @var array $mCategoriesMap of category names to sort keys |
||
38 | */ |
||
39 | public $mCategories; |
||
40 | |||
41 | /** |
||
42 | * @var array $mIndicators Page status indicators, usually displayed in top-right corner. |
||
43 | */ |
||
44 | public $mIndicators = []; |
||
45 | |||
46 | /** |
||
47 | * @var string $mTitleText Title text of the chosen language variant, as HTML. |
||
48 | */ |
||
49 | public $mTitleText; |
||
50 | |||
51 | /** |
||
52 | * @var array $mLinks 2-D map of NS/DBK to ID for the links in the document. |
||
53 | * ID=zero for broken. |
||
54 | */ |
||
55 | public $mLinks = []; |
||
56 | |||
57 | /** |
||
58 | * @var array $mTemplates 2-D map of NS/DBK to ID for the template references. |
||
59 | * ID=zero for broken. |
||
60 | */ |
||
61 | public $mTemplates = []; |
||
62 | |||
63 | /** |
||
64 | * @var array $mTemplateIds 2-D map of NS/DBK to rev ID for the template references. |
||
65 | * ID=zero for broken. |
||
66 | */ |
||
67 | public $mTemplateIds = []; |
||
68 | |||
69 | /** |
||
70 | * @var array $mImages DB keys of the images used, in the array key only |
||
71 | */ |
||
72 | public $mImages = []; |
||
73 | |||
74 | /** |
||
75 | * @var array $mFileSearchOptions DB keys of the images used mapped to sha1 and MW timestamp. |
||
76 | */ |
||
77 | public $mFileSearchOptions = []; |
||
78 | |||
79 | /** |
||
80 | * @var array $mExternalLinks External link URLs, in the key only. |
||
81 | */ |
||
82 | public $mExternalLinks = []; |
||
83 | |||
84 | /** |
||
85 | * @var array $mInterwikiLinks 2-D map of prefix/DBK (in keys only) |
||
86 | * for the inline interwiki links in the document. |
||
87 | */ |
||
88 | public $mInterwikiLinks = []; |
||
89 | |||
90 | /** |
||
91 | * @var bool $mNewSection Show a new section link? |
||
92 | */ |
||
93 | public $mNewSection = false; |
||
94 | |||
95 | /** |
||
96 | * @var bool $mHideNewSection Hide the new section link? |
||
97 | */ |
||
98 | public $mHideNewSection = false; |
||
99 | |||
100 | /** |
||
101 | * @var bool $mNoGallery No gallery on category page? (__NOGALLERY__). |
||
102 | */ |
||
103 | public $mNoGallery = false; |
||
104 | |||
105 | /** |
||
106 | * @var array $mHeadItems Items to put in the <head> section |
||
107 | */ |
||
108 | public $mHeadItems = []; |
||
109 | |||
110 | /** |
||
111 | * @var array $mModules Modules to be loaded by ResourceLoader |
||
112 | */ |
||
113 | public $mModules = []; |
||
114 | |||
115 | /** |
||
116 | * @var array $mModuleScripts Modules of which only the JS will be loaded by ResourceLoader. |
||
117 | */ |
||
118 | public $mModuleScripts = []; |
||
119 | |||
120 | /** |
||
121 | * @var array $mModuleStyles Modules of which only the CSSS will be loaded by ResourceLoader. |
||
122 | */ |
||
123 | public $mModuleStyles = []; |
||
124 | |||
125 | /** |
||
126 | * @var array $mJsConfigVars JavaScript config variable for mw.config combined with this page. |
||
127 | */ |
||
128 | public $mJsConfigVars = []; |
||
129 | |||
130 | /** |
||
131 | * @var array $mOutputHooks Hook tags as per $wgParserOutputHooks. |
||
132 | */ |
||
133 | public $mOutputHooks = []; |
||
134 | |||
135 | /** |
||
136 | * @var array $mWarnings Warning text to be returned to the user. |
||
137 | * Wikitext formatted, in the key only. |
||
138 | */ |
||
139 | public $mWarnings = []; |
||
140 | |||
141 | /** |
||
142 | * @var array $mSections Table of contents |
||
143 | */ |
||
144 | public $mSections = []; |
||
145 | |||
146 | /** |
||
147 | * @var bool $mEditSectionTokens prefix/suffix markers if edit sections were output as tokens. |
||
148 | */ |
||
149 | public $mEditSectionTokens = false; |
||
150 | |||
151 | /** |
||
152 | * @var array $mProperties Name/value pairs to be cached in the DB. |
||
153 | */ |
||
154 | public $mProperties = []; |
||
155 | |||
156 | /** |
||
157 | * @var string $mTOCHTML HTML of the TOC. |
||
158 | */ |
||
159 | public $mTOCHTML = ''; |
||
160 | |||
161 | /** |
||
162 | * @var string $mTimestamp Timestamp of the revision. |
||
163 | */ |
||
164 | public $mTimestamp; |
||
165 | |||
166 | /** |
||
167 | * @var bool $mTOCEnabled Whether TOC should be shown, can't override __NOTOC__. |
||
168 | */ |
||
169 | public $mTOCEnabled = true; |
||
170 | |||
171 | /** |
||
172 | * @var bool $mEnableOOUI Whether OOUI should be enabled. |
||
173 | */ |
||
174 | public $mEnableOOUI = false; |
||
175 | |||
176 | /** |
||
177 | * @var string $mIndexPolicy 'index' or 'noindex'? Any other value will result in no change. |
||
178 | */ |
||
179 | private $mIndexPolicy = ''; |
||
180 | |||
181 | /** |
||
182 | * @var array $mAccessedOptions List of ParserOptions (stored in the keys). |
||
183 | */ |
||
184 | private $mAccessedOptions = []; |
||
185 | |||
186 | /** |
||
187 | * @var array $mExtensionData extra data used by extensions. |
||
188 | */ |
||
189 | private $mExtensionData = []; |
||
190 | |||
191 | /** |
||
192 | * @var array $mLimitReportData Parser limit report data. |
||
193 | */ |
||
194 | private $mLimitReportData = []; |
||
195 | |||
196 | /** |
||
197 | * @var array $mParseStartTime Timestamps for getTimeSinceStart(). |
||
198 | */ |
||
199 | private $mParseStartTime = []; |
||
200 | |||
201 | /** |
||
202 | * @var bool $mPreventClickjacking Whether to emit X-Frame-Options: DENY. |
||
203 | */ |
||
204 | private $mPreventClickjacking = false; |
||
205 | |||
206 | /** |
||
207 | * @var array $mFlags Generic flags. |
||
208 | */ |
||
209 | private $mFlags = []; |
||
210 | |||
211 | /** @var integer|null Assumed rev ID for {{REVISIONID}} if no revision is set */ |
||
212 | private $mSpeculativeRevId; |
||
213 | |||
214 | /** @var integer Upper bound of expiry based on parse duration */ |
||
215 | private $mMaxAdaptiveExpiry = INF; |
||
216 | |||
217 | const EDITSECTION_REGEX = |
||
218 | '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#'; |
||
219 | |||
220 | // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL) |
||
221 | // Current values imply that m=3933.333333 and b=-333.333333 |
||
222 | // See https://www.nngroup.com/articles/website-response-times/ |
||
223 | const PARSE_FAST_SEC = .100; // perceived "fast" page parse |
||
224 | const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse |
||
225 | const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages |
||
226 | const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages |
||
227 | const MIN_AR_TTL = 15; // min adaptive TTL (for sanity, pool counter, and edit stashing) |
||
228 | |||
229 | public function __construct( $text = '', $languageLinks = [], $categoryLinks = [], |
||
237 | |||
238 | /** |
||
239 | * Get the cacheable text with <mw:editsection> markers still in it. The |
||
240 | * return value is suitable for writing back via setText() but is not valid |
||
241 | * for display to the user. |
||
242 | * |
||
243 | * @since 1.27 |
||
244 | */ |
||
245 | public function getRawText() { |
||
248 | |||
249 | public function getText() { |
||
289 | |||
290 | /** |
||
291 | * @param integer $id |
||
292 | * @since 1.28 |
||
293 | */ |
||
294 | public function setSpeculativeRevIdUsed( $id ) { |
||
297 | |||
298 | /** @since 1.28 */ |
||
299 | public function getSpeculativeRevIdUsed() { |
||
302 | |||
303 | public function &getLanguageLinks() { |
||
306 | |||
307 | public function getInterwikiLinks() { |
||
310 | |||
311 | public function getCategoryLinks() { |
||
314 | |||
315 | public function &getCategories() { |
||
318 | |||
319 | /** |
||
320 | * @since 1.25 |
||
321 | */ |
||
322 | public function getIndicators() { |
||
325 | |||
326 | public function getTitleText() { |
||
329 | |||
330 | public function getSections() { |
||
333 | |||
334 | public function getEditSectionTokens() { |
||
337 | |||
338 | public function &getLinks() { |
||
341 | |||
342 | public function &getTemplates() { |
||
345 | |||
346 | public function &getTemplateIds() { |
||
349 | |||
350 | public function &getImages() { |
||
353 | |||
354 | public function &getFileSearchOptions() { |
||
357 | |||
358 | public function &getExternalLinks() { |
||
361 | |||
362 | public function getNoGallery() { |
||
365 | |||
366 | public function getHeadItems() { |
||
369 | |||
370 | public function getModules() { |
||
373 | |||
374 | public function getModuleScripts() { |
||
377 | |||
378 | public function getModuleStyles() { |
||
381 | |||
382 | /** @since 1.23 */ |
||
383 | public function getJsConfigVars() { |
||
386 | |||
387 | public function getOutputHooks() { |
||
390 | |||
391 | public function getWarnings() { |
||
394 | |||
395 | public function getIndexPolicy() { |
||
398 | |||
399 | public function getTOCHTML() { |
||
402 | |||
403 | /** |
||
404 | * @return string|null TS_MW timestamp of the revision content |
||
405 | */ |
||
406 | public function getTimestamp() { |
||
409 | |||
410 | public function getLimitReportData() { |
||
413 | |||
414 | public function getTOCEnabled() { |
||
417 | |||
418 | public function getEnableOOUI() { |
||
421 | |||
422 | public function setText( $text ) { |
||
425 | |||
426 | public function setLanguageLinks( $ll ) { |
||
429 | |||
430 | public function setCategoryLinks( $cl ) { |
||
433 | |||
434 | public function setTitleText( $t ) { |
||
437 | |||
438 | public function setSections( $toc ) { |
||
441 | |||
442 | public function setEditSectionTokens( $t ) { |
||
445 | |||
446 | public function setIndexPolicy( $policy ) { |
||
449 | |||
450 | public function setTOCHTML( $tochtml ) { |
||
453 | |||
454 | public function setTimestamp( $timestamp ) { |
||
457 | |||
458 | public function setTOCEnabled( $flag ) { |
||
461 | |||
462 | public function addCategory( $c, $sort ) { |
||
465 | |||
466 | /** |
||
467 | * @since 1.25 |
||
468 | */ |
||
469 | public function setIndicator( $id, $content ) { |
||
472 | |||
473 | /** |
||
474 | * Enables OOUI, if true, in any OutputPage instance this ParserOutput |
||
475 | * object is added to. |
||
476 | * |
||
477 | * @since 1.26 |
||
478 | * @param bool $enable If OOUI should be enabled or not |
||
479 | */ |
||
480 | public function setEnableOOUI( $enable = false ) { |
||
483 | |||
484 | public function addLanguageLink( $t ) { |
||
487 | |||
488 | public function addWarning( $s ) { |
||
491 | |||
492 | public function addOutputHook( $hook, $data = false ) { |
||
495 | |||
496 | public function setNewSection( $value ) { |
||
508 | |||
509 | /** |
||
510 | * Checks, if a url is pointing to the own server |
||
511 | * |
||
512 | * @param string $internal The server to check against |
||
513 | * @param string $url The url to check |
||
514 | * @return bool |
||
515 | */ |
||
516 | public static function isLinkInternal( $internal, $url ) { |
||
526 | |||
527 | public function addExternalLink( $url ) { |
||
539 | |||
540 | /** |
||
541 | * Record a local or interwiki inline link for saving in future link tables. |
||
542 | * |
||
543 | * @param Title $title |
||
544 | * @param int|null $id Optional known page_id so we can skip the lookup |
||
545 | */ |
||
546 | public function addLink( Title $title, $id = null ) { |
||
573 | |||
574 | /** |
||
575 | * Register a file dependency for this output |
||
576 | * @param string $name Title dbKey |
||
577 | * @param string $timestamp MW timestamp of file creation (or false if non-existing) |
||
578 | * @param string $sha1 Base 36 SHA-1 of file (or false if non-existing) |
||
579 | * @return void |
||
580 | */ |
||
581 | public function addImage( $name, $timestamp = null, $sha1 = null ) { |
||
587 | |||
588 | /** |
||
589 | * Register a template dependency for this output |
||
590 | * @param Title $title |
||
591 | * @param int $page_id |
||
592 | * @param int $rev_id |
||
593 | * @return void |
||
594 | */ |
||
595 | public function addTemplate( $title, $page_id, $rev_id ) { |
||
607 | |||
608 | /** |
||
609 | * @param Title $title Title object, must be an interwiki link |
||
610 | * @throws MWException If given invalid input |
||
611 | */ |
||
612 | public function addInterwikiLink( $title ) { |
||
622 | |||
623 | /** |
||
624 | * Add some text to the "<head>". |
||
625 | * If $tag is set, the section with that tag will only be included once |
||
626 | * in a given page. |
||
627 | * @param string $section |
||
628 | * @param string|bool $tag |
||
629 | */ |
||
630 | public function addHeadItem( $section, $tag = false ) { |
||
637 | |||
638 | public function addModules( $modules ) { |
||
641 | |||
642 | public function addModuleScripts( $modules ) { |
||
645 | |||
646 | public function addModuleStyles( $modules ) { |
||
649 | |||
650 | /** |
||
651 | * Add one or more variables to be set in mw.config in JavaScript. |
||
652 | * |
||
653 | * @param string|array $keys Key or array of key/value pairs. |
||
654 | * @param mixed $value [optional] Value of the configuration variable. |
||
655 | * @since 1.23 |
||
656 | */ |
||
657 | View Code Duplication | public function addJsConfigVars( $keys, $value = null ) { |
|
667 | |||
668 | /** |
||
669 | * Copy items from the OutputPage object into this one |
||
670 | * |
||
671 | * @param OutputPage $out |
||
672 | */ |
||
673 | public function addOutputPageMetadata( OutputPage $out ) { |
||
682 | |||
683 | /** |
||
684 | * Add a tracking category, getting the title from a system message, |
||
685 | * or print a debug message if the title is invalid. |
||
686 | * |
||
687 | * Any message used with this function should be registered so it will |
||
688 | * show up on Special:TrackingCategories. Core messages should be added |
||
689 | * to SpecialTrackingCategories::$coreTrackingCategories, and extensions |
||
690 | * should add to "TrackingCategories" in their extension.json. |
||
691 | * |
||
692 | * @param string $msg Message key |
||
693 | * @param Title $title title of the page which is being tracked |
||
694 | * @return bool Whether the addition was successful |
||
695 | * @since 1.25 |
||
696 | */ |
||
697 | public function addTrackingCategory( $msg, $title ) { |
||
723 | |||
724 | /** |
||
725 | * Override the title to be used for display |
||
726 | * |
||
727 | * @note this is assumed to have been validated |
||
728 | * (check equal normalisation, etc.) |
||
729 | * |
||
730 | * @note this is expected to be safe HTML, |
||
731 | * ready to be served to the client. |
||
732 | * |
||
733 | * @param string $text Desired title text |
||
734 | */ |
||
735 | public function setDisplayTitle( $text ) { |
||
739 | |||
740 | /** |
||
741 | * Get the title to be used for display. |
||
742 | * |
||
743 | * As per the contract of setDisplayTitle(), this is safe HTML, |
||
744 | * ready to be served to the client. |
||
745 | * |
||
746 | * @return string HTML |
||
747 | */ |
||
748 | public function getDisplayTitle() { |
||
755 | |||
756 | /** |
||
757 | * Fairly generic flag setter thingy. |
||
758 | * @param string $flag |
||
759 | */ |
||
760 | public function setFlag( $flag ) { |
||
763 | |||
764 | public function getFlag( $flag ) { |
||
767 | |||
768 | /** |
||
769 | * Set a property to be stored in the page_props database table. |
||
770 | * |
||
771 | * page_props is a key value store indexed by the page ID. This allows |
||
772 | * the parser to set a property on a page which can then be quickly |
||
773 | * retrieved given the page ID or via a DB join when given the page |
||
774 | * title. |
||
775 | * |
||
776 | * Since 1.23, page_props are also indexed by numeric value, to allow |
||
777 | * for efficient "top k" queries of pages wrt a given property. |
||
778 | * |
||
779 | * setProperty() is thus used to propagate properties from the parsed |
||
780 | * page to request contexts other than a page view of the currently parsed |
||
781 | * article. |
||
782 | * |
||
783 | * Some applications examples: |
||
784 | * |
||
785 | * * To implement hidden categories, hiding pages from category listings |
||
786 | * by storing a property. |
||
787 | * |
||
788 | * * Overriding the displayed article title. |
||
789 | * @see ParserOutput::setDisplayTitle() |
||
790 | * |
||
791 | * * To implement image tagging, for example displaying an icon on an |
||
792 | * image thumbnail to indicate that it is listed for deletion on |
||
793 | * Wikimedia Commons. |
||
794 | * This is not actually implemented, yet but would be pretty cool. |
||
795 | * |
||
796 | * @note Do not use setProperty() to set a property which is only used |
||
797 | * in a context where the ParserOutput object itself is already available, |
||
798 | * for example a normal page view. There is no need to save such a property |
||
799 | * in the database since the text is already parsed. You can just hook |
||
800 | * OutputPageParserOutput and get your data out of the ParserOutput object. |
||
801 | * |
||
802 | * If you are writing an extension where you want to set a property in the |
||
803 | * parser which is used by an OutputPageParserOutput hook, you have to |
||
804 | * associate the extension data directly with the ParserOutput object. |
||
805 | * Since MediaWiki 1.21, you can use setExtensionData() to do this: |
||
806 | * |
||
807 | * @par Example: |
||
808 | * @code |
||
809 | * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' ); |
||
810 | * @endcode |
||
811 | * |
||
812 | * And then later, in OutputPageParserOutput or similar: |
||
813 | * |
||
814 | * @par Example: |
||
815 | * @code |
||
816 | * $output->getExtensionData( 'my_ext_foo' ); |
||
817 | * @endcode |
||
818 | * |
||
819 | * In MediaWiki 1.20 and older, you have to use a custom member variable |
||
820 | * within the ParserOutput object: |
||
821 | * |
||
822 | * @par Example: |
||
823 | * @code |
||
824 | * $parser->getOutput()->my_ext_foo = '...'; |
||
825 | * @endcode |
||
826 | * |
||
827 | */ |
||
828 | public function setProperty( $name, $value ) { |
||
831 | |||
832 | /** |
||
833 | * @param string $name The property name to look up. |
||
834 | * |
||
835 | * @return mixed|bool The value previously set using setProperty(). False if null or no value |
||
836 | * was set for the given property name. |
||
837 | * |
||
838 | * @note You need to use getProperties() to check for boolean and null properties. |
||
839 | */ |
||
840 | public function getProperty( $name ) { |
||
843 | |||
844 | public function unsetProperty( $name ) { |
||
847 | |||
848 | public function getProperties() { |
||
854 | |||
855 | /** |
||
856 | * Returns the options from its ParserOptions which have been taken |
||
857 | * into account to produce this output or false if not available. |
||
858 | * @return array |
||
859 | */ |
||
860 | public function getUsedOptions() { |
||
866 | |||
867 | /** |
||
868 | * Tags a parser option for use in the cache key for this parser output. |
||
869 | * Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState(). |
||
870 | * The information gathered here is available via getUsedOptions(), |
||
871 | * and is used by ParserCache::save(). |
||
872 | * |
||
873 | * @see ParserCache::getKey |
||
874 | * @see ParserCache::save |
||
875 | * @see ParserOptions::addExtraKey |
||
876 | * @see ParserOptions::optionsHash |
||
877 | * @param string $option |
||
878 | */ |
||
879 | public function recordOption( $option ) { |
||
882 | |||
883 | /** |
||
884 | * Attaches arbitrary data to this ParserObject. This can be used to store some information in |
||
885 | * the ParserOutput object for later use during page output. The data will be cached along with |
||
886 | * the ParserOutput object, but unlike data set using setProperty(), it is not recorded in the |
||
887 | * database. |
||
888 | * |
||
889 | * This method is provided to overcome the unsafe practice of attaching extra information to a |
||
890 | * ParserObject by directly assigning member variables. |
||
891 | * |
||
892 | * To use setExtensionData() to pass extension information from a hook inside the parser to a |
||
893 | * hook in the page output, use this in the parser hook: |
||
894 | * |
||
895 | * @par Example: |
||
896 | * @code |
||
897 | * $parser->getOutput()->setExtensionData( 'my_ext_foo', '...' ); |
||
898 | * @endcode |
||
899 | * |
||
900 | * And then later, in OutputPageParserOutput or similar: |
||
901 | * |
||
902 | * @par Example: |
||
903 | * @code |
||
904 | * $output->getExtensionData( 'my_ext_foo' ); |
||
905 | * @endcode |
||
906 | * |
||
907 | * In MediaWiki 1.20 and older, you have to use a custom member variable |
||
908 | * within the ParserOutput object: |
||
909 | * |
||
910 | * @par Example: |
||
911 | * @code |
||
912 | * $parser->getOutput()->my_ext_foo = '...'; |
||
913 | * @endcode |
||
914 | * |
||
915 | * @since 1.21 |
||
916 | * |
||
917 | * @param string $key The key for accessing the data. Extensions should take care to avoid |
||
918 | * conflicts in naming keys. It is suggested to use the extension's name as a prefix. |
||
919 | * |
||
920 | * @param mixed $value The value to set. Setting a value to null is equivalent to removing |
||
921 | * the value. |
||
922 | */ |
||
923 | public function setExtensionData( $key, $value ) { |
||
930 | |||
931 | /** |
||
932 | * Gets extensions data previously attached to this ParserOutput using setExtensionData(). |
||
933 | * Typically, such data would be set while parsing the page, e.g. by a parser function. |
||
934 | * |
||
935 | * @since 1.21 |
||
936 | * |
||
937 | * @param string $key The key to look up. |
||
938 | * |
||
939 | * @return mixed|null The value previously set for the given key using setExtensionData() |
||
940 | * or null if no value was set for this key. |
||
941 | */ |
||
942 | public function getExtensionData( $key ) { |
||
949 | |||
950 | private static function getTimes( $clock = null ) { |
||
964 | |||
965 | /** |
||
966 | * Resets the parse start timestamps for future calls to getTimeSinceStart() |
||
967 | * @since 1.22 |
||
968 | */ |
||
969 | public function resetParseStartTime() { |
||
972 | |||
973 | /** |
||
974 | * Returns the time since resetParseStartTime() was last called |
||
975 | * |
||
976 | * Clocks available are: |
||
977 | * - wall: Wall clock time |
||
978 | * - cpu: CPU time (requires getrusage) |
||
979 | * |
||
980 | * @since 1.22 |
||
981 | * @param string $clock |
||
982 | * @return float|null |
||
983 | */ |
||
984 | public function getTimeSinceStart( $clock ) { |
||
992 | |||
993 | /** |
||
994 | * Sets parser limit report data for a key |
||
995 | * |
||
996 | * The key is used as the prefix for various messages used for formatting: |
||
997 | * - $key: The label for the field in the limit report |
||
998 | * - $key-value-text: Message used to format the value in the "NewPP limit |
||
999 | * report" HTML comment. If missing, uses $key-format. |
||
1000 | * - $key-value-html: Message used to format the value in the preview |
||
1001 | * limit report table. If missing, uses $key-format. |
||
1002 | * - $key-value: Message used to format the value. If missing, uses "$1". |
||
1003 | * |
||
1004 | * Note that all values are interpreted as wikitext, and so should be |
||
1005 | * encoded with htmlspecialchars() as necessary, but should avoid complex |
||
1006 | * HTML for sanity of display in the "NewPP limit report" comment. |
||
1007 | * |
||
1008 | * @since 1.22 |
||
1009 | * @param string $key Message key |
||
1010 | * @param mixed $value Appropriate for Message::params() |
||
1011 | */ |
||
1012 | public function setLimitReportData( $key, $value ) { |
||
1015 | |||
1016 | /** |
||
1017 | * Check whether the cache TTL was lowered due to dynamic content |
||
1018 | * |
||
1019 | * When content is determined by more than hard state (e.g. page edits), |
||
1020 | * such as template/file transclusions based on the current timestamp or |
||
1021 | * extension tags that generate lists based on queries, this return true. |
||
1022 | * |
||
1023 | * @return bool |
||
1024 | * @since 1.25 |
||
1025 | */ |
||
1026 | public function hasDynamicContent() { |
||
1031 | |||
1032 | /** |
||
1033 | * Get or set the prevent-clickjacking flag |
||
1034 | * |
||
1035 | * @since 1.24 |
||
1036 | * @param bool|null $flag New flag value, or null to leave it unchanged |
||
1037 | * @return bool Old flag value |
||
1038 | */ |
||
1039 | public function preventClickjacking( $flag = null ) { |
||
1042 | |||
1043 | /** |
||
1044 | * Lower the runtime adaptive TTL to at most this value |
||
1045 | * |
||
1046 | * @param integer $ttl |
||
1047 | * @since 1.28 |
||
1048 | */ |
||
1049 | public function updateRuntimeAdaptiveExpiry( $ttl ) { |
||
1053 | |||
1054 | /** |
||
1055 | * Call this when parsing is done to lower the TTL based on low parse times |
||
1056 | * |
||
1057 | * @since 1.28 |
||
1058 | */ |
||
1059 | public function finalizeAdaptiveCacheExpiry() { |
||
1078 | |||
1079 | public function __sleep() { |
||
1085 | } |
||
1086 |