mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Fall back to local notification count when no global user is found
When MWEchoNotifUser::getGlobalMemcKey does not find a global user, MWEchoNotifUser::getCountsAndTimestamps can return null for 'global' key Just fall back to the local count/timestamp Bug: T317330 Change-Id: Ie11b0c93c0a45fb1f873bd26788beaa3d0c6a9d7
This commit is contained in:
parent
2abf220e58
commit
b34e2c0697
|
@ -210,6 +210,10 @@ class MWEchoNotifUser {
|
|||
}
|
||||
|
||||
$data = $this->getCountsAndTimestamps( $global );
|
||||
if ( $global && $data['global'] === null ) {
|
||||
// No global user exists, no data. Use only local count
|
||||
$global = false;
|
||||
}
|
||||
$count = $data[$global ? 'global' : 'local'][$section]['count'];
|
||||
return (int)$count;
|
||||
}
|
||||
|
@ -258,6 +262,10 @@ class MWEchoNotifUser {
|
|||
}
|
||||
|
||||
$data = $this->getCountsAndTimestamps( $global );
|
||||
if ( $global && $data['global'] === null ) {
|
||||
// No global user exists, no data. Use only local count
|
||||
$global = false;
|
||||
}
|
||||
$timestamp = $data[$global ? 'global' : 'local'][$section]['timestamp'];
|
||||
return $timestamp === -1 ? false : new MWTimestamp( $timestamp );
|
||||
}
|
||||
|
@ -537,10 +545,10 @@ class MWEchoNotifUser {
|
|||
* ],
|
||||
* ]
|
||||
* Where N is a number and TS is a timestamp in TS_MW format or -1. If $includeGlobal is false,
|
||||
* the 'global' key will not be present.
|
||||
* the 'global' key will not be present. It could be null, if no global user exists.
|
||||
*
|
||||
* @param bool $includeGlobal Whether to include cross-wiki notifications as well
|
||||
* @return array[]
|
||||
* @return array
|
||||
*/
|
||||
public function getCountsAndTimestamps( $includeGlobal = false ) {
|
||||
if ( $this->localCountsAndTimestamps === null ) {
|
||||
|
|
Loading…
Reference in a new issue