diff --git a/includes/ImageMap.php b/includes/ImageMap.php index 6fc24eb..d67f20e 100644 --- a/includes/ImageMap.php +++ b/includes/ImageMap.php @@ -279,9 +279,11 @@ class ImageMap { if ( $realmap ) { // Construct the map - // Add random number to avoid breaking cached HTML fragments that are - // later joined together on the one page (bug 16471) - $mapName = "ImageMap_" . ++self::$id . '_' . mt_rand( 0, 0x7fffffff ); + // Add a hash of the map HTML to avoid breaking cached HTML fragments that are + // later joined together on the one page (T18471). + // The only way these hashes can clash is if the map is identical, in which + // case it wouldn't matter that the "wrong" map was used. + $mapName = 'ImageMap_' . substr( md5( $mapHTML ), 0, 16 ); $mapHTML = "\n$mapHTML\n"; // Alter the image tag diff --git a/tests/parser/imageMapParserTests.txt b/tests/parser/imageMapParserTests.txt index 70357ef..ef677e1 100644 --- a/tests/parser/imageMapParserTests.txt +++ b/tests/parser/imageMapParserTests.txt @@ -7,3 +7,15 @@ Image:Foobar.jpg !! result
Foobar.jpg
About this image
!! end + +!! test +dummy test +!! input + +File:Foobar.jpg + +poly 10.1 10.9 10 30 -30 15 [[Main Page]] + +!! result +
Main PageFoobar.jpg
About this image
+!! end