mirror of
https://github.com/php-win-ext/pecl-processing-rrd.git
synced 2026-03-24 00:52:13 +01:00
rrd_lastupdate - bug with multiple data source #61316
git-svn-id: http://svn.php.net/repository/pecl/rrd/trunk@325960 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
15
rrd.c
15
rrd.c
@@ -218,7 +218,7 @@ PHP_FUNCTION(rrd_lastupdate)
|
||||
{
|
||||
char *filename;
|
||||
int filename_length;
|
||||
/* list of arguments for rrd_lastupdate call, it's more efficient then u
|
||||
/* list of arguments for rrd_lastupdate call, it's more efficient then
|
||||
* usage of rrd_args, because there isn't array of arguments in parameters
|
||||
*/
|
||||
char *argv[3];
|
||||
@@ -285,17 +285,12 @@ PHP_FUNCTION(rrd_lastupdate)
|
||||
MAKE_STD_ZVAL(zv_data_array);
|
||||
array_init(zv_data_array);
|
||||
|
||||
/* simple array for "data" is enough, data source names and timestamps are
|
||||
* available under other return value keys
|
||||
*/
|
||||
for (i = 0; i < ds_cnt; i++) {
|
||||
/* last_update is key in data array */
|
||||
zval *zv_timestamp;
|
||||
MAKE_STD_ZVAL(zv_timestamp);
|
||||
ZVAL_LONG(zv_timestamp, last_update);
|
||||
convert_to_string(zv_timestamp);
|
||||
|
||||
add_assoc_string(zv_data_array, Z_STRVAL_P(zv_timestamp), last_ds[i], 1);
|
||||
|
||||
add_next_index_string(zv_data_array, last_ds[i], 1);
|
||||
free(last_ds[i]);
|
||||
zval_dtor(zv_timestamp);
|
||||
}
|
||||
free(last_ds);
|
||||
add_assoc_zval(return_value, "data", zv_data_array);
|
||||
|
||||
@@ -4,14 +4,17 @@ rrd_lastupdate test
|
||||
<?php
|
||||
include('skipif.inc');
|
||||
include('data/definition.inc');
|
||||
if (!file_exists($data_updatedDb)) {
|
||||
die("skip $data_updatedDb doesn't exist");
|
||||
foreach(array($data_updatedDb, $data_moreDSDb) as $file) {
|
||||
if (!file_exists($file)) {
|
||||
die("skip $file doesnt' exist");
|
||||
}
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include('data/definition.inc');
|
||||
var_dump(rrd_lastupdate($data_updatedDb));
|
||||
var_dump(rrd_lastupdate($data_moreDSDb));
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(4) {
|
||||
@@ -26,7 +29,27 @@ array(4) {
|
||||
}
|
||||
["data"]=>
|
||||
array(1) {
|
||||
[920808900]=>
|
||||
[0]=>
|
||||
string(5) "12423"
|
||||
}
|
||||
}
|
||||
array(4) {
|
||||
["last_update"]=>
|
||||
int(920808900)
|
||||
["ds_cnt"]=>
|
||||
int(2)
|
||||
["ds_navm"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(6) "speed1"
|
||||
[1]=>
|
||||
string(6) "speed2"
|
||||
}
|
||||
["data"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(5) "12423"
|
||||
[1]=>
|
||||
string(5) "11423"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user