@@ -56,11 +56,17 @@ class Storage {
5656 public const DELETE_TRIGGER_QUOTA_EXCEEDED = 2 ;
5757
5858 // files for which we can remove the versions after the delete operation was successful
59- private static $ deletedFiles = [];
59+ /**
60+ * @psalm-suppress ImpureStaticProperty
61+ */
62+ private static array $ deletedFiles = [];
6063
61- private static $ sourcePathAndUser = [];
64+ /**
65+ * @psalm-suppress ImpureStaticProperty
66+ */
67+ private static array $ sourcePathAndUser = [];
6268
63- private static $ max_versions_per_interval = [
69+ private const MAX_VERSIONS_PER_INTERVAL = [
6470 //first 10sec, one version every 2sec
6571 1 => ['intervalEndsAfter ' => 10 , 'step ' => 2 ],
6672 //next minute, one version every 10sec
@@ -763,12 +769,8 @@ protected static function getAutoExpireList($time, $versions) {
763769 $ toDelete = []; // versions we want to delete
764770
765771 $ interval = 1 ;
766- $ step = Storage::$ max_versions_per_interval [$ interval ]['step ' ];
767- if (Storage::$ max_versions_per_interval [$ interval ]['intervalEndsAfter ' ] === -1 ) {
768- $ nextInterval = -1 ;
769- } else {
770- $ nextInterval = $ time - Storage::$ max_versions_per_interval [$ interval ]['intervalEndsAfter ' ];
771- }
772+ $ step = Storage::MAX_VERSIONS_PER_INTERVAL [$ interval ]['step ' ];
773+ $ nextInterval = $ time - Storage::MAX_VERSIONS_PER_INTERVAL [$ interval ]['intervalEndsAfter ' ];
772774
773775 $ firstVersion = reset ($ versions );
774776
@@ -797,12 +799,16 @@ protected static function getAutoExpireList($time, $versions) {
797799 $ newInterval = false ; // version checked so we can move to the next one
798800 } else { // time to move on to the next interval
799801 $ interval ++;
800- $ step = Storage::$ max_versions_per_interval [$ interval ]['step ' ];
802+ if ($ interval > count (Storage::MAX_VERSIONS_PER_INTERVAL )) {
803+ /* Should never happen, as last interval has -1 as nextInterval */
804+ throw new \Exception ('MAX_VERSIONS_PER_INTERVAL is malformed or there is a logic issue ' );
805+ }
806+ $ step = Storage::MAX_VERSIONS_PER_INTERVAL [$ interval ]['step ' ];
801807 $ nextVersion = $ prevTimestamp - $ step ;
802- if (Storage::$ max_versions_per_interval [$ interval ]['intervalEndsAfter ' ] === -1 ) {
808+ if (Storage::MAX_VERSIONS_PER_INTERVAL [$ interval ]['intervalEndsAfter ' ] === -1 ) {
803809 $ nextInterval = -1 ;
804810 } else {
805- $ nextInterval = $ time - Storage::$ max_versions_per_interval [$ interval ]['intervalEndsAfter ' ];
811+ $ nextInterval = $ time - Storage::MAX_VERSIONS_PER_INTERVAL [$ interval ]['intervalEndsAfter ' ];
806812 }
807813 $ newInterval = true ; // we changed the interval -> check same version with new interval
808814 }
0 commit comments