File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public function __construct(
5555 }
5656
5757 /**
58- * @param string $userId
58+ * @param string $userId It can be an empty string
5959 * @param int $type
6060 * @param int $usage
6161 * @throws Exception If there is an error creating the quota usage.
Original file line number Diff line number Diff line change @@ -34,21 +34,26 @@ public function __construct(
3434 private LoggerInterface $ logger ,
3535 ) {
3636 }
37+
3738 /**
3839 * Returns the quota rule for the given user
3940 *
4041 * @param int $quotaType
41- * @param string $userId
42+ * @param string $userId It can be an empty string
4243 * @return array
4344 */
4445 public function getRule (int $ quotaType , string $ userId ) {
4546 $ cache = $ this ->cacheFactory ->createDistributed (Application::APP_ID );
4647 $ cacheKey = Application::QUOTA_RULES_CACHE_PREFIX . $ quotaType . '- ' . $ userId ;
4748 $ rule = $ cache ->get ($ cacheKey );
4849 if ($ rule === null ) {
49- $ user = $ this ->userManager ->get ($ userId );
50- $ groups = $ this ->groupManager ->getUserGroupIds ($ user );
5150 try {
51+ $ user = $ this ->userManager ->get ($ userId );
52+ if ($ user === null ) {
53+ // re-use the db exception for not found users
54+ throw new DoesNotExistException ('User not found: ' . $ userId );
55+ }
56+ $ groups = $ this ->groupManager ->getUserGroupIds ($ user );
5257 $ rule = $ this ->quotaRuleMapper ->getRule ($ quotaType , $ userId , $ groups )->jsonSerialize ();
5358 } catch (DoesNotExistException |MultipleObjectsReturnedException ) {
5459 $ rule = [
You can’t perform that action at this time.
0 commit comments