private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
+ private $mCustomDataUpdateCount = 0; # Number of custom updaters in $mSecondaryDataUpdates.
private $mExtensionData = array(); # extra data used by extensions
private $mLimitReportData = array(); # Parser limit report data
private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
* Add a tracking category, getting the title from a system message,
* or print a debug message if the title is invalid.
*
- * Please add any message that you use with this function to
- * $wgTrackingCategories. That way they will be listed on
- * Special:TrackingCategories.
+ * Any message used with this function should be registered so it will
+ * show up on Special:TrackingCategories. Core messages should be added
+ * to SpecialTrackingCategories::$coreTrackingCategories, and extensions
+ * should add to "TrackingCategories" in their extension.json.
*
* @param string $msg Message key
* @param Title $title title of the page which is being tracked
* from the page's content. This is triggered by calling getSecondaryDataUpdates()
* and is used for forward links updates on edit and backlink updates by jobs.
*
+ * @note: custom DataUpdates do not survive serialization of the ParserOutput!
+ * This is especially relevant when using a cached ParserOutput for updating
+ * the database, as WikiPage does if $wgAjaxStashEdit is enabled. For this
+ * reason, ApiStashEdit will skip any ParserOutput that has custom DataUpdates.
+ *
* @since 1.20
*
* @param DataUpdate $update
*/
public function addSecondaryDataUpdate( DataUpdate $update ) {
$this->mSecondaryDataUpdates[] = $update;
+ $this->mCustomDataUpdateCount = count( $this->mSecondaryDataUpdates );
+ }
+
+ /**
+ * Whether this ParserOutput contains custom DataUpdate objects that may not survive
+ * serialization of the ParserOutput.
+ *
+ * @see __sleep()
+ *
+ * @return bool
+ */
+ public function hasCustomDataUpdates() {
+ return ( $this->mCustomDataUpdateCount > 0 );
}
/**
* be created based on $this->getTitleText()
* @param bool $recursive Queue jobs for recursive updates?
*
+ * @throws MWException if called on a ParserOutput instance that was restored from serialization.
+ * DataUpdates are generally not serializable, so after serialization, they are undefined.
+ *
* @return array An array of instances of DataUpdate
*/
public function getSecondaryDataUpdates( Title $title = null, $recursive = true ) {
$title = Title::newFromText( $this->getTitleText() );
}
+ if ( count( $this->mSecondaryDataUpdates ) !== $this->mCustomDataUpdateCount ) {
+ // NOTE: This happens when mSecondaryDataUpdates are lost during serialization
+ // (see __sleep below). After (un)serialization, getSecondaryDataUpdates()
+ // has no defined behavior in that case, and should throw an exception.
+ throw new MWException( 'getSecondaryDataUpdates() must not be called on ParserOutput restored from serialization.' );
+ }
+
+ // NOTE: ApiStashEdit knows about this "magic" update object. If this goes away,
+ // ApiStashEdit::buildStashValue needs to be adjusted.
$linksUpdate = new LinksUpdate( $title, $this, $recursive );
return array_merge( $this->mSecondaryDataUpdates, array( $linksUpdate ) );