Skip to content

If php source is invoked when it's being created, HHVM will lost the complete code. #1447

Closed
@wwbmmm

Description

@wwbmmm

code to reproduce:

$ cat test.php

<?php
$file = 'code.php';
$fd = fopen($file, 'w+');
fwrite($fd, "<?php\n");
echo "Include when file is incomplete\n";
include($file);
fwrite($fd, "var_dump('Hello World');\n");
fclose($fd);

sleep(1); // sleep enough time for file reload

echo "Include when file is complete\n";
include($file);

$ hhvm test.php

Include when file is incomplete
Include when file is complete

$ rm code.php
$ php test.php

Include when file is incomplete
Include when file is complete
string(11) "Hello World"

When request this test.php in server mode, and then request code.php, you will get an empty response even after a long time, until code.php is modified or hhvm is restarted.

This may happen in actual scene online. For example, there is file a.php at the beginning and do the whole work. After some updates, file b.php is added and included in file a.php . During the online deployment, file a.php is modified first. When file b.php is being created, a request come up and invoke file a.php, that cause HHVM to parse and invoke the incomplete file b.php. After b.php is written completely, HHVM will not reload this file, so the incomplete b.php is always being used.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions