Robert Vogel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/349187 )
Change subject: BSFoundation: Used own title invalidation method
......................................................................
BSFoundation: Used own title invalidation method
* We needed an immediate invalidation of the entity data source title
instead of the onTransactionIdle, that is used by
Title::invalidateCache. Now the touched timestamp is correct in the
entity index for BlueSpiceSocial
* Also added the Hook BSEntityInvalidate, so external services know,
when the entity was modiefied in any way
Change-Id: I71a3562871a6dfebc2706ec5dc0a66c8f3ee71d3
---
M includes/Entity.php
1 file changed, 35 insertions(+), 1 deletion(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation
refs/changes/87/349187/1
diff --git a/includes/Entity.php b/includes/Entity.php
index fde12ef..97ac210 100644
--- a/includes/Entity.php
+++ b/includes/Entity.php
@@ -508,8 +508,42 @@
* @return BSEntity
*/
public function invalidateCache() {
- $this->getTitle()->invalidateCache();
+ $this->invalidateTitleCache( wfTimestampNow() );
static::detachCache( $this );
+ Hooks::run( 'BSEntityInvalidate', array( $this ) );
return $this;
}
+
+ /**
+ * Almost a copy of Title::invalidateCache method - but we need an
immediate
+ * invalidation, not whenever the db feels 'idle'
+ * Updates page_touched for this page; called from LinksUpdate.php
+ *
+ * @param string $purgeTime [optional] TS_MW timestamp
+ * @return bool True if the update succeeded
+ */
+ protected function invalidateTitleCache( $purgeTime = null ) {
+ if ( wfReadOnly() ) {
+ return false;
+ }
+
+ if( !$this->getTitle()->exists() ) {
+ return true; // avoid gap locking if we know it's not
there
+ }
+
+ $method = __METHOD__;
+ $dbw = wfGetDB( DB_MASTER );
+ $conds = $this->getTitle()->pageCond();
+
+ $dbTimestamp = $dbw->timestamp( $purgeTime ?: time() );
+
+ $dbw->update(
+ 'page',
+ [ 'page_touched' => $dbTimestamp ],
+ $conds + [ 'page_touched < ' . $dbw->addQuotes(
$dbTimestamp ) ],
+ $method
+ );
+
+ return true;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/349187
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I71a3562871a6dfebc2706ec5dc0a66c8f3ee71d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: REL1_27
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits