Page MenuHomePhabricator

A way to know which features api.php supports
Closed, ResolvedPublic

Description

Sometimes it's good to make flexible JavaScript that can do something better or more efficiently if api.php has a new feature but fall back to a rougher or less efficient way if the feature is missing.

Currently we only have wgVersion but many changes occur on live wikis between version.

We could expose the svn revision as a JavaScript wg constant but forked wikis such as Wikia may have different svn revisions thus breaking any connection between the MediaWiki revision and the api.php feature set.

It may be possible to have some kind of feature array but that could be bulky.

Best might be a universal wgApiRevision which is not dependent on svn and thus will be the same even if you're on a forked wiki, forked api.php would be another story however.

In any case it's surely a good idea to expose the information provided by api.php's "version" parameter. Currently it only outputs flat text when viewing help but could output structured data for JSON and all formats.

In my case I have three ways to achieve my goal. If api.php is not available I can do several ajax hits to the server which results in partial information. If api.php is available I can do a single ajax server hit but need to request more data than strictly necessary. If api.php supports the "amlang" parameter for "meta=allmessages" I can get everything I need with a single efficient ajax server hit.

Currently, however, there is no deterministic way to know if "amlang" is supported.


Version: unspecified
Severity: enhancement

Details

Reference
bz12718

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:07 PM
bzimport set Reference to bz12718.

You can try standard error handling way now. Though, action=capable should be implemented

(In reply to comment #1)

You can try standard error handling way now. Though, action=capable should be
implemented

It should. Still, you can regex the action=help output for "amlang".