Semantic MediaWiki and related extensions
Public Member Functions | List of all members
SMW\SQLStore\RedirectUpdater Class Reference

Public Member Functions

 __construct (Store $store, IdChanger $idChanger, TableFieldUpdater $tableFieldUpdater, PropertyStatisticsStore $propertyStatisticsStore)
 
 setEqualitySupport (int $equalitySupport)
 
 applyChangesFromListener (string $key, ChangeRecord $changeRecord)
 
 moveSubobjects ( $source, $oldnamespace, $target, $newnamespace)
 
 doUpdate (DIWikiPage $source, DIWikiPage $target, array $options)
 
 invalidateLookupCache (CachingSemanticDataLookup $semanticDataLookup)
 
 triggerChangeTitleUpdate (Title $source, Title $target, array $options)
 
 shouldCleanUpAnnotationsAndRedirects (array $redirects=[])
 
 cleanUpAnnotationsAndRedirects (DIWikiPage $subject, array $redirects)
 
 discardRemnantRedirects (DIWikiPage $subject)
 
 updateRedirects (DIWikiPage $source, DIWikiPage $target=null)
 

Detailed Description

GNU GPL v2+

Since
3.1
Author
mwjames

Constructor & Destructor Documentation

◆ __construct()

SMW\SQLStore\RedirectUpdater::__construct ( Store  $store,
IdChanger  $idChanger,
TableFieldUpdater  $tableFieldUpdater,
PropertyStatisticsStore  $propertyStatisticsStore 
)
Since
3.1
Parameters
Store$store
IdChanger$idChanger
TableFieldUpdater$tableFieldUpdater
PropertyStatisticsStore$propertyStatisticsStore

Member Function Documentation

◆ applyChangesFromListener()

SMW\SQLStore\RedirectUpdater::applyChangesFromListener ( string  $key,
ChangeRecord  $changeRecord 
)

This method applies changes from when the Settings change listener receives change events from Settings:set.

Since
3.2
Parameters
string$key
ChangeRecord$changeRecord

◆ cleanUpAnnotationsAndRedirects()

SMW\SQLStore\RedirectUpdater::cleanUpAnnotationsAndRedirects ( DIWikiPage  $subject,
array  $redirects 
)
Since
3.2
Parameters
DIWikiPage$subject
array$redirects

◆ discardRemnantRedirects()

SMW\SQLStore\RedirectUpdater::discardRemnantRedirects ( DIWikiPage  $subject)
Since
3.2
Parameters
DIWikiPage$subject

◆ doUpdate()

SMW\SQLStore\RedirectUpdater::doUpdate ( DIWikiPage  $source,
DIWikiPage  $target,
array  $options 
)

Implementation of SMWStore::changeTitle(). In contrast to updateRedirects(), this function does not simply write a redirect from the old page to the new one, but also deletes all data that may already be stored for the new title (normally the new title should belong to an empty page that has no data but at least it could have a redirect to the old page), and moves all data that exists for the old title to the new location. Thus, the function executes three steps: delete data at newtitle, move data from oldtitle to newtitle, and set redirect from oldtitle to newtitle. In some cases, the goal can be achieved more efficiently, e.g. if the new title does not occur in SMW yet: then we can just change the ID records for the titles instead of changing all data tables

Note that the implementation ignores the MediaWiki IDs since this store has its own ID management. Also, the function requires that both titles are local, i.e. have empty interwiki prefix.

Todo:
Currently the sortkey is not moved with the remaining data. It is not possible to move it reliably in all cases: we cannot distinguish an unset sortkey from one that was set to the name of oldtitle. Maybe use update jobs right away?
Since
1.8
Parameters
Title$oldTitle
Title$newTitle
integer$pageId
integer$redirectId

◆ invalidateLookupCache()

SMW\SQLStore\RedirectUpdater::invalidateLookupCache ( CachingSemanticDataLookup  $semanticDataLookup)
Since
3.1
Parameters
CachingSemanticDataLookup$semanticDataLookup

◆ moveSubobjects()

SMW\SQLStore\RedirectUpdater::moveSubobjects (   $source,
  $oldnamespace,
  $target,
  $newnamespace 
)

Move all cached information about subobjects.

Todo:
This method is neither efficient nor very convincing architecturally; it should be redesigned.
Since
1.8
Parameters
string$source
integer$oldnamespace
string$target
integer$newnamespace

◆ setEqualitySupport()

SMW\SQLStore\RedirectUpdater::setEqualitySupport ( int  $equalitySupport)
Since
3.1
Parameters
integer$equalitySupport

◆ shouldCleanUpAnnotationsAndRedirects()

SMW\SQLStore\RedirectUpdater::shouldCleanUpAnnotationsAndRedirects ( array  $redirects = [])
Since
3.2
Parameters
array$redirects
Returns
boolean

◆ triggerChangeTitleUpdate()

SMW\SQLStore\RedirectUpdater::triggerChangeTitleUpdate ( Title  $source,
Title  $target,
array  $options 
)
Since
3.1
Parameters
Title$source
Title$target
array$options

◆ updateRedirects()

SMW\SQLStore\RedirectUpdater::updateRedirects ( DIWikiPage  $source,
DIWikiPage  $target = null 
)

Helper method to write information about some redirect. Various updates can be necessary if redirects are resolved as identities in SMW. The title and namespace of the affected page and of its updated redirect target are given. The target can be empty ('') to delete any redirect. Returns the canonical ID that is now to be used for the subject.

This method does not change the ids of the affected pages, and thus it is not concerned with updates of the data that is currently stored for the subject. Normally, a subject that is a redirect will not have other data, but this method does not depend on this.

Note
Please make sure you fully understand this code before making any changes here. Keeping the redirect structure consistent is important, and errors in this code can go unnoticed for quite some time.
This method merely handles the addition or deletion of a redirect statement in the wiki. It does not assume that any page contents has been changed (e.g. moved). See changeTitle() for additional handling in this case.
Todo:
Clean up this code.
Since
1.8
Parameters
string$subject_t
integer$subject_ns
string$curtarget_t
integer$curtarget_ns
Returns
integer the new canonical ID of the subject

The documentation for this class was generated from the following file:

About | General disclaimer | Privacy policy