Skip to content

Commit 878bef2

Browse files
committed
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
2 parents 1c662dc + f17156c commit 878bef2

10 files changed

+98
-6
lines changed

ext/gd/libgd/gd_interpolation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static inline int getPixelOverflowTC(gdImagePtr im, const int x, const int y, co
642642
register int border;
643643

644644
if (y < im->cy1) {
645-
3 border = im->tpixels[0][im->cx1];
645+
border = im->tpixels[0][im->cx1];
646646
goto processborder;
647647
}
648648

@@ -2546,4 +2546,4 @@ int gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMethod id)
25462546

25472547
#ifdef _MSC_VER
25482548
# pragma optimize("", on)
2549-
#endif
2549+
#endif

ext/opcache/Optimizer/block_pass.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,11 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
972972
zval result;
973973

974974
if (unary_op) {
975+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
976+
unary_op(&result, &ZEND_OP1_LITERAL(opline));
977+
#else
975978
unary_op(&result, &ZEND_OP1_LITERAL(opline) TSRMLS_CC);
979+
#endif
976980
literal_dtor(&ZEND_OP1_LITERAL(opline));
977981
} else {
978982
/* BOOL */

ext/opcache/Optimizer/pass1_5.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
203203

204204
er = EG(error_reporting);
205205
EG(error_reporting) = 0;
206+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
207+
if (unary_op(&result, &ZEND_OP1_LITERAL(opline)) != SUCCESS) {
208+
#else
206209
if (unary_op(&result, &ZEND_OP1_LITERAL(opline) TSRMLS_CC) != SUCCESS) {
210+
#endif
207211
EG(error_reporting) = er;
208212
break;
209213
}

ext/opcache/ZendAccelerator.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ static inline int is_stream_path(const char *filename)
134134
return ((*p == ':') && (p - filename > 1) && (p[1] == '/') && (p[2] == '/'));
135135
}
136136

137+
static inline int is_cachable_stream_path(const char *filename)
138+
{
139+
return memcmp(filename, "file://", sizeof("file://") - 1) == 0 ||
140+
memcmp(filename, "phar://", sizeof("phar://") - 1) == 0;
141+
}
142+
137143
/* O+ overrides PHP chdir() function and remembers the current working directory
138144
* in ZCG(cwd) and ZCG(cwd_len). Later accel_getcwd() can use stored value and
139145
* avoid getcwd() call.
@@ -1204,10 +1210,18 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han
12041210
} else {
12051211
*op_array_p = NULL;
12061212
if (type == ZEND_REQUIRE) {
1213+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
1214+
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
1215+
#else
12071216
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC);
1217+
#endif
12081218
zend_bailout();
12091219
} else {
1220+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
1221+
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
1222+
#else
12101223
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC);
1224+
#endif
12111225
}
12121226
return NULL;
12131227
}
@@ -1365,7 +1379,9 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
13651379
!ZCG(enabled) || !accel_startup_ok ||
13661380
(!ZCG(counted) && !ZCSG(accelerator_enabled)) ||
13671381
CG(interactive) ||
1368-
(ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C))) {
1382+
(ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C)) ||
1383+
(is_stream_path(file_handle->filename) &&
1384+
!is_cachable_stream_path(file_handle->filename))) {
13691385
/* The Accelerator is disabled, act as if without the Accelerator */
13701386
return accelerator_orig_compile_file(file_handle, type TSRMLS_CC);
13711387
}
@@ -1422,10 +1438,18 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
14221438
zend_stream_open(file_handle->filename, file_handle TSRMLS_CC) == FAILURE) {
14231439
#endif
14241440
if (type == ZEND_REQUIRE) {
1441+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
1442+
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
1443+
#else
14251444
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC);
1445+
#endif
14261446
zend_bailout();
14271447
} else {
1448+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
1449+
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
1450+
#else
14281451
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC);
1452+
#endif
14291453
}
14301454
return NULL;
14311455
}
@@ -1542,7 +1566,11 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
15421566
zend_hash_quick_add(&EG(included_files), persistent_script->full_path, persistent_script->full_path_len + 1, persistent_script->hash_value, &dummy, sizeof(void *), NULL);
15431567
}
15441568
}
1569+
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
1570+
zend_file_handle_dtor(file_handle);
1571+
#else
15451572
zend_file_handle_dtor(file_handle TSRMLS_CC);
1573+
#endif
15461574
from_shared_memory = 1;
15471575
}
15481576

@@ -2342,7 +2370,8 @@ static void zend_accel_init_shm(TSRMLS_D)
23422370
ZCSG(manual_restarts) = 0;
23432371

23442372
ZCSG(accelerator_enabled) = 1;
2345-
ZCSG(last_restart_time) = zend_accel_get_time();
2373+
ZCSG(start_time) = zend_accel_get_time();
2374+
ZCSG(last_restart_time) = 0;
23462375
ZCSG(restart_in_progress) = 0;
23472376

23482377
zend_shared_alloc_unlock(TSRMLS_C);

ext/opcache/ZendAccelerator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#endif
2828

2929
#define ACCELERATOR_PRODUCT_NAME "Zend OPcache"
30-
#define ACCELERATOR_VERSION "7.0.1-dev"
30+
#define ACCELERATOR_VERSION "7.0.1"
3131
/* 2 - added Profiler support, on 20010712 */
3232
/* 3 - added support for Optimizer's encoded-only-files mode */
3333
/* 4 - works with the new Optimizer, that supports the file format with licenses */
@@ -88,6 +88,7 @@
8888
#define PHP_5_2_X_API_NO 220060519
8989
#define PHP_5_3_X_API_NO 220090626
9090
#define PHP_5_4_X_API_NO 220100525
91+
#define PHP_5_5_X_API_NO 220121212
9192

9293
/*** file locking ***/
9394
#ifndef ZEND_WIN32
@@ -274,6 +275,7 @@ typedef struct _zend_accel_shared_globals {
274275
zend_accel_hash include_paths; /* used "include_path" values */
275276

276277
/* Directives & Maintenance */
278+
time_t start_time;
277279
time_t last_restart_time;
278280
time_t force_restart_time;
279281
zend_bool accelerator_enabled;

ext/opcache/config.m4

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,39 @@ int main() {
325325
AC_DEFINE(HAVE_SHM_MMAP_FILE, 1, [Define if you have mmap() SHM support])
326326
msg=yes,msg=no,msg=no)
327327
AC_MSG_RESULT([$msg])
328+
329+
AC_MSG_CHECKING(for known struct flock definition)
330+
dnl Copied from ZendAccelerator.h
331+
AC_TRY_RUN([
332+
#include <fcntl.h>
333+
#include <stdlib.h>
334+
335+
#ifndef ZEND_WIN32
336+
extern int lock_file;
337+
338+
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (defined(__APPLE__) && defined(__MACH__)/* Darwin */) || defined(__OpenBSD__) || defined(__NetBSD__)
339+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
340+
struct flock name = {start, len, -1, type, whence}
341+
# elif defined(__svr4__)
342+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
343+
struct flock name = {type, whence, start, len}
344+
# elif defined(__linux__) || defined(__hpux)
345+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
346+
struct flock name = {type, whence, start, len, 0}
347+
# elif defined(_AIX)
348+
# if defined(_LARGE_FILES) || defined(__64BIT__)
349+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
350+
struct flock name = {type, whence, 0, 0, 0, start, len }
351+
# else
352+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
353+
struct flock name = {type, whence, start, len}
354+
# endif
355+
# else
356+
# error "Don't know how to define struct flock"
357+
# endif
358+
#endif
359+
int main() { return 0; }
360+
], [], [AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])], [])
328361

329362
PHP_NEW_EXTENSION(opcache,
330363
ZendAccelerator.c \

ext/opcache/tests/bug64482.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
echo "Dynamic include";

ext/opcache/tests/bug64482.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #64482 (Opcodes for dynamic includes should not be cached)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
include 'bug64482.inc';
11+
echo "\n";
12+
include 'php://filter/read=string.toupper/resource=bug64482.inc';
13+
echo "\n";
14+
?>
15+
--EXPECT--
16+
Dynamic include
17+
DYNAMIC INCLUDE

ext/opcache/zend_accelerator_module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ static ZEND_FUNCTION(opcache_get_status)
503503
add_assoc_long(statistics, "num_cached_keys", ZCSG(hash).num_entries);
504504
add_assoc_long(statistics, "max_cached_keys", ZCSG(hash).max_num_entries);
505505
add_assoc_long(statistics, "hits", ZCSG(hits));
506+
add_assoc_long(statistics, "start_time", ZCSG(start_time));
506507
add_assoc_long(statistics, "last_restart_time", ZCSG(last_restart_time));
507508
add_assoc_long(statistics, "oom_restarts", ZCSG(oom_restarts));
508509
add_assoc_long(statistics, "wasted_restarts", ZCSG(wasted_restarts));

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ static void zend_do_delayed_early_binding(zend_op_array *op_array, zend_uint ear
857857
}
858858
opline_num = op_array->opcodes[opline_num].result.u.opline_num;
859859
}
860-
zend_restore_compiled_filename(orig_compiled_filename);
860+
zend_restore_compiled_filename(orig_compiled_filename TSRMLS_CC);
861861
CG(in_compilation) = orig_in_compilation;
862862
}
863863
}

0 commit comments

Comments
 (0)