Skip to content

Commit 9c5a902

Browse files
dstogovweltling
authored andcommitted
Fixed Issue #140: "opcache.enable_file_override" doesn't respect "opcache.revalidate_freq"
1 parent 78f2ded commit 9c5a902

File tree

5 files changed

+108
-4
lines changed

5 files changed

+108
-4
lines changed

NEWS

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,65 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 20??, PHP 5.7.0
44

5+
- Core:
6+
. Disallowed JMP into a finally block. (Laruence)
7+
. Added validation of class names in the autoload process. (Dmitry)
8+
. Fixed invalid C code in zend_strtod.c. (Lior Kaplan)
9+
. Fixed bug #66041 (list() fails to unpack yielded ArrayAccess object).
10+
(Nikita)
11+
. Fixed bug #65764 (generators/throw_rethrow FAIL with
12+
ZEND_COMPILE_EXTENDED_INFO). (Nikita)
13+
. Fixed bug #61645 (fopen and O_NONBLOCK). (Mike)
14+
. Fixed bug #66218 (zend_register_functions breaks reflection). (Remi)
15+
16+
- Date:
17+
. Fixed bug #66060 (Heap buffer over-read in DateInterval). (Remi)
18+
. Fixed bug #65768 (DateTimeImmutable::diff does not work). (Nikita Nefedov)
19+
20+
- DOM:
21+
. Fixed bug #65196 (Passing DOMDocumentFragment to DOMDocument::saveHTML()
22+
Produces invalid Markup). (Mike)
23+
24+
- Exif:
25+
. Fixed bug #65873 (Integer overflow in exif_read_data()). (Stas)
26+
27+
- Filter:
28+
. Fixed bug #66229 (128.0.0.0/16 isn't reserved any longer). (Adam)
29+
30+
- GD:
31+
. Fixed bug #64405 (Use freetype-config for determining freetype2 dir(s)).
32+
(Adam)
33+
34+
- PDO_odbc:
35+
. Fixed bug #66311 (Stack smashing protection kills PDO/ODBC queries).
36+
(michael at orlitzky dot com)
37+
38+
- MySQLi:
39+
. Fixed bug #65486 (mysqli_poll() is broken on win x64). (Anatol)
40+
41+
- OPCache:
42+
. Fixed reavlidate_path=1 behavior to avoid caching of symlinks values.
43+
(Dmitry)
44+
45+
- SNMP:
46+
. Fixed SNMP_ERR_TOOBIG handling for bulk walk operations. (Boris Lytochkin)
47+
48+
- SOAP
49+
. Fixed bug #66112 (Use after free condition in SOAP extension).
50+
(martin dot koegler at brz dot gv dot at)
51+
52+
- Sockets:
53+
. Fixed bug #65923 (ext/socket assumes AI_V4MAPPED is defined). (Felipe)
54+
55+
- XSL
56+
. Fixed bug #49634 (Segfault throwing an exception in a XSL registered
57+
function). (Mike)
58+
59+
- ZIP:
60+
. Fixed Bug #66321 (ZipArchive::open() ze_obj->filename_len not real). (Remi)
61+
62+
12 Dec 2013, PHP 5.5.7
63+
564
- DBA:
665
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)
766
- XSL:

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri
879879
return FAILURE;
880880
}
881881

882-
static inline int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle TSRMLS_DC)
882+
int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle TSRMLS_DC)
883883
{
884884
if (ZCG(accel_directives).revalidate_freq &&
885885
(persistent_script->dynamic_members.revalidate >= ZCSG(revalidate_at))) {

ext/opcache/ZendAccelerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ extern char *zps_api_failure_reason;
339339
void accel_shutdown(TSRMLS_D);
340340
void zend_accel_schedule_restart(zend_accel_restart_reason reason TSRMLS_DC);
341341
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason TSRMLS_DC);
342+
int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle TSRMLS_DC);
342343
int zend_accel_invalidate(const char *filename, zend_size_t filename_len, zend_bool force TSRMLS_DC);
343-
int zend_accel_script_optimize(zend_persistent_script *persistent_script TSRMLS_DC);
344344
int accelerator_shm_read_lock(TSRMLS_D);
345345
void accelerator_shm_read_unlock(TSRMLS_D);
346346

ext/opcache/tests/issue0140.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Issue #140: "opcache.enable_file_override" doesn't respect "opcache.revalidate_freq"
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.revalidate_freq=0
7+
opcache.file_update_protection=0
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
<?php if (php_sapi_name() != "cli") die("skip CLI only"); ?>
11+
--FILE--
12+
<?php
13+
define("FILENAME", dirname(__FILE__) . "/issuer0140.inc.php");
14+
file_put_contents(FILENAME, "1\n");
15+
16+
var_dump(is_readable(FILENAME));
17+
include(FILENAME);
18+
var_dump(filemtime(FILENAME));
19+
20+
sleep(2);
21+
file_put_contents(FILENAME, "2\n");
22+
23+
var_dump(is_readable(FILENAME));
24+
include(FILENAME);
25+
var_dump(filemtime(FILENAME));
26+
27+
sleep(2);
28+
unlink(FILENAME);
29+
30+
var_dump(is_readable(FILENAME));
31+
var_dump(@include(FILENAME));
32+
var_dump(@filemtime(FILENAME));
33+
?>
34+
--EXPECTF--
35+
bool(true)
36+
1
37+
int(%d)
38+
bool(true)
39+
2
40+
int(%d)
41+
bool(false)
42+
bool(false)
43+
bool(false)

ext/opcache/zend_accelerator_module.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,15 @@ static int filename_is_in_cache(char *filename, zend_size_t filename_len TSRMLS_
313313
if (IS_ABSOLUTE_PATH(filename, filename_len)) {
314314
persistent_script = zend_accel_hash_find(&ZCSG(hash), filename, filename_len + 1);
315315
if (persistent_script) {
316-
return !persistent_script->corrupted;
316+
return !persistent_script->corrupted &&
317+
validate_timestamp_and_record(persistent_script, &handle TSRMLS_CC) == SUCCESS;
317318
}
318319
}
319320

320321
if ((key = accel_make_persistent_key_ex(&handle, filename_len, &key_length TSRMLS_CC)) != NULL) {
321322
persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length + 1);
322-
return persistent_script && !persistent_script->corrupted;
323+
return persistent_script && !persistent_script->corrupted &&
324+
validate_timestamp_and_record(persistent_script, &handle TSRMLS_CC) == SUCCESS;
323325
}
324326

325327
return 0;

0 commit comments

Comments
 (0)