Skip to content

Commit 0671573

Browse files
committed
fixed buggy behavior after 788ab3e
1 parent cb635b3 commit 0671573

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

src/RobotLoader/RobotLoader.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,39 @@ public function register(bool $prepend = false): self
8585
*/
8686
public function tryLoad(string $type): void
8787
{
88+
$missing = $this->missing[$type] ?? null;
89+
if ($missing >= self::RETRY_LIMIT) {
90+
return;
91+
}
92+
8893
$info = $this->classes[$type] ?? null;
8994

9095
if ($this->autoRebuild) {
91-
if (!$info || !is_file($info['file'])) {
92-
$missing = &$this->missing[$type];
93-
$missing++;
94-
if (!$this->refreshed && $missing <= self::RETRY_LIMIT) {
96+
$save = false;
97+
98+
if (!$this->refreshed) {
99+
if (!$info || !is_file($info['file'])) {
95100
$this->refreshClasses();
96-
$this->saveCache();
97-
} elseif ($info) {
98-
unset($this->classes[$type]);
99-
$this->saveCache();
100-
}
101+
$info = $this->classes[$type] ?? null;
102+
$save = true;
101103

102-
} elseif (!$this->refreshed && filemtime($info['file']) !== $info['time']) {
103-
$this->updateFile($info['file']);
104-
if (empty($this->classes[$type])) {
105-
$this->missing[$type] = 0;
104+
} elseif (filemtime($info['file']) !== $info['time']) {
105+
$this->updateFile($info['file']);
106+
$info = $this->classes[$type] ?? null;
107+
$save = true;
106108
}
109+
}
110+
111+
if (!$info || !is_file($info['file'])) {
112+
$this->missing[$type] = ++$missing;
113+
$save = $save || $info || ($missing <= self::RETRY_LIMIT);
114+
unset($this->classes[$type]);
115+
$info = null;
116+
}
117+
118+
if ($save) {
107119
$this->saveCache();
108120
}
109-
$info = $this->classes[$type] ?? null;
110121
}
111122

112123
if ($info) {

0 commit comments

Comments
 (0)