Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.0

Bug #15019 addCluster using attributes twice
Submitted: 2008-11-13 20:27 UTC
From: slaakso Assigned: jausions
Status: Closed Package: Image_GraphViz (version 1.3.0RC3)
PHP Version: 5.2.6 OS: MacOS X
Roadmaps: (Not assigned)    
Subscription  


 [2008-11-13 20:27 UTC] slaakso (Seppo Laaksonen)
Description: ------------ When one adds clusters into the chart, addCluster adds cluster attribute definitions to the final result twice, once with attribute names and once without them (and the attributes are separated with commas instead of semicolons see bug 13053). This seems to be due to the incorrect re-use of $attr-array in parse() method. Possible fix (from line 751): $attrC = $this->_escapeArray($cluster['attributes']); $attr = array(); foreach ($attrC as $key => $value) { Test script: --------------- <?php require_once 'Image/GraphViz.php'; $graph = new Image_GraphViz(true, '', 'Bug', true); $graph->addCluster('cluster_0', 'Cluster', array( 'fontcolor' =>'black', 'style' => 'filled' ) ); $graph->addNode( 'Node', '', cluster_0 ); echo $graph->parse(); ?> Expected result: ---------------- strict digraph Bug { subgraph cluster_0 { graph [ fontcolor=black;style=filled;label=Cluster ]; "Node" [ 0="" ]; } } Actual result: -------------- strict digraph Bug { subgraph cluster_0 { graph [ black,filled,fontcolor=black,style=filled,label=Cluster ]; "Node" [ 0="" ]; } }

Comments

 [2008-11-14 08:45 UTC] slaakso (Seppo Laaksonen)
Please ignore the incorrect reference to bug #13053. Attributes are correctly separated with commas. The extra orphan attributes still exists though.
 [2008-11-17 00:48 UTC] doconnor (Daniel O'Connor)
I get: Notice: Use of undefined constant cluster_0 - assumed 'cluster_0' in /home/clockwerx/pear/bug-15019.php on line 6 Call Stack: 0.0005 62200 1. {main}() /home/clockwerx/pear/bug-15019.php:0 Warning: Invalid argument supplied for foreach() in /usr/share/php/Image/GraphViz.php on line 486 Call Stack: 0.0005 62200 1. {main}() /home/clockwerx/pear/bug-15019.php:0 0.0409 586452 2. Image_GraphViz->parse() /home/clockwerx/pear/bug-15019.php:11 Warning: assert(): Assertion failed in /home/clockwerx/pear/bug-15019.php on line 11 Call Stack: 0.0005 62200 1. {main}() /home/clockwerx/pear/bug-15019.php:0 0.0413 587932 2. assert() /home/clockwerx/pear/bug-15019.php:11
 [2008-11-17 11:54 UTC] slaakso (Seppo Laaksonen)
For some reason my environment was not catching the unfortunate bug in test script. The cluster_0 parameter in addNode was supposed to be enclosed in apostrophes. Test script: --------------- <?php require_once 'Image/GraphViz.php'; $graph = new Image_GraphViz(true, '', 'Bug', true); $graph->addCluster('cluster_0', 'Cluster', array( 'fontcolor'=>'black', 'style' => 'filled' ) ); $graph->addNode( 'Node', '', 'cluster_0' ); echo $graph->parse(); ?> Expected result: ---------------- strict digraph Bug { subgraph cluster_0 { graph [ fontcolor=black,style=filled,label=Cluster ]; "Node" [ 0="" ]; } } Actual result: --------------- strict digraph Bug { subgraph cluster_0 { graph [ black,filled,fontcolor=black,style=filled,label=Cluster ]; "Node" [ 0="" ]; } }
 [2009-03-14 00:20 UTC] hexmode (Mark A. Hershberger)
I'd like to package this module for Debian and here's what I came up with: --- Image_GraphViz-1.3.0RC3/GraphViz.php~ +++ Image_GraphViz-1.3.0RC3/GraphViz.php @@ -748,9 +748,9 @@ if (isset($this->graph['clusters'][$group])) { $cluster = $this->graph['clusters'][$group]; - $attr = $this->_escapeArray($cluster['attributes']); - foreach ($attr as $key => $value) { + foreach ($this->_escapeArray($cluster['attributes']) + as $key => $value) { $attr[] = $key.'='.$value; }
 [2009-12-08 21:31 UTC] jausions (Philippe Jausions)
-Status: Assigned +Status: Verified
 [2009-12-14 03:21 UTC] jausions (Philippe Jausions)
-Status: Verified +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.