Page MenuHomePhabricator

OpenLayers input uses removed MW Core function OutputPage::addModuleScripts()
Open, Needs TriagePublic

Description

In Mediawiki 1.34, when using a form with an OpenLayers input type the following error is displayed :

Error from line 55 of /var/www/html/extensions/PageForms/includes/forminputs/PF_OpenLayersInput.php: Call to undefined method OutputPage::addModuleScripts()

OpenLayers extension should be enabled.

Event Timeline

Yokiria created this task.May 18 2020, 1:25 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 18 2020, 1:25 PM
Aklapper renamed this task from OpenLayers input uses removed function in MW 1.34 to OpenLayers input uses removed MW Core function OutputPage::addModuleScripts().May 18 2020, 1:30 PM
Aklapper added a project: Technical-Debt.

@Yokiria - sorry about the problem. It's been a long time since I tried using the OpenLayers extension. If you replace these two lines in PF_OpenLayersInput.php:

			$wgOut->addModuleStyles( 'ext.openlayers.main' );
			$wgOut->addModuleScripts( 'ext.openlayers.main' );

...with just this line:

			$wgOut->addModules( 'ext.openlayers.main' );

...does the code work for you?

@Yaron_Koren there is no error anymore, but the map is not displayed.
In the browser console I have a ReferenceError: OpenLayers is not defined error.
I use the 1.0.0 of the OpenLayers extension, installed via composer.

Not sure it's linked but I had this error previously when i disabled the OpenLayers extension.
The issue was with the line 58 of the same file. I had to replace the openlayers URL by https://openlayers.org/api/OpenLayers.js (I removed the "www")

Well, if I remember correctly, that's the reason why the code includes those strange calls to addModuleStyles() + addModuleScripts() in the first place, instead of just calling addModules() - because calling addModules() doesn't work, for some reason. I have no idea how to fix this problem, now that addModuleScripts() no longer exists. Maybe the OpenLayers extension just can't be used with Page Forms, until this problem is solved.

I'll get rid of the "www" in the Page Forms setting, but that's an unrelated problem.