Commit graph

269 commits

Author SHA1 Message Date
Baha
036b9c4167 Make API documentation links language aware
Links generated by the API are now aware of the user's preferred
language and will show documents in that language if available.

To test, log in to mediawiki.org and set your language preference to 'es',
then on an MediaWiki installation with this patch view the generated
expanded API help at `api.php?action=help&recursivesubmodules=1&modules=main`.
Each link to documentation on mediawiki.org should take you to its
translated /es subpage, if one exists.

Bug: T104518
Change-Id: I339a1f3ae1bce9d759cf251899d57c32b1def91e
2017-04-05 11:08:25 -04:00
C. Scott Ananian
1824778e44 Export list of languages which will trigger language conversion
LanguageConverter is enabled on a per-page basis, based on the page
language and whether it implements `$lang->getConverter()`.  Export
this in siteinfo so that Parsoid knows whether it should parse
language converter markup on a given page (based on the page language).

Bug: T153341
Change-Id: I010aa3812051725166ab79ea5ee3eaf56615fe94
2017-03-02 10:12:20 -05:00
James D. Forrester
50e796e948 includes/api: Replace implicitly-Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I49e2a10350a328a8572fcedd44012751a29e1068
2017-02-24 16:41:47 +00:00
Yuriy Shnitkovskiy
85a52faa37 Removed deprecated usages of Interwiki methods in core
Change-Id: Ibd25968660466c44189ccb01df1d8bec6e1b207c
2017-01-10 12:19:31 +02:00
Brad Jorsch
4e6810e4a2 API: i18n for warnings and errors
API warnings and error messages are currently hard-coded English
strings. This patch changes that.

With a few exceptions, this patch should be compatible with non-updated
extensions:
* The change to ApiBase::$messageMap will blow up anything trying to
  mess with it.
* The changes to the 'ApiCheckCanExecute' hook will cause a wrong
  (probably unparsed) error message to be emitted for extensions not
  already using an ApiMessage. Unless they're currently broken like
  Wikibase.

Bug: T37074
Bug: T47843
Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898
Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec
Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6
Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed
Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c
Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b
Depends-On: I535344c29d51521147c2a26c341dae38cec3e931
Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
2016-12-06 10:20:48 -05:00
Arlo Breault
2c55507814 API: Expose $wgGalleryOptions in the meta=siteinfo
* For native gallery rendering in Parsoid.

Bug: T151360
Change-Id: Ia38c17671380523476afca3bf84528f1c14da1a0
2016-11-22 22:31:55 +00:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Kunal Mehta
beb18f1edd API: Expose $wgEnableMagicLinks in meta=siteinfo
So Parsoid can use it.

Bug: T145590
Change-Id: Id792e07dc6fffec6d02b34168220b3a4e24b222b
2016-09-13 15:43:19 -07:00
Amir Sarabadani
7fd83c2102 Clean up array() in docs, Part I
Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f
2016-07-25 17:15:18 +04:30
jenkins-bot
351d3235f7 Merge "ApiQuerySiteInfo: Expose wgFixArabicUnicode and wgFixMalayalamUnicode" 2016-06-28 15:52:34 +00:00
Yusuke Matsubara
5db1b3455b ApiQuerySiteInfo: Expose wgFixArabicUnicode and wgFixMalayalamUnicode
These variables control how MediaWiki normalizes page titles.
Clients need to know these settings to not be surprised by such normalization.
See T94826.

Change-Id: Id77f584b8c3a3d9c065993bd74525f166112b20c
2016-06-28 08:07:38 +09:00
Florian
13155a3317 Expose $wgMaxArticleSize in siteinfo query api
Currently, an user of the api has to try to save a page to see,
if it's too big, or not. A much saner way would be, that the api user
reads the siteinfo of the target wiki to know the maximum size of a
page and trim the edit to not exceed this limit.

This commit exposes the value of the configuration variable, which
handles the maximum article size.

Bug: T138669
Change-Id: I25a4c1b9013f98e5b0a263a637c8b006dccfd5ad
2016-06-27 16:50:25 +02:00
Kunal Mehta
9a4ece7fc5 ApiQuerySiteInfo: Avoid extra getConfig() calls
Change-Id: Idfd11691cf579107162a730ded17c5101cd72463
2016-06-08 15:03:38 -07:00
Kunal Mehta
ddaaf59713 ApiQuerySiteInfo: Add $wgInterwikiMagic value
Bug: T131564
Change-Id: Ia7c1e944c0f65d8b1b940388aceb1f0f89005dc6
2016-06-08 15:02:39 -07:00
Brad Jorsch
a932d0c429 API: Handle shorthand "all groups" configuration in ApiQuerySiteInfo
In $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, and
$wgGroupsRemoveFromSelf, boolean true in place of an array of groups to
allow adding/removing is shorthand for "all groups". Handle this
appropriately in action=query&meta=siteinfo&siprop=usergroups.

Bug: T135467
Change-Id: I6ae61ef14ac7932e3369155c56bad60a9d72060d
2016-05-19 18:53:57 +00:00
Bartosz Dziewoński
c57fe1c4a8 Refactor upload dialog to make it configurable
This aims to solve all the problems and fulfill all the use cases.
It allows the dialog to be configured for Wikimedia Commons without
hardcoding anything, and it should be flexible enough for third-party
use. The default configuration should be sane for any wiki.

The file upload dialog can be configured using $wgUploadDialog.
See DefaultSettings.php for documentation. Example configuration for
Wikimedia Commons: Id56370e2334c8fe34e88180356232b48c244b7c4.

Configuration is loaded using ResourceLoaderUploadDialogModule for
local uploads or using ApiQuerySiteinfo (action=query&meta=siteinfo)
for uploads to a foreign wiki. Custom localisation messages may be
loaded using action=query&meta=allmessages.

Renamed messages:
  upload-form-label-own-work-message-local       -> upload-form-label-own-work-message-generic-local
  upload-form-label-not-own-work-message-local   -> upload-form-label-not-own-work-message-generic-local
  upload-form-label-not-own-work-local-local     -> upload-form-label-not-own-work-local-generic-local
  upload-form-label-own-work-message-default     -> upload-form-label-own-work-message-generic-foreign
  upload-form-label-not-own-work-message-default -> upload-form-label-not-own-work-message-generic-foreign
  upload-form-label-not-own-work-local-default   -> upload-form-label-not-own-work-local-generic-foreign

Deleted messages, moved to WikimediaMessages in Id2977e19330aeaf854157d4355cd17e5dc72f16a:
  upload-form-label-own-work-message-shared
  upload-form-label-not-own-work-message-shared
  upload-form-label-not-own-work-local-shared

Bug: T118097
Bug: T120998
Bug: T121632
Bug: T121633
Bug: T127895
Change-Id: I3017b8f09c27625deb7a92d6f667895b71cc0637
2016-05-16 21:14:58 +02:00
Siebrand Mazeland
33ba3bea02 Use Elvis operator where possible in API
Change-Id: I0a26c04cf2ded2c1bd74d8dabd131ae8e20117f3
2016-03-08 16:10:23 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Max Semenik
796711e0c4 Kill vestiges of SVN times
Change-Id: Ib80c71ea93479eb326ac5afea295d4608f92babe
2016-01-30 01:32:36 -08:00
georggi
7c3e47f5af ApiSiteInfo: Added a way to check if uploads are enabled
Added new property 'uploadsenabled' to be able to check if
uploads are enabled

Bug: T72075
Change-Id: I4bf7040a953e98816d6fffdbdeeec1e56035b28a
2015-12-09 19:07:38 +02:00
Brad Jorsch
72152a7ffc API: Allow querying central user info
meta=siteinfo gets a list of all configured central ID lookup providers
and which one is being used as the default, while meta=userinfo,
list=users, and list=allusers get the ability to return the IDs and
attachment status.

Change-Id: Iea15b6c22baac79b3f8ca6df0e20a6a4299507d2
2015-12-02 22:32:34 +00:00
Reedy
32ff1f4c47 Remove various unused variables
Change-Id: I4b1b20b4126735cb32a80e473fe48d523bcb24d1
2015-11-07 21:22:17 +00:00
Reedy
9335469cf3 Fix casing of function calls in API
Change-Id: I44b343568e5713118c41f29a73e112162dd3e635
2015-11-07 21:10:23 +00:00
Brad Jorsch
6f0923174c API: Be consistent in siteinfo showhooks output
This was originally made 'BCarray' to avoid breaking BC, but in this
case the nonstandard output is so rare it's probably best to just be
internally consistent.

Bug: T117022
Change-Id: I501c415f6170383c163110b00e54ac88c3dfec89
2015-10-29 18:21:17 +00:00
Perside Rosalie
6ba942258a Changed paths to package dependency file
Paths to ./composer.lock is changed to ./vendor/composer/installed.json
and dependency information now is read from the installed.json file.
A new ComposerInstalled class has been declared and uses the class now
to access the getInstalledDependencies() method to read data

Bug: T106247
Change-Id: Ic216577bb19b4fc5832ba003fcbbe9195d707b41
2015-10-26 15:58:03 +00:00
csteipp
59b627b0b7 SECURITY: API: Improve validation in chunked uploading
This fixes a few shortcomings in the chunked uploader:
* Raises an error if offset + chunksize > filesize.
* Enforces a minimum chunk size for non-final chunks.
* Refuses additional chunks after seeing a final chunk.
* Status of a chunked upload in progress is now available with
  'checkstatus'.

Bug: T91203
Bug: T91205
Change-Id: I2262db1bc8460616b069c564475d2e4148001768
2015-10-16 14:10:44 -07:00
umherirrender
f92f399257 API: Use message-per-value for apihelp-query+siteinfo-param-prop
Use message-per-value for message
apihelp-query+siteinfo-param-prop to allow smaller strings
for translation.
Each prop in a message also will show up a new parameter on the help
page without the adjust of the translation (but than in english instead
of fully skip it).

Change-Id: I458fddcaef1cc96656a87375eff9707c8ba0db94
2015-08-06 09:51:00 +02:00
This, that and the other
f0d6c2bf9f Restore namespace-number keys in APIQuerySiteinfo siprop=namespaces
Per discussion at the task.

Bug: T102645
Change-Id: Ic40f7fa3f5612b3d994cc01bcd0929545576041d
2015-06-20 22:24:31 +10:00
Brad Jorsch
295d35a9d4 API: Add some BCarray into ApiQuerySiteinfo
The main change is that siprop=namespaces will output an array instead
of a numerically-keyed object with formatversion=2.

Various other properties also got the same treatment, but in those cases
the intention was always array and possible non-array output was due to
array_unique or odd indexes in config variables.

Bug: T102645
Change-Id: I486131ac0d6763c3fe40fa45bcee472fe1b46fd6
2015-06-16 12:55:11 -04:00
Brad Jorsch
589ac1ad18 ApiQuerySiteInfo: Add invalidusernamechars
Since T98757 is talking about changing this (whether by default or not),
we should probably make it accessible via the API.

Change-Id: I8cd08b214171866208a65181f772de9f2e315cd9
2015-05-12 16:40:04 -04:00
RobinHood70
15ecc5a93a Update getHelpUrls() for reworked mw.org API pages
Community members restructured the mediawiki.org API pages, e.g.
the meta allmessages query submodule is no longer in the catch-all
https://www.mediawiki.org/wiki/API:Meta?oldid=1408361#allmessages_.2F_am
but its own https://www.mediawiki.org/wiki/API:Allmessages

The links in the generated API help, e.g.
https://www.mediawiki.org/wiki/Special:ApiHelp/query+allmessages,  are no
correct. They're not 404s but they don't take you directly to the
relevant page.

This patch set fixes the getHelpUrls() URLs (and does nothing else).
I tested them all.

Thanks RobinHood70!

Change-Id: Icea94abdd22d1ad468172642a21641e7c5ce2046
2015-05-04 08:15:54 +00:00
Brad Jorsch
beab6b009e Change API result data structure to be cleaner in new formats
Nothing in this patch should result in changed output for format=json or
format=php except as noted in RELEASE-NOTES-1.25, and changed output for
format=xml should be similar or cosmetic. However, other code accessing
the result data directly may need to be updated.

Bug: T87053
Bug: T12887
Change-Id: I3500708965cb8869b5aed1543381aad208dadd13
2015-04-20 17:49:37 -04:00
jenkins-bot
4fa0240228 Merge "API: Overhaul ApiResult, make format=xml not throw, and add json formatversion" 2015-04-16 01:05:51 +00:00
Brad Jorsch
1c57794e37 API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.

ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.

So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
  arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
  Formatters are responsible for stripping it if necessary. "raw mode"
  is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
  question, and so on.
* New class for formatting warnings and errors using i18n messages, and
  support for multiple errors and a more machine-readable format for
  warnings. For the moment, though, the actual output will not be changing
  yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
  between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
  modules currently returning booleans will need to use
  ApiResult::META_BC_BOOLS to preserve their current output.

Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.

Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2015-04-10 16:57:15 -04:00
Alex Monk
89f2f72470 Fix ApiQuerySiteInfo with siprop=rightsinfo to not die if your wgRightsPage is null
Follows-up I2b36b7a3

Change-Id: I7d76cd48021a0097ce5e11f4ad4100cb85ee5ad0
2015-04-06 18:31:51 +01:00
Kunal Mehta
06bfb654ab Expose installed libraries in action=query&meta=siteinfo
Bug: T89385
Change-Id: I4256f4d9858c09c042f649b7e701189acf85aedd
2015-02-12 23:25:19 +00:00
umherirrender
8d47b4f373 Output wikiid/api in meta=siteinfo only when non-empty
When using interwiki data from the database the value for iw_wikiid and
iw_api maybe empty strings, because the database does not allow NULL
here.
Suppress the output of the attribute in that case, because there are not
useful.
This should not break clients, because using .cdb (like WMF wikis)
already missing these attributes in the result.

Change-Id: I60b97b4b58fdeaf699951544d418e5dc06e3830a
2015-01-30 20:12:33 +01:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Arlo Breault
f9c50bd7f1 Expose legaltitlechars through the API
Bug: 47651
Change-Id: I79fdd698e6df75b1823b0d2d150db68e862c640f
2014-11-13 10:17:10 -08:00
Brad Jorsch
f62bc7536e API: Fix access on getExamplesMessages
ApiBase declares it protected, but for some reason I had made it public
in all subclasses.

Change-Id: I8a50d4f47e66c7f09137968d3941dc5cdc1d28e4
2014-10-29 11:15:27 -04:00
jenkins-bot
30cc068774 Merge "API: Internationalize all remaining core API modules" 2014-10-20 21:41:19 +00:00
Brad Jorsch
ad225f501c API: Internationalize all remaining core API modules
This also adds some new ApiBase::PARAM_* constants to generate more
helpful help, and a method to override the default description message
for the use of ApiDisabled and ApiQueryDisabled.

Bug: 71638
Change-Id: Ic0c3d232e0498d58a043037e2e0c6f0b1c3edad3
2014-10-20 16:56:35 -04:00
Chad Horohoe
90d90dad6e Remove hitcounters and associated code
The hitcounter implementation in MediaWiki is flawed
and needs removal. For proper metrics, it is suggested to use
something like Piwik or Google Analytics.

RFC: https://www.mediawiki.org/wiki/Requests_for_comment/Removing_hit_counters_from_MediaWiki_core
Change-Id: I0e5006a7e8a09c800f8fa4effa9399e8afdd7a57
2014-10-20 13:01:55 -07:00
daniel
4f0b2f4241 Allow callback functions for creating SpecialPages.
This enables factory functions to be registered for special
pages, as an alterative to giving a class name. This follows the
same rationale as Ieb85493a7765, which introduced factory functions
for API modules.

Change-Id: Ia2107dc5af7869187ba5dc02a1bef46d6801e138
2014-09-18 14:47:34 +02:00
Bartosz Dziewoński
49edf82e05 ApiQuerySiteinfo: Use proper localised skin display names if available
Based on the code in Preferences::generateSkinOptions(). This should
probably be turned into a helper method one day…

Bug: 48953
Change-Id: Ib85a783bd19de8a59e7b81a4203a05b786e67772
2014-09-15 13:03:01 +00:00
jenkins-bot
8959a09b8f Merge "Prevent "Notice: Undefined index" in ApiQuerySiteinfo" 2014-09-15 03:13:39 +00:00
Jackmcbarn
d01b01c6cc Don't list nonexistent groups as addable or removable
You can't add or remove a group that doesn't exist, so don't claim that
it's possible on Special:ListGroupRights or the API.

Change-Id: I02d3f00142ca1cb0cdcbf30e79fecb3c96e96405
2014-09-14 22:48:01 -04:00
Marius Hoch
01ca947a06 Prevent "Notice: Undefined index" in ApiQuerySiteinfo
$row['iw_trans'] wont be set if $wgInterwikiCache is used.

Change-Id: Iea1041b9c699667c251442ed7f4c95e3ba550e7c
2014-09-15 04:33:16 +02:00
umherirrender
589f9ecbb7 Add missing space to autodoc of meta=siteinfo&siprop=languages
Change-Id: I56ba3b3282ea747b47016558513f96ca597e28d7
2014-09-01 05:05:20 +00:00
jenkins-bot
914e7e2b5d Merge "Indicate the actual version of HHVM in use" 2014-08-27 22:42:12 +00:00