Jack Phoenix has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/403842 )
Change subject: wfMemcKey (deprecated in MW 1.30) -> makeKey() on a BagOStuff
instance
......................................................................
wfMemcKey (deprecated in MW 1.30) -> makeKey() on a BagOStuff instance
Change-Id: Ib40ec6ec8e148c8f60e6bfd8a740a783b202a648
---
M ArticleFeedbackv5.activity.php
M ArticleFeedbackv5.hooks.php
M ArticleFeedbackv5.model.php
M api/ApiAddFlagNoteArticleFeedbackv5.php
M data/DataModel.php
M data/maintenance/DataModelPurgeCache.php
M data/tests/DataModelSampleTests.php
M maintenance/purgeCache.php
M tests/ArticleFeedbackv5ModelTest.php
9 files changed, 29 insertions(+), 28 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5
refs/changes/42/403842/1
diff --git a/ArticleFeedbackv5.activity.php b/ArticleFeedbackv5.activity.php
index a7dbbd8..7a2af83 100644
--- a/ArticleFeedbackv5.activity.php
+++ b/ArticleFeedbackv5.activity.php
@@ -188,7 +188,7 @@
* data in cache may be out of date.
*/
global $wgMemc;
- $key = wfMemcKey( get_called_class(),
'getLastEditorActivity', $itemId );
+ $key = $wgMemc->makeKey( get_called_class(),
'getLastEditorActivity', $itemId );
$wgMemc->delete( $key );
}
@@ -285,7 +285,7 @@
foreach( $wgArticleFeedbackv5Permissions as $permission
) {
if ( $user->isAllowed( $permission ) ) {
// get count for this specific
permission level from cache
- $key = wfMemcKey( 'articlefeedbackv5',
'getActivityCount', $permission, $feedback->aft_id );
+ $key = $wgMemc->makeKey(
'articlefeedbackv5', 'getActivityCount', $permission, $feedback->aft_id );
$count = $wgMemc->get( $key );
if ( $count === false ) {
@@ -322,7 +322,7 @@
// get permission level that should be updated
$permission = self::$actions[$action]['permissions'];
- $key = wfMemcKey( 'articlefeedbackv5', 'getActivityCount',
$permission, $feedbackId );
+ $key = $wgMemc->makeKey( 'articlefeedbackv5',
'getActivityCount', $permission, $feedbackId );
$count = $wgMemc->get( $key );
/*
@@ -389,7 +389,7 @@
continue;
}
- $key = wfMemcKey( get_called_class(),
'getLastEditorActivity', $feedback->aft_id );
+ $key = $wgMemc->makeKey( get_called_class(),
'getLastEditorActivity', $feedback->aft_id );
$cache = $wgMemc->get( $key );
if ( $cache !== false ) {
$activity[$feedback->aft_id] = $cache;
@@ -487,7 +487,7 @@
}
// cache, per feedback entry
- $key = wfMemcKey( get_called_class(),
'getLastEditorActivity', $params['feedbackId'] );
+ $key = $wgMemc->makeKey( get_called_class(),
'getLastEditorActivity', $params['feedbackId'] );
$wgMemc->set( $key, $action, 60 * 60 );
$activity[$params['feedbackId']] = $action;
diff --git a/ArticleFeedbackv5.hooks.php b/ArticleFeedbackv5.hooks.php
index e3f268e..01b50fe 100644
--- a/ArticleFeedbackv5.hooks.php
+++ b/ArticleFeedbackv5.hooks.php
@@ -518,7 +518,7 @@
if ( $pager->contribs == 'newbie' ) {
// fetch max user id from cache (if present)
global $wgMemc;
- $key = wfMemcKey( 'articlefeedbackv5', 'maxUserId' );
+ $key = $wgMemc->makeKey( 'articlefeedbackv5',
'maxUserId' );
$max = $wgMemc->get( $key );
if ( $max === false ) {
// max user id not present in cache; fetch from
db & save to cache for 1h
diff --git a/ArticleFeedbackv5.model.php b/ArticleFeedbackv5.model.php
index 5f29276..9cc0f34 100644
--- a/ArticleFeedbackv5.model.php
+++ b/ArticleFeedbackv5.model.php
@@ -245,7 +245,7 @@
return $existingValue + $difference;
};
- $key = wfMemcKey( get_called_class(), 'getCountFound',
$shard );
+ $key = static::getCache()->makeKey( get_called_class(),
'getCountFound', $shard );
static::getCache()->merge( $key, $callback );
}
}
@@ -261,7 +261,7 @@
* @return float
*/
public static function getCountFound( $pageId = null ) {
- $key = wfMemcKey( get_called_class(), 'getCountFound', $pageId
);
+ $key = static::getCache()->makeKey( get_called_class(),
'getCountFound', $pageId );
$found = static::getCache()->get( $key );
if ( $found === false ) {
diff --git a/api/ApiAddFlagNoteArticleFeedbackv5.php
b/api/ApiAddFlagNoteArticleFeedbackv5.php
index d5a2d8f..13c221e 100644
--- a/api/ApiAddFlagNoteArticleFeedbackv5.php
+++ b/api/ApiAddFlagNoteArticleFeedbackv5.php
@@ -74,7 +74,7 @@
* data in cache may be out of date.
*/
global $wgMemc;
- $key = wfMemcKey( 'ArticleFeedbackv5Activity',
'getLastEditorActivity', $feedbackId );
+ $key = $wgMemc->makeKey(
'ArticleFeedbackv5Activity', 'getLastEditorActivity', $feedbackId );
$wgMemc->delete( $key );
}
}
diff --git a/data/DataModel.php b/data/DataModel.php
index 3c1b619..9c83c83 100644
--- a/data/DataModel.php
+++ b/data/DataModel.php
@@ -188,7 +188,7 @@
* @return DataModel|bool
*/
public static function get( $id, $shard ) {
- $key = wfMemcKey( get_called_class(), 'get', $id, $shard );
+ $key = static::getCache()->makeKey( get_called_class(), 'get',
$id, $shard );
$entry = static::getCache()->get( $key );
// when not found in cache, load data from DB
@@ -253,8 +253,8 @@
}
// internal key to identify this exact list by
- $keyGetList = wfMemcKey( get_called_class(), 'getList', $name,
$shard, $offset, $sort, $order );
- $keyGetListValidity = wfMemcKey( get_called_class(),
'getListValidity', $name, $shard );
+ $keyGetList = static::getCache()->makeKey( get_called_class(),
'getList', $name, $shard, $offset, $sort, $order );
+ $keyGetListValidity = static::getCache()->makeKey(
get_called_class(), 'getListValidity', $name, $shard );
// get data from cache
$cache = static::getCache()->get( $keyGetList );
@@ -359,7 +359,7 @@
}
// internal key to identify this exact list by
- $key = wfMemcKey( get_called_class(), 'getCount', $name, $shard
);
+ $key = static::getCache()->makeKey( get_called_class(),
'getCount', $name, $shard );
// (try to) fetch list from cache
$count = static::getCache()->get( $key );
@@ -586,7 +586,7 @@
$id = $entry['id'];
$shard = $entry['shard'];
- $keyGet = wfMemcKey( get_called_class(), 'get', $id,
$shard );
+ $keyGet = static::getCache()->makeKey(
get_called_class(), 'get', $id, $shard );
if ( static::getCache()->get( $keyGet ) === false ) {
$missing[$id] = $shard;
}
@@ -615,7 +615,7 @@
* is not lagging; we don't want to cache outdated data.
*/
if ( static::getBackend()->allowCache() ) {
- $key = wfMemcKey( get_called_class(), 'get',
$this->{static::getIdColumn()}, $this->{static::getShardColumn()} );
+ $key = static::getCache()->makeKey( get_called_class(),
'get', $this->{static::getIdColumn()}, $this->{static::getShardColumn()} );
static::getCache()->set( $key, $this, 60 * 60 );
}
@@ -628,7 +628,7 @@
* @return DataModel
*/
public function uncache() {
- $key = wfMemcKey( get_called_class(), 'get',
$this->{static::getIdColumn()}, $this->{static::getShardColumn()} );
+ $key = static::getCache()->makeKey( get_called_class(), 'get',
$this->{static::getIdColumn()}, $this->{static::getShardColumn()} );
static::getCache()->delete( $key );
return $this;
@@ -652,7 +652,7 @@
*/
if ( static::getBackend()->allowCache() ) {
$cache = array( 'time' => wfTimestampNow(), 'list' =>
$list );
- $keyGetList = wfMemcKey( get_called_class(), 'getList',
$name, $shard, $offset, $sort, $order );
+ $keyGetList = static::getCache()->makeKey(
get_called_class(), 'getList', $name, $shard, $offset, $sort, $order );
static::getCache()->set( $keyGetList, $cache, 60 * 60 );
}
}
@@ -680,7 +680,7 @@
* found in this validity cache.
*/
foreach ( array( $shard, null ) as $shard ) {
- $key = wfMemcKey( get_called_class(),
'getListValidity', $name, $shard );
+ $key = static::getCache()->makeKey( get_called_class(),
'getListValidity', $name, $shard );
static::getCache()->set( $key, wfTimestampNow(), 60 *
60 );
}
}
@@ -753,7 +753,7 @@
// update both shard-specific as well as general all-shard count
foreach ( array( $shard, null ) as $shard ) {
$class = get_called_class();
- $key = wfMemcKey( $class, 'getCount', $name, $shard );
+ $key = static::getCache()->makeKey( $class, 'getCount',
$name, $shard );
/**
* Callback method, updating the cached counts.
diff --git a/data/maintenance/DataModelPurgeCache.php
b/data/maintenance/DataModelPurgeCache.php
index e607768..3849bde 100644
--- a/data/maintenance/DataModelPurgeCache.php
+++ b/data/maintenance/DataModelPurgeCache.php
@@ -107,7 +107,7 @@
$class::uncacheList( $list, $shard );
// clear counts
- $key = wfMemcKey( $class, 'getCount', $list, $shard );
+ $key = $class::getCache()->makeKey( $class, 'getCount',
$list, $shard );
$class::getCache()->delete( $key );
}
}
diff --git a/data/tests/DataModelSampleTests.php
b/data/tests/DataModelSampleTests.php
index c98bb67..eb6c238 100644
--- a/data/tests/DataModelSampleTests.php
+++ b/data/tests/DataModelSampleTests.php
@@ -56,7 +56,7 @@
// data in cache
global $wgMemc;
- $key = wfMemcKey( 'DataModelSample', 'get',
$this->sample->{DataModelSample::getIdColumn()},
$this->sample->{DataModelSample::getShardColumn()} );
+ $key = $wgMemc->makeKey( 'DataModelSample', 'get',
$this->sample->{DataModelSample::getIdColumn()},
$this->sample->{DataModelSample::getShardColumn()} );
$this->assertEquals( $this->sample, $wgMemc->get( $key ) );
// data in db
@@ -72,7 +72,7 @@
// data in cache
global $wgMemc;
- $key = wfMemcKey( 'DataModelSample', 'get',
$this->sample->{DataModelSample::getIdColumn()},
$this->sample->{DataModelSample::getShardColumn()} );
+ $key = $wgMemc->makeKey( 'DataModelSample', 'get',
$this->sample->{DataModelSample::getIdColumn()},
$this->sample->{DataModelSample::getShardColumn()} );
$this->assertEquals( $this->sample, $wgMemc->get( $key ) );
// data in db
diff --git a/maintenance/purgeCache.php b/maintenance/purgeCache.php
index 760b479..aed9eb3 100644
--- a/maintenance/purgeCache.php
+++ b/maintenance/purgeCache.php
@@ -39,7 +39,7 @@
// clear max user id
global $wgMemc;
- $wgMemc->delete( wfMemcKey( 'articlefeedbackv5', 'maxUserId' )
);
+ $wgMemc->delete( $wgMemc->makeKey( 'articlefeedbackv5',
'maxUserId' ) );
}
/**
@@ -55,12 +55,12 @@
// feedback activity count per permission
global $wgArticleFeedbackv5Permissions;
foreach( $wgArticleFeedbackv5Permissions as $permission ) {
- $key = wfMemcKey( 'articlefeedbackv5',
'getActivityCount', $permission, $object->aft_id );
+ $key = $wgMemc->makeKey( 'articlefeedbackv5',
'getActivityCount', $permission, $object->aft_id );
$wgMemc->delete( $key );
}
// feedback last editor activity
- $key = wfMemcKey( 'ArticleFeedbackv5Activity',
'getLastEditorActivity', $object->aft_id );
+ $key = $wgMemc->makeKey( 'ArticleFeedbackv5Activity',
'getLastEditorActivity', $object->aft_id );
$wgMemc->delete( $key );
}
@@ -75,7 +75,8 @@
$class = $this->getClass();
// clear page found percentage
- $key = wfMemcKey( $class, 'getCountFound', $shard );
+ global $wgMemc;
+ $key = $wgMemc->makeKey( $class, 'getCountFound', $shard );
$class::getCache()->delete( $key );
}
}
diff --git a/tests/ArticleFeedbackv5ModelTest.php
b/tests/ArticleFeedbackv5ModelTest.php
index 58c67ac..6f21507 100644
--- a/tests/ArticleFeedbackv5ModelTest.php
+++ b/tests/ArticleFeedbackv5ModelTest.php
@@ -68,7 +68,7 @@
// data in cache
global $wgMemc;
- $key = wfMemcKey( 'ArticleFeedbackv5Model', 'get',
$this->sample->{ArticleFeedbackv5Model::getIdColumn()},
$this->sample->{ArticleFeedbackv5Model::getShardColumn()} );
+ $key = $wgMemc->makeKey( 'ArticleFeedbackv5Model', 'get',
$this->sample->{ArticleFeedbackv5Model::getIdColumn()},
$this->sample->{ArticleFeedbackv5Model::getShardColumn()} );
$this->assertEquals( $this->sample, $wgMemc->get( $key ) );
// data in db
@@ -84,7 +84,7 @@
// data in cache
global $wgMemc;
- $key = wfMemcKey( 'ArticleFeedbackv5Model', 'get',
$this->sample->{ArticleFeedbackv5Model::getIdColumn()},
$this->sample->{ArticleFeedbackv5Model::getShardColumn()} );
+ $key = $wgMemc->makeKey( 'ArticleFeedbackv5Model', 'get',
$this->sample->{ArticleFeedbackv5Model::getIdColumn()},
$this->sample->{ArticleFeedbackv5Model::getShardColumn()} );
$this->assertEquals( $this->sample, $wgMemc->get( $key ) );
// data in db
--
To view, visit https://gerrit.wikimedia.org/r/403842
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib40ec6ec8e148c8f60e6bfd8a740a783b202a648
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits