Forum:Call for testing: ImageRenamerBot

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to: navigation, search
Forums: Yew Grove > Call for testing: ImageRenamerBot
Archive
This page or section is an archive.
Please do not edit the contents of this page.
This thread was archived on 26 November 2011 by Thebrains222.

At Joey's request, I have made a bot to rename images on a wiki.

He allowed me access to his test wiki for the purpose of, well, testing the API and the bot. However, I have no idea how well it works right now. It seems to work well, but hasn't seen much usage. I would like to see some more testing done on [[w:c:joeytje50:Test wiki|Joey's wiki]].

tl;dr: add references to images on the wiki, upload more files if you want; blank the Requests section of [[w:c:joeytje50:User:A proofreader/Request test|this page]], then add lines of the form *File:X|File:Y to it and save the page, then wait 3 minutes.

 a proofreader ▸ 

15:12, November 12, 2011 (UTC)

Specifications for testing

  1. The bot is written in Java.
  2. The bot has a configuration file, at $HOME/.imgmovebot.conf, containing variables to do the image renaming work.
    • Wiki=joeytje50.wikia.com (this is the domain of the wiki to work on)
    • RequestPage=User:A proofreader/Request test (this is the name of the request page under the wiki's domain)
    • LastRequestRevision=5643 (this is a variable that gets set by the bot; when transferring the bot to another user to run, this should be preserved to avoid reprocessing the entire list and throwing errors everywhere due to inexistent source images)
    • RunInterval=180 (this is the number of seconds to wait between reads of the RequestPage)
    • LoginName=A proofreader
    • LoginPassword=NotWritingItHere
  3. Every RunInterval (180) seconds, using the MediaWiki API 'Get Page History', the bot reads its RequestPage ([[w:c:joeytje50:User:A proofreader/Request test|this one]]) and notes the edits that have been made to it after the LastRequestRevision.
  4. Each line of the text of the RequestPage as of each revision is parsed for something resembling *File:X|File:Y. This means that requesters must blank the page and add their requests then click Save. They may leave a set of instructions at the top of the page for the next requester, which will be ignored by the bot.
  5. For each valid request found in the revisions, using the MediaWiki API 'Move Page', the bot attempts to move the image. If it fails, an error template is queued for addition to the talk page of the requester (see below). Otherwise, references to the file's old name are edited to the new name in all of the pages formerly using it, using the MediaWiki API 'Get Image Usage'. [[File:X|... and [[File:X]] are assumed to be image references in wikitext for this transformation. The new text is dumped on each page using the MediaWiki API 'Edit Page'.
  6. After a revision is processed, the name of the requester is determined by the revision's user field, and the bot dumps {{ImageMoveError | source=File:X | target=File:Y | errortext=Error information}} on that user's talk page for every error that occurred while attempting 'Move Page', if applicable. It then dumps {{ImageMoveSuccess|SUCCESSCOUNT}} to signify how many images were moved correctly, if applicable. Templates are used so that they can be modified (e.g. reworded) more easily.
 a proofreader ▸ 

15:12, November 12, 2011 (UTC)

Specifications for actual use

  1. As above, but the configuration changes.
    • Wiki=runescape.wikia.com
    • RequestPage=TO BE DISCUSSED
    • RunInterval=3600
    • LoginName=TO BE DISCUSSED
    • LoginPassword=TO BE DETERMINED BY WHOEVER CREATES THE ACCOUNT
  2. Templates ImageMoveError and ImageMoveSuccess would need to be made.
  3. The bot's request page would need to be made.
  4. The bot's request page would need to be protected using Special:AbuseFilter so that only custodians can write to it.
  5. The bot would need to be given the custodian right in order to move pages in the File namespace.
  6. Documentation and code would go to User:LoginName.
 a proofreader ▸ 

15:12, November 12, 2011 (UTC)

Discussion

Bump - Seriously, I can't understand this stuff, so I'll bump this and defer to people who can. --LiquidTalk 03:29, November 16, 2011 (UTC)

{{Vote|q}} - Why would only custodians have access to it? Why not allow everyone? svco4bY.png3Gf5N2F.png 03:57, November 16, 2011 (UTC)

To prevent a kind of security hole known as privilege escalation. If ever there is a part of the code that accidentally allows, via URL injection or otherwise, a non-custodian to perform any other action requiring the privilege, then all users are allowed to effectively act as a custodian until it's fixed. By restricting the page to custodians, this security hole is prevented, and only the people who can rename files on their own accounts in the first place can request a bulk rename for speed.  a proofreader ▸  04:02, November 16, 2011 (UTC)
Fair enough, and answered my 2nd question I neglected to ask. :P Just don't forget to let admins edit it too! D: svco4bY.png3Gf5N2F.png 04:08, November 16, 2011 (UTC)
That would not be up to me; it would be up to the creator of the AbuseFilter. Only sysops have the ability to make those, I believe. But yeah, admins need to be able to add to the request list too.  a proofreader ▸  04:12, November 16, 2011 (UTC)
That can be done once you tell me what the page is. Suppa chuppa Talk 04:13, November 16, 2011 (UTC)
All right. The page is not made yet because there's no consensus yet for the bot, but if there is, I'll leave a message on your talk page about it.  a proofreader ▸  04:16, November 16, 2011 (UTC)
Pretty sure Forum:Bot specification: PNGOptimisationBot established any sort of consensus necessary for the bot, so you should be able to make it. All that's really left are the minor details about implementation, at least as far as I know. Suppa chuppa Talk 04:17, November 16, 2011 (UTC)
My bad, got confused. Yeah, you'll need consensus on this first. Suppa chuppa Talk 04:21, November 16, 2011 (UTC)

{{Vote|c}} - An issue uncovered in testing will need to be fixed: image references are edited, but not wikilink references.

 a proofreader ▸ 

22:13, November 16, 2011 (UTC)

i.e references of the form [[:File:X]]? --Henneyj 22:36, November 16, 2011 (UTC)
Exactly. The references I get are only from Image Usage in the API as well, so I need to also consider Special:WhatLinksHere.  a proofreader ▸  22:54, November 16, 2011 (UTC)
The issue seems to have been fixed. Some more testing is needed to confirm this.  a proofreader ▸  23:41, November 16, 2011 (UTC)

{{Vote|c}} Possible privilege problem - Another issue I thought about during testing is protected pages. If a page referencing an image is editable by only certain groups of users, the bot would need increasing amounts of privileges, up to and including sysop, to do its task completely. Alternatively:

  • a sysop may be asked to temporarily give ImageRenamerBot sysop privileges until the rename is done, if an image is used on a lot of protected pages; or
  • a sysop may manually fix the remaining redlinks and broken image references arising from his/her own rename or a custodian's rename, giving the bot no special privileges.
 a proofreader ▸ 

22:13, November 16, 2011 (UTC)

Maybe you could make your bot put any requests for editing protected pages on RS:AR mentioning the old and new filename, giving a list of all pages it couldn't edit, and then let admins move those filelinks manually. JOEYTJE50TALKpull my finger 09:26, November 17, 2011 (UTC)
Very good idea! I didn't consider that. However I would require more testing for that, to know how the Wiki.java framework reacts to editing a protected page. (Which exception is thrown, etc.) [Edit conflicted, putting this section in its rightful place in the thread]  a proofreader ▸  09:30, November 17, 2011 (UTC)
I've created [[w:c:joeytje50:Project:Administrator requests]] for testing that if you want, btw JOEYTJE50TALKpull my finger 09:28, November 17, 2011 (UTC)

{{Vote|c}} -

Okay, this is much more difficult than I anticipated. Special:WhatLinksHere and the MediaWiki API Image Usage give me the pages that use a template if a template contains an image, not the template. So it ends up hitting the test page, editing nothing, then moving on to the next page to rename the file in. The file reference in the template was completely glossed over. This is not even considering the templates that go like {{TemplateName|Examplefile}} or {{TemplateName|Examplefile.png}} and expand it to a reference to File:Examplefile.png, which I would need to put special knowledge of into ImageRenamerBot. I would need a list of all templates that can expand file references. Such a list may already be made, but I have no idea.  a proofreader ▸  10:01, November 17, 2011 (UTC)

Scratch that, it was because the template had <includeonly>. If that tag is removed, the bot can edit the image name inside the page AND the template. Progress has been made! Also, if a template invocation {{}} using a file name without the File:, such as Cake.png, adds the resulting page to Special:WhatLinksHere for the image, the bot can now edit the Cake.png in the page, despite it being in a template invocation {{}}. This will be useful for Template:Infobox item, among others. More testing is needed for that.

 a proofreader ▸ 

07:55, November 18, 2011 (UTC)

Notice - Any more testing needed? Otherwise this will be closed soon. 222 talk 11:24, November 25, 2011 (UTC)

I think the bot won't need that much more testing; any remaining bugs can get ironed out after the implementation. Most of the egregious bugs are gone, though, like replacing &lt; and &gt; with < and > while editing image references in pages, and not finding references to File:Example.png if they are encoded as [[:File:Example.png]].  a proofreader ▸  20:44, November 25, 2011 (UTC)

Closed - Testing phase complete. 222 talk 10:40, November 26, 2011 (UTC)