splitbrain / dokuwiki-plugin-ditaa

Renders ASCII flowcharts contained in a DokuWiki page to images
http://www.dokuwiki.org/plugin:ditaa
5 stars 5 forks source link

Every ditaa diagram ends up in the same shown picture #13

Closed conturNDE closed 8 years ago

conturNDE commented 9 years ago

Hi to everyone,

Tested on two different instances of Dokuwiki (Release 2014-09-29d "Hrun") on two different servers. The behaviour is the same. We use the Ditaa-Plugin in version "ditaa 1.0" (should be the newest one).

We have on several pages some ditaa diagrams. But on all the pages for all the different diagrams the same picture is shown. The URL of the picture

If I tested ditaa manually (java -jar ditaa0_9.jar bla.txt) the created diagram is the correct one.

The HTML source code shows different references for different images, but the images containing the same content. for example:

The only "*ditaa.png"-file I found at cache: /var/www/DokuWiki/data/cache/1/1ca35f68b30b7478c3a0855ac1a73b58.ditaa.png the corresponding /var/www/DokuWiki/data/cache/1/1ca35f68b30b7478c3a0855ac1a73b58.ditaa.txt shows the content of a total different diagram.

Things I tryed:

Greets, Andreas

denisimmoos commented 8 years ago

Hi there,

Exactly the same issue with Release 2015-08-10 "Detritus".

Tried the same steps also:

Greets, Denis

wols commented 8 years ago

+1

denisimmoos commented 8 years ago

Hi wols, Hi conturNDE,

Could you find a workaround ?

I'm desperately looking for a fix :/.

Thanks ...

denisimmoos commented 8 years ago

[Mon Aug 17 04:44:30.703006 2015] [:error] [pid 19259] [client x.x.x.x:61969] PHP Warning: Invalid argument supplied for foreach() in /var/www/html/dokuwiki/lib/plugins/ditaa/syntax.php on line 105, referer: http://x.x.x.x/dokuwiki/doku.php

jabateman commented 8 years ago

I'd also like to mention I'm seeing the same problem.

I have not found a work-around yet.

jabateman commented 8 years ago

I found what I think is a workable solution. The cachename for each image seems to be based on an MD5 hash of the scale, antialias, edgesep, round and shadow settings on a given image. This does not make that cachename unique if the content is different and "settings" for a given ditaa image are the same.

The content for a given ditaa is already captured in its own MD5 hash, and simply adding the content MD5 to the cachename seems to resolve the issue to make each image have a unique cachename.

To add the content MD5 hash to the image hash, make the following change to syntax.php:

    function _prepareData($input)
    {
        $output = array();
        foreach( $input as $key => $value ) {
            switch ($key) {
                case 'scale':
                case 'antialias':
                case 'edgesep':
                case 'round':
                case 'shadow':
                case 'md5': //<- Add to allow ditaa content MD5 hash to be part of image hash
                    $output[$key] = $value;
            };
        }
        ksort($output);
        return $output;
    }