22 private $jobQueueGroup;
25 private $newProps = [];
28 private $existingProps;
38 private $linkInvalidations;
46 $this->jobQueueGroup = $jobQueueGroup;
64 return [
'pp_propname',
'pp_value' ];
68 foreach ( $this->newProps as $name => $value ) {
69 yield [ (string)$name, $value ];
78 private function getExistingProps() {
79 if ( $this->existingProps ===
null ) {
80 $this->existingProps = [];
82 $this->existingProps[$row->pp_propname] = $row->pp_value;
85 return $this->existingProps;
89 foreach ( $this->getExistingProps() as $name => $value ) {
90 yield [ (string)$name, $value ];
95 $existing = $this->getExistingProps();
96 [ $name, $value ] = $linkId;
97 return \array_key_exists( $name, $existing )
98 && $this->encodeValue( $existing[$name] ) === $this->encodeValue( $value );
102 [ $name, $value ] = $linkId;
103 return \array_key_exists( $name, $this->newProps )
104 && $this->encodeValue( $this->newProps[$name] ) === $this->encodeValue( $value );
107 private function encodeValue( $value ) {
108 if ( is_bool( $value ) ) {
109 return (
string)(int)$value;
110 } elseif ( $value ===
null ) {
113 return (
string)$value;
118 [ $name, $value ] = $linkId;
120 'pp_propname' => $name,
121 'pp_value' => $this->encodeValue( $value ),
122 'pp_sortkey' => $this->getPropertySortKeyValue( $value )
138 private function getPropertySortKeyValue( $value ) {
139 if ( is_int( $value ) || is_float( $value ) || is_bool( $value ) ) {
140 return floatval( $value );
148 'pp_propname' => $linkId[0]
153 $changed = array_unique( array_merge(
154 array_column( $this->insertedLinks, 0 ),
155 array_column( $this->deletedLinks, 0 ) ) );
156 $this->invalidateProperties( $changed );
164 private function invalidateProperties( array $changed ) {
166 foreach ( $changed as $name ) {
167 if ( isset( $this->linkInvalidations[$name] ) ) {
168 $inv = $this->linkInvalidations[$name];
169 if ( !is_array( $inv ) ) {
172 foreach ( $inv as $table ) {
176 [
'causeAction' =>
'page-props' ]
183 $this->jobQueueGroup->lazyPush( $jobs );
195 foreach ( $this->
getLinkIDs( $setType ) as $linkId ) {
196 [ $name, $value ] = $linkId;
197 $props[$name] = $value;
Job to purge the HTML/file cache for all pages that link to or use another page or file.
static newForBacklinks(PageReference $page, $table, $params=[])
Class to handle enqueueing of background jobs.
finishUpdate()
Subclasses can override this to do any updates associated with their link data, for example dispatchi...
getFromField()
Get the name of the field which links to page_id.
getExistingFields()
Get the fields to be used in fetchExistingRows().
insertLink( $linkId)
Insert a link identified by ID.
isExisting( $linkId)
Determine whether a link (from the new set) is in the existing set.
deleteLink( $linkId)
Delete a link identified by ID.
getExistingLinkIDs()
Get an array (or iterator) of link IDs for the existing state.
__construct(ServiceOptions $options, JobQueueGroup $jobQueueGroup)
setParserOutput(ParserOutput $parserOutput)
Subclasses should implement this to extract the data they need from the ParserOutput.
const CONSTRUCTOR_OPTIONS
getAssocArray( $setType)
Get the properties for a given link set as an associative array.
getTableName()
Get the table name.
getNewLinkIDs()
Get an array (or iterator) of link IDs for the new state.
isInNewSet( $linkId)
Determine whether a link (from the existing set) is in the new set.
A class containing constants representing the names of configuration variables.
const PagePropLinkInvalidations
Name constant for the PagePropLinkInvalidations setting, for use with Config::get()
getPageProperties()
Return all the page properties set on this ParserOutput.