Last modified: 2013-10-23 18:17:11 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 T39013, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 37013 - ResourceLoader does not check dependencies for existance
ResourceLoader does not check dependencies for existance
Status: RESOLVED WORKSFORME
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
aklapper-moreinfo
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-22 09:07 UTC by Dmitriy Sintsov
Modified: 2013-10-23 18:17 UTC (History)
6 users (show)

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


Attachments

Description Dmitriy Sintsov 2012-05-22 09:07:33 UTC
I developed my extension in 1.18wmf1 then in 1.20 master. One of ResourceLoader modules, defined by extension has the following dependency:

			'dependencies' => 'mediawiki.jqueryMsg',

The 'mediawiki.jqueryMsg' module and it's script is present in 1.18wmf1, 1.19, 1.20 master, but I was really surprised that in 1.18.2 it does not exists so the page scripts where my extension module is requested were broken with the following Chrome console errors:

Uncaught Error: Unknown dependency: mediawiki.jqueryMsg load.php:9427
Uncaught TypeError: Cannot read property 'options' of undefined GmapFunc:255
Uncaught TypeError: Cannot read property 'tokens' of undefined GmapFunc:260

Can I try to catch the client-side error in load.php? I don't know how. Instead, I implemented the following server-side method to check whether the dependent modules actually exists:

	static protected function checkAllModulesExists() {
		$allModules = array_keys( self::$mapModules );
		foreach ( self::$mapModules as $moduleName => $moduleDefinition ) {
			if ( !array_key_exists( 'dependencies', $moduleDefinition ) ) {
				continue;
			}
			if ( is_array( $moduleDefinition['dependencies'] ) ) {
				$allModules += $moduleDefinition['dependencies'];
			} else {
				# We do not check for multiple matches in values:
				# it would only decrease performance in this case.
				$allModules[] = $moduleDefinition['dependencies'];
			}
		}
		$nonExistantModules = array_diff(
			$allModules,
			self::$out->getResourceLoader()->getModuleNames()
		);
		if ( count( $nonExistantModules ) > 0 ) {
			throw new MWException( 'Cannot find requested module(s): ' .
				implode( ',', $nonExistantModules ) .
				' in ' . __METHOD__
			);
		}
	}

Which produces the following page message, at least (that is more informative than Chrome console message):

Cannot find requested module(s): mediawiki.jqueryMsg in GMFn::checkAllModulesExists

It would be nice if ResourceLoader itself checked the dependencies of added modules.
Comment 1 Krinkle 2012-05-27 23:20:04 UTC
Modules can be dynamically registered. This should be checked in mediawiki.js instead.

I believe this has been fixed in 1.19 or 1.20, could you confirm?
Comment 2 Dmitriy Sintsov 2012-05-28 06:18:19 UTC
I think Extension:UploadWizard also was using this module and it should be supported in 1.18.2 as well.

Is there a graceful way of catching these errors at client side in 1.20? However, 1.20 includes the forementioned module.
Comment 3 Andre Klapper 2013-05-17 14:16:26 UTC
(In reply to comment #1)
> Modules can be dynamically registered. This should be checked in mediawiki.js
> instead. I believe this has been fixed in 1.19 or 1.20, could you confirm?

Dmitriy: Still running 1.18, or have you upgraded in the meantime?
If the latter, cxould you answer above question?
Comment 4 Dmitriy Sintsov 2013-05-17 14:55:42 UTC
Andre, MediaWiki is unpopular framework here in Russia. Our education system receives much smaller financing comparing to first world countries. Grants and charities are also very small, infrequent and hard to get. Non-commercial work is self-prohibitive because the life is expensive and wages are small (not in Moscow, at least). So I was not getting enough of freelancer MediaWiki job. Thus I was forced to move to Drupal then to my own framework. Sometimes I do small MediaWiki work but not so often and I lost deep knowledge of MediaWiki internals I had back in 1.15-1.17 times (API, FileRepo, early versions of ResourceLoader).

But of course previous lack of good scripting and lack of VisualEditor also contributed to low popularity of MediaWiki here in Russia. Hope it will get more popular again.

The site is now running 1.22wmf1. It was not my personal site but a freelancer job.
Comment 5 Andre Klapper 2013-08-14 16:09:13 UTC
I see... Pity.
As we cannot retest, closing as per comment 1.

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


Navigation
Links