Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002496graphvizOutput Generationpublic2014-10-15 05:172014-10-15 11:14
ReporterMikael92 
Assigned Toellson 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformMediawiki : 1.23.1 PHP : 5.5.11OSWindowsOS Version7
Summary0002496: Problème Extension :Graphviz v1.3.1 avec la commande wfshell_exec()
DescriptionBonjour,
J’essaye d’installer et de faire fonctionner l’Extension :GraphViz sur un mediawiki pour générer des graphes. Puis par la suite installer les extensions xycategoriesBrowser ou FormGraph pour les générer automatiquement.

Mediawiki : 1.23.1 PHP : 5.5.11 sur Windows7
Extension :Graphviz v1.3.1 qui date du 2014-07-10 (très récent) http://www.mediawiki.org/wiki/Extension:GraphViz [^]
Le programme Graphviz 2.38 installé depuis http://www.graphviz.org/Download..php [^] en .msi


 Voila mon problème les graphes ne veulent pas se générer avec les balises par exemple :
<graphviz border='frame' format='png' caption='Graph for example no. 1'>
digraph example1 {Hello->World}
</graphviz>

Le problème s’emblerait venir de la commande de wfshell_exec :

protected static function executeCommand( $command, &$output ) {
        if ( !wfIsWindows() ) {
// redirect stderr to stdout so that it will be included in outputArray
            $command .= " 2>&1";
                }
    $output = wfShellExec( $command, $ret );
            if ( $ret != 0 ) {
return false; }
        return true;
}

La source et le fichier .png sont bien créé quand je met des exit donc la $command est bonne. Le $ret me met toujours un false car égal à 1 et la sortie $output est nulle. Je suppose que c’est la fonction de shell_exec qui bug.

Evidement j’ai bien les droits utilisateurs dans les dossiers, la variable d’environnement path modifiée, les chemins dot et exec path, l’Extension ImageMaps qui fonctionne.

Cette function executeCommand intervient ici :
    protected static function render( $input, $args, $parser )
    { ----------sous silence---------------
        // check if the graph source changed only if:
        // - the wiki text is being saved or
        // - an edit of the wiki text is being previewed or
        // - the graph image or map file does not exist
        $sourceChanged = false;
        if ( $saving || $isPreview || !$imageExists || !$mapExists ) {
            if ( !self::isSourceChanged( $graphParms->getSourcePath( $isPreview ), $input, $sourceChanged, $errorText ) ) {
                return self::errorHTML( $errorText );
            }
        }
        wfDebug( __METHOD__ . ": sourceChanged: $sourceChanged\n" );

//var_dump ($graphParms->getImageCommand( $isPreview ));
        echo "AVANT TESTS DES CHANGEMENTS\n";
// generate image and map files only if the graph source changed or the image or map files do not exist
        if ( $sourceChanged || !$imageExists || !$mapExists ) {
        // first, check if the user is allowed to upload the image
            if ( !UploadLocalFile::isUploadAllowedForUser( $user, $errorText ) ) {
                return self::errorHTML( $errorText );
            }
            echo "JE PEUX FAIRE UN UPLOAD\n";

            // if the source changed, update it on disk
            if ( $sourceChanged ) {
                echo "LA SOURCE A BIEN CHANGEE\n";
                if ( !self::updateSource( $graphParms->getSourcePath( $isPreview ), $input, $errorText ) ) {
                    self::deleteFiles( $graphParms, $isPreview, false );
                    return self::errorHTML( $errorText );
                }
            }
            echo "LA SOURCE EST GENEREE\n";
            //var_dump($isPreview);

            // execute the image creation command
            if ( !self::executeCommand( $graphParms->getImageCommand( $isPreview ), $errorText ) )
            {
            self::deleteFiles( $graphParms, $isPreview, false );

            // remove path info from the errorText
        $errorText = str_replace( $imageDir, "", $errorText );
        $errorText = str_replace( $sourceAndMapDir, "", $errorText );
        return self::multilineErrorHTML( $errorText );
        }
        echo "L IMAGE EST GENEREE\n"; (ne le fait jamais ici)
        exit;

// check if the upload is allowed for the intended title (the image file must exist prior to this check)
            if ( !UploadLocalFile::isUploadAllowedForTitle(
                $user,
                $graphParms->getImageFileName( $isPreview ),
                $graphParms->getImagePath( $isPreview ),
                false,
                $parser->getFunctionLang(),
                $errorText ) )
            {
                self::deleteFiles( $graphParms, $isPreview, false );
                return self::errorHTML( $errorText );
            }

            // execute the map creation command
            if ( !self::executeCommand( $graphParms->getMapCommand( $isPreview ), $errorText ) )
            {
                self::deleteFiles( $graphParms, $isPreview, false );

// remove path info from the errorText (file base names are allowed to pass)
        $errorText = str_replace( $imageDir, "", $errorText );
        $errorText = str_replace( $sourceAndMapDir, "", $errorText );
        return self::multilineErrorHTML( $errorText );
            }


Donc quelqu'un aurait une idée pour faire fonctionner correctement la fonction de shell_exec ?
Merci beaucoup de votre attention et de l'intérêt que vous pourrez porter à mon problème.

Mikael.
Additional InformationJ’ai essayé toutes les versions antérieurs sans succès. J’ai cependant trouvé quelques informations (des versions antérieur d’ailleurs) .

$cmdline = wfEscapeShellArg($cmd).' -T '.$outputType.' -o '.wfEscapeShellArg($imgn).' '.$inputOption.wfEscapeShellArg($src);
  $cmdlinemap = wfEscapeShellArg($cmd).$mapDashTOption.'-o '.wfEscapeShellArg($mapn).' '.$inputOption.wfEscapeShellArg($src);
if ( $isWindows ) {
                 $WshShell = new COM("WScript.Shell");
                 $ret = $WshShell->Exec($cmdline);
                 $retmap = $WshShell->Exec($cmdlinemap);
             } else {
                 $ret = shell_exec($cmdline);
                 $retmap = shell_exec($cmdlinemap);
TagsNo tags attached.
AUXILLARY-FILES
DATE-FIXED
FIX-COMMENTUser resolved the issue.
FORMER-ID
INPUT-FILE
OUTPUT-FILE
STATUS-COMMENT
VERSION
Attached Files

- Relationships

-  Notes
User avatar (0000836)
Mikael92 (reporter)
2014-10-15 05:23

Sinon j'ai vu aussi l'anti-aliasing avec ImageMagick où on passe
dotCommand > OutputPSscript > Passed to Magick > .png mais plus dure à mettre en place.
User avatar (0000837)
ellson (administrator)
2014-10-15 10:39

" I try to install and operate the Extension: GraphViz on a mediawiki to generate graphs. Then thereafter install xycategoriesBrowser FormGraph or extensions for automatically generate.

The installed program from Graphviz 2.38 http://www.graphviz.org/Download..php [^] [^] in msi

Here is my problem the graphs do not want to generate with tags such as:
<graphviz border='frame' format='png' caption='Graph for example no. 1'>
digraph example1 {Hello->World}
</graphviz>

The problem of coming emblerait control wfshell_exec:

protected static function ExecuteCommand ($ command, & $ output) {
         if (! wfIsWindows ()) {
// Redirect stderr to stdout so That It Will Be included in outputArray
             $ command = "2> & 1".;
                 }
     $ output = wfShellExec ($ command, $ ret);
             if ($ ret! = 0) {
return false; }
         return true;
}

The source and png file are created when I put the exit so the $ command is good. The $ ret always makes me a false since it is equal to 1 and the output $ output is zero. I guess it is the function of shell_exec that bug.

Obviously I have user rights on file, the path environment variable modified, paths and dot exec path, Extension ImageMaps that works.

This function takes ExecuteCommand here:

...

So anyone have an idea to make it work properly function shell_exec?
Thank you for your attention and interest you can (apply to my problem)."


Thanks to google translate for the help.
User avatar (0000838)
ellson (administrator)
2014-10-15 10:53

I think this is a media-wiki problem rather than graphviz.

Shells, and other commands, at least on Unix, always return 0 for success and anything non-0 for fail. So that: "if ($ ret! = 0) {return false; }" looks like a translation into php conventions?

I see:
  $ command = "2> & 1".;

but I don't see where "\somepath\dot.exe -Tpng" is provided to the shell??

I'm not able to be much help, I think. I don't know windows or media-wiki.
User avatar (0000839)
Mikael92 (reporter)
2014-10-15 11:05

I have found the probleme was the shell_exec function.

Just replace "$output = wfShellExec( $command, $ret );" by "$output = shell_exec($command);" and maybe some others parameters are changed.

$ret become indefined ... but it's working so no need :)

thank you for your help. I'm trying to install Extension:categoryBrower.

PS : sorry for my english
User avatar (0000840)
ellson (administrator)
2014-10-15 11:13

PPS : No probleme. Sorry for my French, Cheers. :-)

- Issue History
Date Modified Username Field Change
2014-10-15 05:17 Mikael92 New Issue
2014-10-15 05:23 Mikael92 Note Added: 0000836
2014-10-15 10:39 ellson Note Added: 0000837
2014-10-15 10:53 ellson Note Added: 0000838
2014-10-15 11:05 Mikael92 Note Added: 0000839
2014-10-15 11:13 ellson Note Added: 0000840
2014-10-15 11:14 ellson FIX-COMMENT => User resolved the issue.
2014-10-15 11:14 ellson Status new => resolved
2014-10-15 11:14 ellson Resolution open => fixed
2014-10-15 11:14 ellson Assigned To => ellson


MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker