Last modified: 2013-01-08 00:05:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T34416, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 32416 - [SM] maps break with the error "Undefined variable: mwmaps" when produced from a template
[SM] maps break with the error "Undefined variable: mwmaps" when produced fro...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
SemanticMaps (Other open bugs)
unspecified
All All
: Unprioritized major (vote)
: ---
Assigned To: Jeroen De Dauw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-14 22:44 UTC by badon
Modified: 2013-01-08 00:05 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
template and demo wiki code, 2-space tabs used in formatting (837 bytes, application/octet-stream)
2011-11-16 05:45 UTC, badon
Details
Demo wiki code with workaround in the template (929 bytes, application/octet-stream)
2011-11-16 06:06 UTC, badon
Details

Description badon 2011-11-14 22:44:02 UTC
Sometimes I get a situation where semantic maps fails to load up a google map, and instead shows a gray box with the message "Loading map...". The queries being used to display the maps don't seem to make any difference, but here's a couple of examples:

{{#ask: [[Type::{{PAGENAME}}]]
| ?Location
| format=map
| zoom=2
| autozoom=off
}}

{{#ask: [[Category:SomeCategory]] [[Belongs to::{{PAGENAME}}]] [[Location::+]] 
| ?
| sort=Sighting date
| order=descending
| limit=1
}}

I thought maybe there was a problem with my web browser, so I tried it on a few different browsers, and got essentially the same errors:

Opera Dragonfly says this:

Uncaught exception: ReferenceError: Undefined variable: mwmaps	
Uncaught exception: ReferenceError: Undefined variable: mwmaps	
Uncaught exception: TypeError: Cannot convert 'window.mwmaps' to object	Event thread: DOMContentLoaded

Google Chrome's Inspector says this:

Uncaught ReferenceError: mwmaps is not defined
Uncaught TypeError: Cannot read property 'googlemaps3' of undefined

Firefox's Firebug says this:

mwmaps is not defined
[Break On This Error] <div id="map_google3_2" style="width: ...,"label":"","locations":[]};</script>
mwmaps is not defined
[Break On This Error] <div id="map_google3_3" style="width: ...,"label":"","locations":[]};</script>
window.mwmaps is undefined
[Break On This Error] setTimeout(this,100);}};setTilt();}_th...ot compatible with Google Maps v3."});

I haven't been able to figure out what can reliably cause this to occur, but I did discover that moving the map around the page can cause it to go away. In particular, moving it to the top of the page will sometimes fix it, especially if the map appears twice both at the top of the page and elsewhere in the page.

Sometimes simply putting the map at the top of the page makes it suddenly work again. Putting a single map at the bottom of the page has not caused it to work, but if there's an identical map at the top of the page, it might start working again.
Comment 1 badon 2011-11-14 22:46:57 UTC
Whoops, that second query example is the wrong one. It should be this one:

{{#ask: [[Category:SomeCategory]] [[Belongs to::{{PAGENAME}}]] [[Location::+]]
| ?Location
| sort=Sighting date
| order=descending
| zoom=4
| controls=type, streetview, zoom
| autozoom=off
| limit=1
}}
Comment 2 Jeroen De Dauw 2011-11-15 08:51:59 UTC
Can you reproduce this on a public wiki and link to it?
Comment 3 badon 2011-11-16 05:45:32 UTC
Created attachment 9463 [details]
template and demo wiki code, 2-space tabs used in formatting

Yes, I spent a few hours experimenting with this, and I managed to put something together that demonstrates the bug in all the random variations I could find that seemed to be important (Login with Demo/test):

http://www.coincompendium.com/wiki/index.php/Sandbox/Bug_32416

There are comments in the code that should guide you in figuring out what is happening. The problem seems to stem from a template that contains mapping code, and the bug is triggered with map queries and with ordinary maps (I tested <display_points> also).

It appears that the template's mapping code is preventing the demo maps from displaying. All maps work if the Bug 32416 template mapping code (stored in a variable) is displayed above the demo maps, or if other maps are displayed above the call to the Bug 32416 template. 

I think the bug is just some unintended interaction between maps in the template, and maps outside the template. Somehow, the Bug 32416 template's maps prevent other maps from displaying, if they don't get displayed themselves, or if there are no other maps above the Bug 32416 template.

This is probably the most difficult bug to pin down that I have found so far (the delimiter issue in Bug 30534 took longer though, because it is much more subtle). I am eager to find out what is causing the maps to be dependent on other maps if a map is created in a template, and how it is fixed to make them independent.

Until it is fixed, I will try to find a workaround where the map from the template is always displayed, but hidden when it is unwanted. Hopefully CSS can do that. I will try it.

Let me know if something isn't clear in the demo. I'll attach the texts of the demo to this bug report.
Comment 4 badon 2011-11-16 05:55:18 UTC
My proposed CSS workaround was successful. Displaying the template map with a CSS class in MediaWiki:Common.css like this:

.hidden {display:none;}

succeeded in circumventing the bug by displaying the map, but hiding it. Other maps on the page now work. Maybe that technique can be used as the basis of some expedient solution to the bug if a more elegant solution will need to wait until later?
Comment 5 badon 2011-11-16 06:03:43 UTC
I just added these lines to the template code, for you to play with:

<!-- uncommenting the below line will successfully workaround the bug https://bugzilla.wikimedia.org/show_bug.cgi?id=32416 -->
<!--
<div style="display:none;">{{#var: location map}}</div>
-->
Comment 6 badon 2011-11-16 06:06:11 UTC
Created attachment 9464 [details]
Demo wiki code with workaround in the template
Comment 7 Jeroen De Dauw 2011-11-16 11:41:30 UTC
Looks like a MW 1.17 specific bug that has been worked around already in some previous release of Maps. I suggest you upgrade and see if the issue goes away.
Comment 8 badon 2011-11-16 18:07:41 UTC
It looks like MediaWiki 1.18 is still in beta, which is why I haven't installed it yet. My workaround seems to be good enough for me until 1.18 is released. How long will 1.17 be supported? This page says MediaWiki releases are supported for one year - presumably that means one year after a new release.

Since the workaround is easy and very effective for 1.17, and the bug has been fixed in 1.18 (I'm taking your word for that since I haven't tested it), maybe it would be OK to just update the documentation with a "known bugs" section that links to this bug and briefly describes how to workaround it for those that continue to use older versions of MediaWiki.

If you agree, we can mark this one WONTFIX, and then focus attention on bugs that have no easy workarounds. What do you think?
Comment 9 Jeroen De Dauw 2011-11-16 18:19:13 UTC
Read: Looks like a MW 1.17 specific bug that has been worked around already in some previous release of Maps.

If it's fixed in Maps, it does not matter that 1.18 has not been released yet.

1.17 will be supported till after 1.19 is released.
Comment 10 badon 2011-11-16 19:57:12 UTC
Yes, I read that line, and rereading it a few times didn't help. I realize English is not your first language. It was ambiguous whether you were meaning to upgrade the Semantic Maps bundle or MediaWiki. I assumed MediaWiki since you specified it by version. My test MediaWiki 1.17 is still running Semantic Maps bundle 1.0.1 and I wasn't aware that 1.0.4 has been released because you didn't mention that key piece of information. Also, the various docs scattered across various different sites have not been updated to show 1.0.4 is out now. 

I will appreciate the courtesy of rephrasing instead of tersely repeating, next time I misunderstand what you're saying. It will save me a lot of time in bug testing for you.

In any case, I tried upgrading to 1.0.4 and it took down my wiki with the error message:

Error: This version of Semantic Maps requires Semantic MediaWiki 1.7 or above; use Semantic Maps 1.0 to 1.0.3 for SMW 1.6 to 1.6.1

If there's something more that needs to be done to upgrade, other than replacing the old version, I don't know what it is. The docs about upgrading are outdated, and some of them are still talking about versions 0.5 and 0.7. However, the release notes here:

http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SemanticMaps/RELEASE-NOTES?view=co

say the following for SM 1.0.4:

=== Semantic Maps 1.0.4 ===
(2011-10-15)

* Added compatibility with SMW 1.7 and later.
* Removed compatibility with SMW 1.6.1 and earlier.
* Improved default map format handling.

That seems to match the error message, so it appears compatibility with the current 1.17 version of MediaWiki has been broken somehow in Semantic Maps bundle 1.0.4. 

Downgrading to 1.0.3 brought my wiki back online, but also showed that the bug is still there as of 1.0.3, but unfortunately my workaround for the bug no longer works in 1.0.3. I did not test 1.0.2, and just downgraded directly to 1.0.1 to bring my wiki back online with a known effective workaround for the bug.

Let me know if you need any more information or if it would be helpful to test 1.0.2.
Comment 11 badon 2011-11-28 05:45:50 UTC
I'm not getting the undefined variable error for the non-working map on the lower right of this page:

http://www.coincompendium.com/wiki/index.php/Sandbox/another_maps_bug

I'm not sure if the cause is identical to the cause for this reported bug, but whatever it is, the workaround is not effective. I have not been able to isolate the bug better, and I have not been able to find anything that can make it work. The same code that's generating the map works fine when it is not in the template.

In general, it appears something is wrong with how Semantic Maps functions when being called from a template, and the JS error I discovered might be just an artifact of that.
Comment 12 badon 2012-02-08 21:14:01 UTC
The URL to the demo for this bug in comment 3 has changed to this (login with Demo/test):

http://www.coincompendium.com/w/index.php/Sandbox/Bug_32416
Comment 13 Jeroen De Dauw 2013-01-08 00:05:55 UTC
Fixed in latest rel

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links