Bug #19286 [Opn]: Loop error on empty clusters

From: Date: Thu, 10 May 2012 00:38:26 +0000
Subject: Bug #19286 [Opn]: Loop error on empty clusters
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-8635@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19286&edit=1 ID: 19286 Updated by: daniel.oconnor@gmail.com Reported By: fgmarand at gmail dot com Summary: Loop error on empty clusters Status: Open Type: Bug Package: Image_GraphViz Operating System: Ubuntu 11.04 Package Version: 1.3.0 PHP Version: 5.3.5 Roadmap Versions: New Comment: Marking package as unmaintained, there's been a patch attached for over 3 months with no activity. Previous Comments: ------------------------------------------------------------------------ [2012-05-08 15:49:23] fgm Added #patch bug:19286;patch:loop_cluster_without_nodes-19286;revision:1336488562;. ------------------------------------------------------------------------ [2012-05-08 15:38:48] fgm Same error on subgraphs instead of clusters. <?php include 'Image/GraphViz.php'; $g = new Image_Graphviz(); $g->addSubgraph('s1_id', 's1_title'); echo $g->parse(); Notice: Undefined index: s1_id in (path)/Image_GraphViz/Image/GraphViz.php on line 937 ------------------------------------------------------------------------ [2012-02-10 16:32:56] fgm Added #patch bug:19286;patch:loop_cluster_without_nodes-19286;revision:1328891576;. ------------------------------------------------------------------------ [2012-02-10 16:15:46] fgm Description: ------------ When rendering a graph containing a cluster without any nodes within, Image_Graphviz::_nodes() throws "Invalid argument" errors. This happens because _nodes() loops on $nodes without making sure that it is usabe as an array. Current code: foreach ($nodes as $node => $attributes) { Suggested fix: foreach ((array) $nodes as $node => $attributes) { Test script: --------------- <?php include 'Image/GraphViz.php'; $g = new Image_Graphviz(); $g->addcluster('c1', 'c1'); $g->image(); Expected result: ---------------- No error, just svg output. Actual result: -------------- PHP Notice: Undefined index: c1 in /usr/share/php/Image/GraphViz.php on line 936 ... PHP Warning: Invalid argument supplied for foreach() in /usr/share/php/Image/GraphViz.php on line 909 ...(svg output)... The error on line 936 does not appear in other situations, but appears in this contrived example. ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19286&edit=1

« previous php.pear.bugs (#8635) next »