Skip to content

Commit 1e6bcad

Browse files
committed
$refreshed is set in rebuildCallback()
1 parent 51b4778 commit 1e6bcad

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/RobotLoader/RobotLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public function getIndexedClasses()
143143
*/
144144
public function rebuild()
145145
{
146-
$this->refreshed = TRUE; // prevents calling rebuild() or updateFile() in tryLoad()
147146
$this->getCache()->save($this->getKey(), Nette\Utils\Callback::closure($this, 'rebuildCallback'));
148147
}
149148

@@ -153,6 +152,7 @@ public function rebuild()
153152
*/
154153
public function rebuildCallback()
155154
{
155+
$this->refreshed = TRUE; // prevents calling rebuild() or updateFile() in tryLoad()
156156
$files = $missing = [];
157157
foreach ($this->classes as $class => $info) {
158158
if (is_array($info)) {

tests/Loaders/RobotLoader.rebuild.phpt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
use Nette\Loaders\RobotLoader;
8-
use Nette\Caching\Storages\DevNullStorage;
8+
use Nette\Caching\Storages\FileStorage;
99
use Tester\Assert;
1010

1111

@@ -16,13 +16,21 @@ file_put_contents(TEMP_DIR . '/file1.php', '<?php class A {}');
1616
file_put_contents(TEMP_DIR . '/file2.php', '<?php class B {}');
1717

1818
$loader = new RobotLoader;
19-
$loader->setCacheStorage(new DevNullStorage);
19+
$loader->setCacheStorage(new FileStorage(TEMP_DIR));
2020
$loader->addDirectory(TEMP_DIR);
21-
$loader->register();
21+
$loader->register(); // rebuilds cache
2222

2323
rename(TEMP_DIR . '/file1.php', TEMP_DIR . '/file3.php');
2424

25-
$a = new A;
25+
Assert::false(class_exists('A'));
26+
27+
28+
$loader2 = new RobotLoader;
29+
$loader2->setCacheStorage(new FileStorage(TEMP_DIR));
30+
$loader2->addDirectory(TEMP_DIR);
31+
$loader2->register();
32+
33+
Assert::true(class_exists('A'));
2634

2735
rename(TEMP_DIR . '/file2.php', TEMP_DIR . '/file4.php');
2836

0 commit comments

Comments
 (0)