[Mediawiki-api-announce] BREAKING CHANGE: action=protect to allow multiple expiries; output format, error messages changed

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Mediawiki-api-announce] BREAKING CHANGE: action=protect to allow multiple expiries; output format, error messages changed

Roan Kattouw
As of r41652 [1], action=protect allows the user to specify different
expiry timestamps for different protections, something the UI has
supported for a while.

To support this, the expiry parameter has changed to accept multiple
values, and even duplicate values. The first expiry timestamp will apply
to the first protection, the second to the second, etc. The number of
values in the expiry parameter must be equal to the number of values in
the protections parameter, or an error will occur (for details on the
new error message, see [2]). To preserve backwards compatibility,
setting a single value in the expiry parameter is always allowed: in
that case, all specified protections will have the same expiry timestamp.

Example requests:
api.php?action=protect&token=123ABC&title=Foo&protections=edit=sysop|move=sysop&expiry=infinite
  Will add the protections edit=sysop and move=sysop, both of which will
never expire
api.php?action=protect&token=123ABC&title=Foo&protections=edit=autoconfirmed|move=sysop&expiry=20081104000000|infinite
  Will add the protections edit=autoconfirmed and move=sysop; the first
will expire on November 4, 2008, the second will never expire
api.php?action=protect&token=123ABC&title=Foo&protections=edit=autoconfirmed|move=sysop|read=user&expiry=20081104000000|infinite
  Will cause an error, because 2 expiries were given for 3 protections
api.php?action=protect&token=123ABC&title=Foo&protections=edit=autoconfirmed|move=sysop&expiry=20081104000000|infinite|infinite
  Will cause an error, because 3 expiries were given for 2 protections

The output format has also been changed, so multiple expiry times can be
listed.

Old format:
<protect title="Foo" reason="" expiry="infinite">
  <protections edit="sysop" move="sysop" />
</protect>

New format:
<protect title="Foo" reason="">
  <protections>
    <protection edit="sysop" expiry="infinite" />
    <protection move="sysop" expiry="infinite" />
  </protections>
</protect>

Additionally, the invalidexpiry and pastexpiry error messages have been
changed to mention the expiry timestamp they're referring to. In the new
messages, EXPIRY is replaced by the faulty expiry timestamp.

Old messages:
* code: invalidexpiry
** info: Invalid expiry time
* code: pastexpiry
** info: Expiry time is in the past

New messages:
* code: invalidexpiry
** info: Invalid expiry time ``EXPIRY''
* code: pastexpiry
** info: Expiry time ``EXPIRY'' is in the past

For the newly added error message toofewexpiries or more information
about action=protect, see the documentation at www.mediawiki.org [2].

[1] http://svn.wikimedia.org/viewvc/mediawiki/?view=rev&rev=41652
[2] http://www.mediawiki.org/wiki/API:Edit_-_Protect

_______________________________________________
Mediawiki-api-announce mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api