View Issue Details

IDProjectCategoryView StatusLast Update
0012336mantisbtreportspublic2014-12-08 02:08
Reportergthomas Assigned Todhx  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3.0dev 
Target Version1.3.0-beta.1 
Summary0012336: Syntax error in graphviz_api.php on line 435
Description

Seems to be an indentation-implied plus closing brace error.

Additional Information

Patch attached.

Tagspatch
Attached Files
graphviz_syntax_error.patch (2,050 bytes)   
From 6880e367d948b36d412dba8deef4a645da3247d3 Mon Sep 17 00:00:00 2001
From: Gulacsi Tamas <tgulacsi@websrv.unosoft.dmz>
Date: Fri, 10 Sep 2010 10:58:20 +0200
Subject: [PATCH] fix graphiz_api indentation and syntax error


diff --git a/core/graphviz_api.php b/core/graphviz_api.php
old mode 100644
new mode 100755
index 125cbff..b10aed1
--- a/core/graphviz_api.php
+++ b/core/graphviz_api.php
@@ -338,33 +338,32 @@ class Graph {
 			2 => array( 'file', 'php://stderr', 'w', ),
 			);
 
-			$t_pipes = array();
-			$t_proccess = proc_open( $t_command, $t_descriptors, $t_pipes );
-
-			if( is_resource( $t_proccess ) ) {
-				# Filter generated output through dot
-				fwrite( $t_pipes[0], $t_dot_source );
-				fclose( $t_pipes[0] );
-
-				if( $p_headers ) {
-					# Headers were requested, use another output buffer to
-					# retrieve the size for Content-Length.
-					ob_start();
-					while( !feof( $t_pipes[1] ) ) {
-						echo fgets( $t_pipes[1], 1024 );
-					}
-					header( 'Content-Length: ' . ob_get_length() );
-					ob_end_flush();
-				} else {
-					# No need for headers, send output directly.
-					while( !feof( $t_pipes[1] ) ) {
-						print( fgets( $t_pipes[1], 1024 ) );
-					}
+		$t_pipes = array();
+		$t_proccess = proc_open( $t_command, $t_descriptors, $t_pipes );
+
+		if( is_resource( $t_proccess ) ) {
+			# Filter generated output through dot
+			fwrite( $t_pipes[0], $t_dot_source );
+			fclose( $t_pipes[0] );
+
+			if( $p_headers ) {
+				# Headers were requested, use another output buffer to
+				# retrieve the size for Content-Length.
+				ob_start();
+				while( !feof( $t_pipes[1] ) ) {
+					echo fgets( $t_pipes[1], 1024 );
+				}
+				header( 'Content-Length: ' . ob_get_length() );
+				ob_end_flush();
+			} else {
+				# No need for headers, send output directly.
+				while( !feof( $t_pipes[1] ) ) {
+					print( fgets( $t_pipes[1], 1024 ) );
 				}
-
-				fclose( $t_pipes[1] );
-				proc_close( $t_proccess );
 			}
+
+			fclose( $t_pipes[1] );
+			proc_close( $t_proccess );
 		}
 	}
 
-- 
1.5.4.3

graphviz_syntax_error.patch (2,050 bytes)   

Relationships

related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 

Activities

Renegade

Renegade

2010-09-28 21:28

reporter   ~0026899

The product version for this issue is set to "git trunk". I am personally running 1.2.3 from the site. Should the file have significantly changed between the 1.2.x branch and the current trunk, ignore me.

Otherwise:

I applied this patch because I couldn't get graphviz to run with Mantis, despite the fact that it works fine when called manually.

I am now getting an error
PHP Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in [path]/core/graphviz_api.php on line 498
when trying to call a graph.
line 498 contains a single curly brace in my patched version.

Normal diff shows a bunch of tab changes, diff -w shows exactly one change:
425a426

  }

since that matches the description in the issue, I'm rather sure the patch applied smoothly.

Long story short: As far as I can tell, the original version was alright (didn't throw an error), and the patched version causes an error.

As said, if this doesn't apply because trunk and 1.2.x differ in that file, ignore me. Just thought I'd make note of it, especially since others might get the same idea.

gthomas

gthomas

2010-09-29 01:34

reporter   ~0026900

1.2.x is totally different from git-trunk:
It has special case handling for windows servers (WinGraph), and had a syntax error (missing }) which is corrected by this patch.

index 44d43e8..b10aed1
--- a/core/graphviz_api.php
+++ b/core/graphviz_api.php
@@ -1,5 +1,5 @@
<?php
-# MantisBT - a php based bugtracking system
+# MantisBT - A PHP based bugtracking system

MantisBT is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

@@ -15,25 +15,31 @@

along with MantisBT. If not, see http://www.gnu.org/licenses/.

/**

+require_api( 'constant_inc.php' );
+require_api( 'utility_api.php' );
+
/**

  • constant(s) defining the output formats supported by dot and neato.
    */
    @@ -317,82 +323,19 @@ class Graph {
    if( $p_headers ) {
    header( 'Content-Type: ' . $t_mime );
    }

            # Retrieve the source dot document into a buffer
            ob_start();
            $this->generate();
            $t_dot_source = ob_get_contents();
            ob_end_clean();
  • There are three different ways to generate the output dependin

  • on the operating system and PHP version.

  • if( is_windows_server() ) {
  • If we are under Windows, we use the COM interface prov

  • by WinGraphviz. Thanks Paul!

  • Issue 0004625: Work around WinGraphviz bug that fails wi

  • graphs with zero or one node. It is probably too much

  • generate a graphic output just to explain it to the us

  • so we just return a null content.

  • if( count( $this->nodes ) <= 1 ) {
  • return;
  • }
  • $t_graphviz = new COM( $this->graphviz_com_module );
  • Check if we managed to instantiate the COM object.

  • if( is_null( $t_graphviz ) ) {
  • We can't display any message or trigger an err

  • failure, since we may have already sent a Cont

  • header potentially incompatible with the any h

  • return;
  • }
  • if( $t_binary ) {
  • Image formats

  • $t_dot_output = $t_graphviz->ToBinaryGraph( $t_d
  • if( $p_headers ) {
  • Headers were requested, use another ou

  • to retrieve the size for Content-Lengt

  • ob_start();
  • echo base64_decode( $t_dot_output->ToBas
  • header( 'Content-Length: ' . ob_get_leng
  • ob_end_flush();
  • } else {
  • No need for headers, send output direc

  • echo base64_decode( $ret->ToBase64String
  • }
  • } else {
  • Text formats

  • $t_dot_output = $t_graphviz->ToTextGraph( $t_dot
  • if( $p_headers ) {
  • header( 'Content-Length: ' . utf8_strlen
  • }
  • echo $t_dot_output;
  • }
  • unset( $t_graphviz );
  • } else {
  • If we are not under Windows, use proc_open,

  • since it avoids the need of temporary files.

                    # Start dot process
  •                 $t_command = $this->graphviz_tool . ' -T' . $p_format;
                    $t_descriptors = array(
  • 0 => array(
  • 'pipe',
  • 'r',
  • ),
  • 1 => array(
  • 'pipe',
  • 'w',
  • ),
  • 2 => array(
  • 'file',
  • 'php://stderr',
  • 'w',
  • ),
  • 0 => array( 'pipe', 'r', ),
  • 1 => array( 'pipe', 'w', ),
  • 2 => array( 'file', 'php://stderr', 'w', ),
    );

                    $t_pipes = array();

    @@ -423,7 +366,6 @@ class Graph {
    proc_close( $t_proccess );
    }
    }

  • }

    /** 
     * PROTECTED function to build a node or edge attribute list.
Renegade

Renegade

2010-09-29 02:56

reporter   ~0026901

Well as said...at least others running 1.2.x won't get the same idea now.

A clearer version marking than "trunk" would help avoid such confusion, btw.
The trunk version this was submitted for 19 days ago could be totally different than the current trunk version as well, despite both being the "trunk" version.

dhx

dhx

2010-10-22 07:50

reporter   ~0027127

Thanks for the patch Gulacsi, I have finally committed it. Apologies for the delayed commit.

This problem only affected version 1.3.x of MantisBT (not 1.2.x).

grangeway

grangeway

2013-04-05 17:57

reporter   ~0036477

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

Related Changesets

MantisBT: master 0ed24722

2010-09-10 04:58

Gulacsi Tamas

Committer: David Hicks


Details Diff
fix graphiz_api indentation and syntax error

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0012336