Extension talk:GraphViz

From MediaWiki.org
Jump to: navigation, search

Error Messages and other curious behaviour[edit | edit source]

I have expected that the diagrams created for the old graphViz extension would also work with the new one. Instead I get an error message: "Error: no valid link was found at the end of line 2".

What does this mean?
Answer: Extension:ImageMap now handles image rendering on behalf of the GraphViz extension. The "no valid link" message is actually from the ImageMap extension complaining that it doesn't understand the provided link syntax. The old GraphViz extension syntax for specifying an internal link (a bare string without enclosing square brackets) is not natively understood by MediaWiki or the ImageMap extension. If you add two sets of enclosing square brackets (the normal wiki syntax for internal links) you'll be back in business. Please see Extension:GraphViz#Links for more information about the new GraphViz link syntax. P.S. Do you have graphs with a ton of internal links in the old syntax? I dislike the idea of perpetuating a non-standard internal link syntax but if this is a significant hardship then I might consider a backwards compatibility shim. --Thanks, Keith Welter

Are there other error messages which should be explained?
Answer: In addition to returning error messages from Extension:ImageMap, the GraphViz extension also returns error messages from the graphviz and mscgen rendering tools (e.g. about syntax errors in the DOT or Mscgen language input). The GraphViz extension also returns error messages about problems uploading a rendered image (e.g. insufficient permissions or forbidden image type). Finally the GraphViz extension returns error messages about internal errors such as failure to create the working directory. These are the basic categories of error messages. If you see a specific error message and have questions about it, please let me know. --Thanks, Keith Welter

Because my own examples didn't work, I tried the first two examples from the extension page. I get a very curious behaviour when putting both examples on one page.
Here's the code:

== simple graphViz test ==

=== Example 1 from http://www.mediawiki.org/wiki/Extension:GraphViz ===
<graphviz border='frame' format='png' desc='none'>
digraph example1 {Hello->"World!"}
</graphviz>

=== Example 2 from http://www.mediawiki.org/wiki/Extension:GraphViz ===
<graphviz renderer='neato' caption='Hello Neato'>
graph EXAMPLE2 {
  run -- intr;
  intr -- runbl;
  runbl -- run;
  run -- kernel;
  kernel -- zombie;
  kernel -- sleep;
  kernel -- runmem;
  sleep -- swap;
  swap -- runswap;
  runswap -- new;
  runswap -- runmem;
  new -- runmem;
  sleep -- runmem;
}
</graphviz>

The first heading is shown on the left side (correct)
The first diagram is presented on the right side. (don't know if this is correct.)
Then the second heading is shown under the first diagram and the second diagram is also shown on the right side. (wrong)
The second heading and the second diagram should be placed on the left side.

Is this already known?
Answer: As mentioned above, Extension:ImageMap now handles image rendering on behalf of the GraphViz extension. It does standard MediaWiki image rendering. If you scroll down in the image format table, you'll see that format=frame does yield the image on the right of the screen. Also see, Help:Images#Horizontal_alignment I think all the answers to your formatting questions should be on the image page. If not, the talk page for that is the right place to post follow-up questions. --Thanks, Keith Welter

Workaround: For now, I have simply removed the border='frame' part. Then, there are no borders and both diagrams are shown on the left side.

Thanks, Martin

July 1st, 2014: Thanks Keith for the very fast answer!

I'll try with the new link syntax. I'm generating my diagrams from the results of sparql queries (working with Semantic MediaWiki). This way the diagrams always show the current state of the wiki. So I have only to do some corrections in a few templates. But at first, I'll try to get some hard-coded examples working. I'll share my experiences here. And I'll take a closer look at the ImageMap extension. Thanks for the explanations on that.

I have experimented further and I now see that there is another problem at the bottom of it. Even when I removed all links I got the error message with the link. And this was really confusing. But now I have seen this: when I change a graph without changing its name it is not re-rendered. I have now started with the simple "Hello, World" example and only added a second line to the DOT code: Hello -> Goodbye; . When saving the page the old diagram is shown. When changing the name to something not used before, the new diagram will be created. I'm sure that this works for you, so I think I'm doing something wrong. Where can I look for debugging this?

Hi Martin, I'm seeing the same problem on MW 1.22.2. Please open a bug (I'll be debugging in the meantime). The edit preview does still work for me. So you can try that to see how your rendered graphs look. Just click on the "Show preview" button on the edit page.

Actually, I just installed GraphViz version 1.3.0 and if I reload the page after clicking save then I see the rendering of the updated graph. Please try that and report back with your results (along with your MW version and GraphViz version which you can find on the Special:Version page of your wiki. Caching may be a factor so please also provide the $wgMainCacheType value from your LocalSettings.php.

For debugging, see Manual:How_to_debug. I use the following in my LocalSettings.php:

$wgDebugLogFile = "/var/log/mediawiki/debug-{$wgDBname}.log";
$wgDebugToolbar = true;
$wgShowExceptionDetails = true;
$wgDevelopmentWarnings = true;

The GraphViz extension uses wfDebug statements to produce debug log entries which include the function name. You can search for names like "GraphViz::", "GraphRenderParms::" and "UploadLocalFile::".

--Thanks, Keith Welter

Hello Keith,

I wanted to try version 1.3.0 before filing a bug report but I couldn't download it. I have still MediaWiki 1.19.17 and therefore followed the git link. There I still get the version 1.1.0 from June 27th. I have even emptied my browser cache and downloaded again, same result. Perhaps due to caching at www.mediawiki.org???

Talking of caching: I'm using the default CACHE_NONE for my wiki.

And the extension works fine as long as I'm not updating the dot code. Even my templates work now. (so "Thanks!" again!)

Another point: when having finished this discussion I would look over this and keep only the essentials which may be of importance for other users. Is this OK for you?

Best regards, Martin

Hi Martin, I recreated the problem on MW 1.19.17. The problem is that the extension uses two hooks that were introduced in MW 1.21. There are alternative hooks (deprecated in MW 1.21) that should work for MW versions <1.21. I'll begin work on the backward compatibility fix. Please do proceed with opening the bug. Also, I agree about cleaning-up this talk page when we're done. And feel free to suggest any improvements for the doc on the main extension page. --Thanks, Keith Welter

Hello Keith,

I have filed the bug now. It's number 67587 [1]. And thanks for addressing the backward compatibility issue. Despite the newer versions of MediaWiki the 1.19.17 is a long-term stable one and there are still a lot of people using it. --Best regards, Martin

Preview[edit | edit source]

Every time a new graph is added to the page or an old one is edited, on preview or page save, instead of the graph, an inscription appears: Graph image source changed. Reload page to display updated graph image., and you need to press F5 to see the graph. It was not like this in previous versions of the extension. This is very uncomfortable since it renders the Preview button useless, and a graph is not something you can make perfect on the first attempt.

Alex Mashin (talk) 07:33, 20 July 2014 (UTC)

Hi Alex. First off, sorry for the slow response. This page is on my watch list but I didn't get notified (or it went to my spam folder which only goes back to August). I'll endeavor to remove the reload behavior in a future version (it requires a substantial design change so it will probably be version 2.x.x). Another apology-- I'm effectively on paternity leave so it will be some time before I can get to this. Thanks for your feedback and sorry the reload behavior is not to your liking. BTW, pressing F5 to reload the graph image on the preview page works for me to see graph changes reflected before saving them. --Welterkj (talk) 21:57, 18 September 2014 (UTC)

Hi Alex, I've released version 1.4.0 which avoids the reload message in most cases. Please give it a try and let me know how it goes. Thanks! --Welterkj (talk) 19:21, 19 October 2014 (UTC)

Dynamic Graphs[edit | edit source]

I've been using earlier versions of this extension for some time to generate GraphViz code and replace text/colors in the code with live status from a database to produce live network diagrams based on our monitoring systems. This recent update appears to have broken that ability. What I'd done was to have something like this in a page:

<my_graphviz>
graph {
  A [label=<<table><tr><td><img src="{{MyIcon:A}}"/></td></tr><tr><td>A</td></tr></table>];
  B [label=<<table><tr><td><img src="{{MyIcon:B}}"/></td></tr><tr><td>B</td></tr></table>];
  A -- B [taillabel="1",headlabel="2",color="{{MyPort:A:1}};{{MyPort:B:2]]"];
}
</my_graphviz>

My extension takes this tag input and replaces the {{MyIcon:HOST}} patterns it finds in the content with icons that represent the state of the HOST. The {{MyPort:HOST:PORT}} patterns get replaced with a color that reflects the interface state of the PORT on the HOST. The output of the extension is a <graphviz/> tag with the {{My...}} tags replaced then sent back through $parser->recursiveTagParse(). The tag is also calling $parser->disableCache() so the results are updated for each request.

This has worked well for many years until last week when I updated a DEV machine to the new release of this extension. Seems the new approach to storing the generated images as true file articles in MediaWiki is messing with me. I thought I'd reach out and see if there's some nice way to fix this or if I should just stick with the older code.

Thanks in advance.

PDugas (talk) 14:34, 28 July 2014 (UTC)

Hi PDugas. Please see my response to Alex about the "Preview" issue above. I suspect you are running afoul of the same reload behavior that Alex dislikes. I suggest you stick with the older code until the new version I described to Alex is available. Sorry the current version isn't working for you. --Welterkj (talk) 22:02, 18 September 2014 (UTC)

Hi PDugas, after more thought, I think the dynamic graph functionality you describe would require a new feature in the GraphViz extension (>1.0). I'll do some more investigation. --Welterkj (talk) 19:23, 19 October 2014 (UTC)

Dynamic graph functionality is now available at the development level (use "composer require mediawiki/graph-viz 'dev-master'"). Usage: <graphviz preparse="dynamic">...</graphviz>. You can also specify preparse="static" which will only replace variables/templates when saving or previewing an edit of the page containing the <graphviz> (or <mscgen>) tags. --Welterkj (talk) 20:34, 26 October 2014 (UTC)

The preparse tag argument is now available in version 1.5.0. --Welterkj (talk) 21:25, 28 October 2014 (UTC)

Does not always work with me: Error: blablabla.src:0: syntax error near line 0 context: digraph example1 >>> {Hello- <<< >World} With dynamic as well as static setting of the preparse argument. edit: at times it appears to be working, though it is difficult to make out the reason why, because on another occasion it refuses to do so and throws out a considerable amount of errors messages.--Temptuousinsolence (talk) 15:04, 31 October 2014 (UTC)

Hi Temptuousinsolence, please raise a bug under component "[other]" and provide the wikitext that caused the problem as well as a debug log. Thanks. --Welterkj (talk) 16:02, 31 October 2014 (UTC)--

Bugfix Version 1.3.1 (2014-07-10)[edit | edit source]

Hi, I don't know how to report this on https://bugzilla.wikimedia.org because the extension is not listed there, so I report this here:

  • the contruction of the class GraphVizSettings() is wrong and stops the Wiki from functioning. (I use MediaWiki 1.23.2, PHP 5.4.20 (fpm-fcgi), MySQL 5.6.12-log)

Here is a patch:

--- GraphViz.php	2014-08-06 22:49:40.000000000 +0200
+++ GraphViz_neu.php	2014-08-06 22:47:07.000000000 +0200
@@ -69,20 +69,20 @@
 	public $defaultImageType;
 };
 
-$wgGraphVizSettings = new GraphVizSettings();
 
 //self executing anonymous function to prevent global scope assumptions
 call_user_func( function() {
 
+	$wgGraphVizSettings = new GraphVizSettings();
 	// Set execution path
 	if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'Darwin' ) ) {
-		$GLOBALS['wgGraphVizSettings']->execPath = 'C:/Program Files/Graphviz/bin/';
+		$wgGraphVizSettings->execPath = 'C:/Program Files/Graphviz/bin/';
 	} else {
-		$GLOBALS['wgGraphVizSettings']->execPath = '/usr/bin/';
+		$wgGraphVizSettings->execPath = '/usr/bin/';
 	}
 
-	$GLOBALS['wgGraphVizSettings']->mscgenPath = '';
-	$GLOBALS['wgGraphVizSettings']->defaultImageType = 'png';
+	$wgGraphVizSettings->mscgenPath = '';
+	$wgGraphVizSettings->defaultImageType = 'png';
 
 	$dir = __DIR__ . '/';

--Andreas P. Icon External Link E-Mail.png 11:24, 7 August 2014 (UTC)

Hi Andreas. The existing code works fine for me on MW 1.23.2. Can you be more specific about the symptoms of your problem? It seems to me that with your patch $wgGraphVizSettings would only be visible within the local scope of the anonymous function that contains it (though it is meant to be global scope). Thanks. --Welterkj (talk) 22:27, 18 September 2014 (UTC)

I had the same problem and it helps at least to get rid of the error message in line 81 of the Graphviz.php: $GLOBALS['wgGraphVizSettings']->execPath = '/usr/bin'; The symptom is that there is a persistent error message that does not want to vanish. --Temptuousinsolence (talk) 10:16, 21 October 2014 (UTC)

I reproduced the problem and raised bug 72325 (component [other] is fine for GraphViz bugs). Thanks! --Welterkj (talk) 18:04, 21 October 2014 (UTC)

Fixed in version version 1.4.1. --Welterkj (talk) 04:03, 22 October 2014 (UTC)

Specific example?[edit | edit source]

The link given the for example is a link to the gallery for the Graphviz library, not Extension:GraphViz itself. Is there a demo site where this extension is running? If a live demo site isn't available, maybe show some screenshots/PDFs of the page source showing Graphviz syntax and the resulting output. --Lance E Sloan 17:39, 16 September 2014 (UTC)

Hi Lance. I changed the link to point to Extension:GraphViz#Examples. If I find a good live demo site I'll update it again. Thanks. --Welterkj (talk) 22:10, 18 September 2014 (UTC)

GraphViz 1.5.0 internal error with MW 1.23.6[edit | edit source]

I run MW 1.23.6. GraphViz 1.3.1 works fine. But when I upgrade GraphViz extension (using composer) to 1.5.0, I get following "Internal error" when opening a page with embeded graphs or try to create a new graph:

[exception] [107987dc] /mediawiki/index.php?title=Sandbox&action=submit
Exception from line 77 of /srv/www/htdocs/mediawiki/includes/parser/StripState.php:
Invalid marker: ^?UNIQ9f35223a283f1154-graphviz-00000001-QINU^?

Anybody having the same issue? --Ralfk (talk) 12:39, 31 October 2014 (UTC)

Yes, I have the same issue. Preparsing (see a bit above) makes it at least possible to edit the page and enter the content to the MW-page, but the current GraphViz extension is hardly working smoothly. --Temptuousinsolence (talk) 15:06, 31 October 2014 (UTC)

Hi guys, sorry for your trouble with GraphViz 1.5.0 and MW 1.23.6. I did my testing on MW 1.23.2 and MW 1.19.20 so I'll upgrade the former and try to reproduce. In the meantime, please raise a bug under component "[other]" and provide a debug log. Thanks. --Welterkj (talk) 15:55, 31 October 2014 (UTC)

I have setup xdebug and will upload a log file once I have configured it properly.--Temptuousinsolence (talk) 10:11, 4 November 2014 (UTC)

I got some time to investigate today and it appears that the contents of the git repository are not what they should be. So please disregard the request for a debug log file while I sort-out what happened with the relevant commits. To revert to a stable version: composer require mediawiki/graph-viz '1.4.1' Sorry again for the inconvenience. --Welterkj (talk) 00:13, 5 November 2014 (UTC)

I have changed the GraphViz-Version, but still the same error.--Temptuousinsolence (talk) 13:41, 5 November 2014 (UTC)

I had tagged the wrong commit when I created release 1.5.0 for composer. That is fixed now so uninstalling/installing version 1.5.0 will now result in the correct code being installed. To uninstall, I delete the require graph-viz line out of the composer.json file in the MW installation dir and then do 'composer update'. I tested a composer install of the fixed version 1.5.0 on MW 1.23.6 and that worked fine for me (version 1.4.1 also works for me). Please reinstall version 1.5.0 and if you still have trouble we should really open a bug report and move the conversation there. I'm happy to do that if needed. Thanks. --Welterkj (talk) 20:29, 5 November 2014 (UTC)

What has changed is that the amount of errors has increased ...
for instance:

Error detected at line 4: syntax error, unexpected characters. > Vorlage->Vorlage [label="Erstellt"]; the ">" is not parsed correctly of the mscgen. I thought that maybe there was an error in the permissions, since I am on a Linux machine and played around with them and now I have an even longer trail of error codes ... Bugreport --Temptuousinsolence (talk) 09:39, 6 November 2014 (UTC)

I uninstalled the extension (even though this wiki was on 1.3.1 before) and installed it again as 1.5.0. But still the same error (and even one additional) --Ralfk (talk) 14:22, 6 November 2014 (UTC):
[Bug56269] Exception thrown with an uncommited database transaction: [8d1f035a] /wiki/Sandbox/Graphviz   Exception from line 77 of /srv/www/htdocs/w/includ
es/parser/StripState.php: Invalid marker: ^?UNIQbc7b8602bc553993-graphviz-00000003-QINU^?

[exception] [8d1f035a] /wiki/Sandbox/Graphviz   Exception from line 77 of /srv/www/htdocs/w/includes/parser/StripState.php: Invalid marker: ^?UNIQbc7b8602b
c553993-graphviz-00000003-QINU^?
  • I confirm that the invalid marker error is still there as of today.
    Alex Mashin (talk) 10:53, 8 November 2014 (UTC)
    • After downgrading to 1.4.1 and 1.4.0, the error persists. 1.3.1 works, more or less ().
      Alex Mashin (talk) 11:30, 8 November 2014 (UTC)

I need a debug log to diagnose this problem since I am unable to reproduce it. If someone could attach a log to the bug report that would be a big help. -Welterkj

I uploaded a log ... I had been busy lately and did not have had the time to deal with this. --Temptuousinsolence (talk) 08:53, 13 November 2014 (UTC)

preparse[edit | edit source]

What is wrong with {{#tag:graphviz|...}}?
Alex Mashin (talk) 11:30, 8 November 2014 (UTC)

Polynomial explosion when used in templates[edit | edit source]

This extension creates articles in the File namespace, one per image. This is fine. But if you use the extension in a template, and 100 pages transclude the template, you get 100 identical images in the File namespace. And every time you update the template, potentially 100 uploaded files get replaced... all identical! That seems a fundamentally questionable design decision.

Is there a way around this non-scalable behavior? --Maiden taiwan (talk) 20:43, 21 November 2014 (UTC)

Call to a member function getId() on a non-object[edit | edit source]

When GraphViz first creates its File page, we are seeing this error:

PHP Fatal error:  Call to a member function getId() on a non-object
in /path/w/extensions/GraphViz/GraphViz_body.php on line 351

Here's the line:

return $title->getLatestRevID() != $title->getFirstRevision()->getId();

So getFirstRevision() is null, perhaps because the File page hasn't been created yet? Should this be:

return $title->getFirstRevision()
  ? $title->getLatestRevID() != $title->getFirstRevision()->getId()
  : false
  ;

MediaWiki bug tracker is down this week for an upgrade, so I'm reporting the problem here. Any workarounds?

--Maiden taiwan (talk) 20:54, 21 November 2014 (UTC)

Possible. But maybe it is related to the issue that is brought oup here. I somehow recall that I had problems with the id once as well, but it had been in a different environment that I am currently working with. --Temptuousinsolence (talk) 09:24, 24 November 2014 (UTC)