Merge pull request #9019 from annando/performance

Some performance tweaks
This commit is contained in:
Hypolite Petovan 2020-08-16 10:07:35 -04:00 committed by GitHub
commit a7f8604d42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 8 deletions

View file

@ -97,6 +97,8 @@ class User
* @}
*/
private static $owner;
/**
* Returns true if a user record exists with the provided id
*
@ -211,8 +213,12 @@ class User
* @return boolean|array
* @throws Exception
*/
public static function getOwnerDataById($uid, $check_valid = true)
public static function getOwnerDataById(int $uid, bool $check_valid = true)
{
if (!empty(self::$owner[$uid])) {
return self::$owner[$uid];
}
$owner = DBA::selectFirst('owner-view', [], ['uid' => $uid]);
if (!DBA::isResult($owner)) {
if (!DBA::exists('user', ['uid' => $uid]) || !$check_valid) {
@ -256,6 +262,7 @@ class User
$owner = self::getOwnerDataById($uid, false);
}
self::$owner[$uid] = $owner;
return $owner;
}