Added an array of SecondaryDataUpdate objects to ParserOutput

Change-Id: I329be83a0899b3f16c99119f2f802233a157ee42
This commit is contained in:
daniel 2012-04-05 17:21:07 +02:00
parent 6e27659f57
commit cc365c3552

View file

@ -140,8 +140,9 @@ class ParserOutput extends CacheTime {
$mProperties = array(), # Name/value pairs to be cached in the DB
$mTOCHTML = '', # HTML of the TOC
$mTimestamp; # Timestamp of the revision
private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
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 instances of SecondaryDataObject(), used to cause some information extracted from the page in a custom place.
const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
@ -447,4 +448,53 @@ class ParserOutput extends CacheTime {
function recordOption( $option ) {
$this->mAccessedOptions[$option] = true;
}
/**
* Adds an update job to the output. Any update jobs added to the output will eventually bexecuted in order to
* store any secondary information extracted from the page's content.
*
* @param SecondaryDataUpdate $update
*/
public function addSecondaryDataUpdate( SecondaryDataUpdate $update ) {
$this->mSecondaryDataUpdates[] = $update;
}
/**
* Returns any SecondaryDataUpdate jobs to be executed in order to store secondary information
* extracted from the page's content.
*
* This does not automatically include an LinksUpdate object for the links in this ParserOutput instance.
* Use getLinksUpdateAndOtherUpdates() if you want that.
*
* @return array an array of instances of SecondaryDataUpdate
*/
public function getSecondaryDataUpdates() {
return $this->mSecondaryDataUpdates;
}
/**
* Conveniance method that returns any SecondaryDataUpdate jobs to be executed in order
* to store secondary information extracted from the page's content, including the LinksUpdate object
* for all links stopred in this ParserOutput object.
*
* @param $title Title of the page we're updating. If not given, a title object will be created based on $this->getTitleText()
* @param $recursive Boolean: queue jobs for recursive updates?
*
* @return array an array of instances of SecondaryDataUpdate
*/
public function getLinksUpdateAndOtherUpdates( Title $title = null, $recursive = true ) {
if ( empty( $title ) ) {
$title = Title::newFromText( $this->getTitleText() );
}
$linksUpdate = new LinksUpdate( $title, $this, $recursive );
if ( empty( $this->mSecondaryDataUpdates ) ) {
return array( $linksUpdate );
} else {
$updates = array_merge( $this->mSecondaryDataUpdates, array( $linksUpdate ) );
}
return $updates;
}
}