PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_Graph » Bug #2545

Changes in error reporting

Details

Submitted2004-10-16 11:36 UTC
Fromotiteca at free dot fr
Assignedsergiosgc
StatusClosed
PackageStructures_Graph
PHP Version4.3.4
Roadmaps(Not assigned)

Comments

[2004-10-16 11:36 UTC] otiteca at free dot fr

Description:
------------
In Structures_Graph_Node::connectTo(),
the use of PEAR::RaiseError() do not prevent for the method to execute => a node not in graph, can be connected to another one.
then I do propose to use: return new Pear_Error(), for the method to stop execute on error, by this way, the main script can manage error.

here's my connectTo method modified:

function connectTo(&$destinationNode) {
// We only connect to nodes
if (!is_a($destinationNode, 'Structures_Graph_Node')) {
return new Pear_Error('Structures_Graph_Node::connectTo received an object that is not a Structures_Graph_Node', STRUCTURES_GRAPH_ERROR_GENERIC);}
// Nodes must already be in graphs to be connected
if ($this->_graph == null)
return new PEAR_Error('Structures_Graph_Node::connectTo Tried to connect a node that is not in a graph', STRUCTURES_GRAPH_ERROR_GENERIC);
if ($destinationNode->getGraph() == null)
return new Pear_Error('Structures_Graph_Node::connectTo Tried to connect to a node that is not in a graph', STRUCTURES_GRAPH_ERROR_GENERIC);
// Connect here
$this->_connectTo($destinationNode);
// If graph is undirected, connect back
if (!$this->_graph->isDirected()) {
$destinationNode->_connectTo($this);
}
}

Reproduce code:
---------------
$toto =& new NetGraph();
$mynode = new Structures_Graph_Node();
$mynode2 =& new Structures_Graph_Node();
$mynode->setData("ptptptpttptptptptp");
$mynode2->setData("xxxxxxxxxxxxxxxxxxxxxx");

$toto->addNode($mynode);

$mynode->connectTo($mynode2); //$mynode2 not in graph

print_r($toto); //you'll see that $mynode and $mynode2 are connected while $mynode2 is not in graph

Expected result:
----------------
netgraph Object ( [_nodes] => Array ( [0] => structures_graph_node Object ( [_data] => ptptptpttptptptptp [_metadata] => Array ( ) [_arcs] => Array ( ) [_graph] => netgraph Object ( [_nodes] => Array *RECURSION* [_directed] => 1 ) ) ) [_directed] => 1 )

Actual result:
--------------
netgraph Object ( [_nodes] => Array ( [0] => structures_graph_node Object ( [_data] => ptptptpttptptptptp [_metadata] => Array ( ) [_arcs] => Array ( [0] => structures_graph_node Object ( [_data] => xxxxxxxxxxxxxxxxxxxxxx [_metadata] => Array ( ) [_arcs] => Array ( ) [_graph] => ) ) [_graph] => netgraph Object ( [_nodes] => Array *RECURSION* [_directed] => 1 ) ) ) [_directed] => 1 )

[2004-10-20 13:55 UTC] sergio dot carvalho at portugalmail dot com

Assigned bug to me. Removed OS indication as it is irrelevant to the bug type.

[2005-12-09 12:00 UTC] sergiosgc at php dot net

This bug has been fixed in CVS.

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.

Fixed all PEAR::raiseError calls to return whenever they were raising errors.