FFFF Idea: ContainerBuilder: avoid fopen if file is in opcode cache by JanTvrdik · Pull Request #27 · nette/di · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .php  (1)

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/DI/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ protected function generateConfig()
private function loadClass()
{
$key = md5(serialize(array($this->config, $this->configFiles, $this->class, $this->parentClass)));
$handle = fopen($file = "$this->tempDirectory/$key.php", 'c+');
$file = "$this->tempDirectory/$key.php";

if (!$this->autoRebuild && function_exists('opcache_is_script_cached') && opcache_is_script_cached($file)) {
require $file; // not atomic, any idea?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I am correct but I traced file reading back to zend_fopen_wrapper, is that the function that ultimately loads the script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, why?

return;
}

$handle = fopen($file, 'c+');
if (!$handle) {
throw new Nette\IOException("Unable to open or create file '$file'.");
}
Expand Down
0