jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
api.QueryGenerator._add_slots: Do not add slots if using deprecated parameters

Usage of slots with deprecated parameters is forbidden by API.

Bug: T205210
Change-Id: I9e30e285d5928430e8ffe77fd628ddf75bf7c53c
---
M pywikibot/data/api.py
1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 68ea978..2c801f9 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2716,18 +2716,40 @@
if self.site.mw_version < '1.32':
return
request = self.request
+ # If using any deprecated_params, do not add slots. Usage of
+ # these parameters together with slots is forbidden and the user will
+ # get an API warning anyway.
props = request.get('prop')
if props:
if 'revisions' in props:
- request['rvslots'] = '*'
+ deprecated_params = {
+ 'rvexpandtemplates', 'rvparse', 'rvdiffto', 'rvdifftotext',
+ 'rvdifftotextpst', 'rvcontentformat', 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['rvslots'] = '*'
if 'deletedrevisions' in props:
- request['drvslots'] = '*'
+ deprecated_params = {
+ 'drvexpandtemplates', 'drvparse', 'drvdiffto',
+ 'drvdifftotext', 'drvdifftotextpst', 'drvcontentformat',
+ 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['drvslots'] = '*'
lists = request.get('list')
if lists:
if 'allrevisions' in lists:
- request['arvslots'] = '*'
- if 'deletedrevisions' in lists:
- request['adrslots'] = '*'
+ deprecated_params = {
+ 'arvexpandtemplates', 'arvparse', 'arvdiffto',
+ 'arvdifftotext', 'arvdifftotextpst', 'arvcontentformat',
+ 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['arvslots'] = '*'
+ if 'alldeletedrevisions' in lists:
+ deprecated_params = {
+ 'adrexpandtemplates', 'adrparse', 'adrdiffto',
+ 'adrdifftotext', 'adrdifftotextpst', 'adrcontentformat',
+ 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['adrslots'] = '*'

def set_query_increment(self, value):
"""Set the maximum number of items to be retrieved per API query.

To view, visit change 462197. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e30e285d5928430e8ffe77fd628ddf75bf7c53c
Gerrit-Change-Number: 462197
Gerrit-PatchSet: 4
Gerrit-Owner: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)