Jeroen De Dauw wrote:
Hey,
I'm looking for a way to change values passed to a parser function when it's executed. This would be to change addresses in the parser functions of the Maps extension into coordinates, so the geocoding doesn't need to happen every time the parser function is executed.
Example:
You enter: {{display_map:foobar}}
Then save the page, and when you edit, it shows: {{display_map:93.42, 12.34}}
What hook would be suited for such a thing?
Cheers
-- Jeroen De Dauw
There's no hook in the preSaveTransform() And it's much saner this way.
Your use case has several problems: *You are saving something very different than what the user has wrote. *What if the geocoding is later improved and foobar now maps to 93.37, 12.338 ? *The user misspelt foobar as foobaz, which happens to be in 7.21, 148.4 How would other users /easily) detect that mistake? *foobar doesn't exist now and isn't translated. It gets added later, and it's substituted on the next page save, which may be totally unrelated. *It's not obvious on [[foobar]] that the map is pointing to the correct coordinates (the user could have written foobar, or a wrong coord).
You want to not do the geocoding on each parserfunction call. Great, cache it in $wgMemc and recover from there when needed.