Page MenuHomePhabricator

Clean up files uploaded with 'null' as the author
Closed, ResolvedPublic

Description

Reminder to myself to clean up files affected by T121097 and uploaded to Commons with 'null' as the author, after that bug is fixed and the fix deployed.

https://commons.wikimedia.org/w/index.php?title=Special:WhatLinksHere/User:Null&namespace=6&limit=500

Event Timeline

matmarex claimed this task.
matmarex raised the priority of this task from to Medium.
matmarex updated the task description. (Show Details)
matmarex added a project: Commons.
matmarex subscribed.

I have corrected the problematic uploads on Commons: https://commons.wikimedia.org/w/index.php?title=Special:Contributions/Matma_Rex&dir=prev&offset=20160119213820&limit=250&target=Matma+Rex (exactly 250, as it happens).

Seven more files (https://commons.wikimedia.org/w/index.php?title=Special:WhatLinksHere/User:Null&namespace=6) appear to be affected by some similar bugs in other tools. They're all pretty old though.

# coding: utf-8
require 'sunflower'

s = Sunflower.new 'commons'
#s.login 'Matma Rex', gets.strip
s.summary = 'fixing "null" author for cross-wiki uploads, see [[phab:T121097]]'

l = s.make_list 'whatlinkshere', 'User:Null'
puts l.length

l.each do |t|
	next unless t.start_with? 'File:'
	logs = s.API action: 'query', list: 'logevents', letype: 'upload', letitle: t
	next if logs['query']['logevents'].empty?
	if logs['query']['logevents'][0]['comment'].start_with? 'Cross-wiki upload from'
		author = logs['query']['logevents'][0]['user']
		next if !author || author.empty?
		page = s.page t
		next unless page.text.sub! '[[User:null|null]]', "[[User:#{author}|#{author}]]"
		if page.save
			puts "Fixed: #{t} -> #{author}"
		end
	end
end