samwilson / diagrams-extension

A MediaWiki extension that displays GraphViz, Mscgen, PlantUML, and Mermaid diagrams in wiki pages.
https://www.mediawiki.org/wiki/Extension:Diagrams
GNU General Public License v2.0
8 stars 12 forks source link

Undefined array key "map" #94

Open daemonraco opened 5 months ago

daemonraco commented 5 months ago

Hi, I've been getting this error every time I change a page and save it:

Warning: Undefined array key "map" in /var/www/html/extensions/Diagrams/includes/Diagrams.php on line 135

I downloaded the latest version of this extension and at that line I found this piece of code (the if is line 135):

// Get the stored image map data, if applicable.
$ismapUrl = null;
if ( $diagramsRepo->fileExists( $repoFilepath . $outputFormats['map'] ) ) {
    if ( $outputFormats['map'] === 'ismap' ) {
        $ismapUrl = $files['map']->getUrl();
    } elseif ( !$mapData ) {
        $mapData = file_get_contents( $files['map']->getFullUrl() );
    }
}

Could it be that $outputFormats['map'] is not being checked for undefined values?

samwilson commented 5 months ago

That's strange. There should be something in $files['map'] if there is an $outputFormats['map']. We can easily add a check, but I wonder if the actual bug is another thing. Are you using plantuml? Could you share the minimal wikitext that produces this error?