Skip to content

Commit ccf7d7c

Browse files
committed
Add optional flag to opcache_get_status()
1 parent fe384b3 commit ccf7d7c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -430,21 +430,20 @@ static zval* accelerator_get_scripts(TSRMLS_D)
430430
return return_value;
431431
}
432432

433-
/* {{{ proto array accelerator_get_status()
434-
Obtain statistics information regarding code acceleration in the Zend Performance Suite */
433+
/* {{{ proto array accelerator_get_status([bool fetch_scripts])
434+
Obtain statistics information regarding code acceleration */
435435
static ZEND_FUNCTION(opcache_get_status)
436436
{
437437
long reqs;
438438
zval *memory_usage,*statistics,*scripts;
439+
zend_bool fetch_scripts = 1;
439440

440441
/* keep the compiler happy */
441442
(void)ht; (void)return_value_ptr; (void)this_ptr; (void)return_value_used;
442443

443-
#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
444-
if (zend_parse_parameters_none() == FAILURE) {
445-
RETURN_FALSE;
444+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &fetch_scripts) == FAILURE) {
445+
return;
446446
}
447-
#endif
448447

449448
if (!accel_startup_ok) {
450449
RETURN_FALSE;
@@ -480,10 +479,12 @@ static ZEND_FUNCTION(opcache_get_status)
480479
add_assoc_double(statistics, "opcache_hit_rate", reqs?(((double) ZCSG(hits))/reqs)*100.0:0);
481480
add_assoc_zval(return_value, "opcache_statistics", statistics);
482481

483-
/* accelerated scripts */
484-
scripts = accelerator_get_scripts(TSRMLS_C);
485-
if (scripts) {
486-
add_assoc_zval(return_value, "scripts", scripts);
482+
if (fetch_scripts) {
483+
/* accelerated scripts */
484+
scripts = accelerator_get_scripts(TSRMLS_C);
485+
if (scripts) {
486+
add_assoc_zval(return_value, "scripts", scripts);
487+
}
487488
}
488489
}
489490

@@ -494,7 +495,7 @@ static int add_blacklist_path(zend_blacklist_entry *p, zval *return_value TSRMLS
494495
}
495496

496497
/* {{{ proto array accelerator_get_configuration()
497-
Obtain configuration information for the Zend Performance Suite */
498+
Obtain configuration information */
498499
static ZEND_FUNCTION(opcache_get_configuration)
499500
{
500501
zval *directives,*version,*blacklist;

0 commit comments

Comments
 (0)