Page MenuHomePhabricator

ProofreadPage: permission denied error on editing quality status via code without changing user
Closed, ResolvedPublic

Description

I am trying to work on https://ta.wikisource.org with python API.

This tamil wikisource has proofread extension and quality status buttons.

I use the following code to click quality status buttons.

import pywikibot
from pywikibot import proofreadpage

site = pywikibot.Site('ta','wikisource')
page = pywikibot.Page(site, u"Page:"<pagename>)
text = page.text

pa = proofreadpage.ProofreadPage(page)
pa.text = pa.text.replace('level="1"','level="3"')
pa.save(summary="demo")

When I ran the above code now,

It gives the following error.

Run the following code.

it shows the following error.

ERROR: editpage: unknown failure reason {u'edit': {u'result': u'Failure', u'notallowed': u'\u0b87\u0ba8\u0bcd\u0ba4 \u0baa\u0b95\u0bcd\u0b95\u0ba4\u0bcd\u0ba4\u0bbf\u0ba9\u0bcd \u0bae\u0bc6\u0baf\u0bcd\u0baa\u0bcd\u0baa\u0bc1 \u0baa\u0bbe\u0bb0\u0bcd\u0b95\u0bcd\u0b95\u0bc1\u0bae\u0bcd \u0ba8\u0bbf\u0bb2\u0bc8\u0baf\u0bc8 \u0bae\u0bbe\u0bb1\u0bcd\u0bb1 \u0ba4\u0b99\u0bcd\u0b95\u0bb3\u0bc1\u0b95\u0bcd\u0b95\u0bc1 \u0b89\u0bb0\u0bbf\u0bae\u0bc8 \u0b87\u0bb2\u0bcd\u0bb2\u0bc8'}}
WARNING: Page [[Page:x?r?nxc? mlrx.pdf/100]] not saved

on running on jupyter,

ERROR: editpage: unknown failure reason {'edit': {'result': 'Failure', 'notallowed': 'you dont have permissions to change the proof read status of this page'}}

The above error happens for my account and my friend account with sysop permission.

But we can manually change the proof read page quality status.

What may be the reason?

Help to solve this.

Thanks.

Event Timeline

Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 9 2016, 1:19 PM
Tshrinivasan updated the task description. (Show Details)May 9 2016, 1:20 PM

sample file for testing.

Restricted Application added a subscriber: pywikibot-bugs-list. · View Herald TranscriptMay 9 2016, 5:59 PM
Mpaa added a subscriber: Mpaa.EditedMay 9 2016, 8:44 PM

You need to change also the user.
Probably the extension is checking that you are not who is stated as user in the page header.

Mpaa updated the task description. (Show Details)May 9 2016, 8:44 PM
Mpaa renamed this task from How to solve Permission denied error on editing quality status via code ? to ProofreadPage: permission denied error on editing quality status via code.May 9 2016, 9:05 PM
Mpaa closed this task as Resolved.

As a sidenote, in ProofreadPage, a sanity check on users was never enforced as it is safer to rely on the Extension itself.

jayvdb added a subscriber: jayvdb.May 10 2016, 12:41 AM

That Proofread Page extension error message could be more helpful.

I'd like to understand this better since this error is happening via PAWS, and it handles authentication automatically for you. Can someone tell me what you mean by 'You need to change also the user.'? PAWS automatically sends OAuth tokens for the current user...

Tpt added a subscriber: Tpt.May 10 2016, 9:30 AM

Can someone tell me what you mean by 'You need to change also the user.'?

This user has no link with MediaWiki authentification. It's the "user" Y that is set in the <pagequality level="X" user="Y"/> tag included in the page content and, sadly, ProofreadPage does not fill this "user" automatically for API edits.

Aklapper renamed this task from ProofreadPage: permission denied error on editing quality status via code to ProofreadPage: permission denied error on editing quality status via code for user without MediaWiki authentication.May 10 2016, 9:56 AM
Aklapper updated the task description. (Show Details)

I'm still vaguely confused. Can someone tell me what should take the place of:

pa.text = pa.text.replace('level="1"','level="3"')

to work?

jayvdb reopened this task as Open.May 10 2016, 11:16 AM
Mpaa added a comment.EditedMay 10 2016, 7:44 PM

It should change "level" and, if needed "user" as well.

Quoted from: https://en.wikisource.org/wiki/User_talk:Tpt#Proofread_extension_logic

About level change the rules are:
    If the level changes you should set the user to be your bot.
    If the level does not change you should keep the existing user.
    If the level change to 3 to 4 the user should change (e.g. the person that set the level to 4 should be different than the one that set it to 3).

So in pywikibot there could a check if this logic is respected, otherwise the user could/should be warned.
I chose not to implement it as there was anyhow an error message thrown by the extension.

If you think it would be useful, I can try to add it.

I am not sure the title reflects the issue (or more a enhancement):
"via code for user without MediaWiki authentication"

I do not understand why MediaWiki authentication is mentioned here.

Learnt that we have to change the user="" and pagequality level=""

on the proofread pages to change the status via any program.

Did it and it worked well.

Thanks for all.

Here is the code.
https://github.com/tshrinivasan/tools-for-wiki/blob/master/proof-read-quality-status-changer/proof-read-status-changer-to-yellow.py#L101

@Mpaa it will be nice, if you update pywikibot to check for the conditions you mentioned.

Thanks all.

Tshrinivasan closed this task as Resolved.May 19 2016, 5:50 PM
Tshrinivasan triaged this task as Medium priority.
jayvdb renamed this task from ProofreadPage: permission denied error on editing quality status via code for user without MediaWiki authentication to ProofreadPage: permission denied error on editing quality status via code without changing user.May 20 2016, 1:33 PM
GOIII moved this task from Backlog to Done on the ProofreadPage board.Jun 12 2016, 4:03 AM