(bug 27508) SVGMetadataExtractor takes too much resources on huge svg's. Change it...
authorBrian Wolff <bawolff@users.mediawiki.org>
Sun, 6 Mar 2011 08:15:49 +0000 (08:15 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Sun, 6 Mar 2011 08:15:49 +0000 (08:15 +0000)
commite6de99be92a1d96b5609c1c5eeb8c2fab66ebfc4
treee85c0d43a964bf25ebe8ecf15db82e3fa5fe8e2e
parent02ef2dc762eb3688180add68309cb2353e8d5c3b
(bug 27508) SVGMetadataExtractor takes too much resources on huge svg's. Change it so it only looks at begining of file.

Add a new config variable $wgSVGMetadataCutoff (currently set to 256kb, chosen rather arbitrarily)
and only read that much of the svg file when finding metadata. In general:
*Most (non-crazy huge map) svgs aren't that big, so there'd be no change in general
*Almost all files have any relevent metadata (well except for when we look for animation tags) is at the begining of the file
before actual image data.
*At the end of the day, even if this does miss metadata in some files (which I really doubt it would), I'd consider that a better
situation then the current situation where it can take 10 minutes or have OOM to parse the likes of [[:File:Puerto_Rico_ecosystems_map-fr.svg]]

Also has parts of/parts are based on Hartman's patch from bugzilla in it.

Also changes how it recurses into child elements looking for animation, to do so only when neccesary.

Trims the results of reading values, because i was getting extra leading spaces when testing this.

Last of all, add a comment to the MediaHandler class about how the first parameter of MediaHandler::getMetadata is kind of useless.
(it confused me when I was doing this)
RELEASE-NOTES
includes/DefaultSettings.php
includes/media/Generic.php
includes/media/SVGMetadataExtractor.php