Content deleted Content added
second positional parameter may be used for "reason" |
fix error check order - this was causing script errors for invocations without currentn params and invocations where the currentn param was an invalid title |
||
Line 126:
local current = t.current
local num = t.num
local currentTitle
local subjectSpace
-- Check for invalid or missing currentn parameters▼
-- Category namespace check▼
-- This check must come first, as mw.title.new will give an error if
-- it is given invalid input.
if not current then▼
local msg = '"current%d" parameter missing;'▼
.. ' please add it or remove the "new%d" parameter'▼
msg = string.format(msg, num, num)▼
return err(msg)▼
end▼
-- Check for invalid currentn titles▼
-- This check must come before the namespace checks and the check for
-- non-existent titles, as we cannot extract the relevant data from
-- the title object if the title object does not exist.
currentTitle = mw.title.new(current)
if not currentTitle then▼
local msg = 'Invalid title detected in parameter "current' .. num .. '";'▼
.. ' check for [[Wikipedia:Page name#'▼
.. 'Technical restrictions and limitations|invalid characters]] and'▼
.. ' incorrectly formatted'▼
.. ' [[Help:Interwiki linking|interwiki prefixes]]'▼
return err(msg)▼
end▼
subjectSpace = mw.site.namespaces[currentTitle.namespace].subject.id
if subjectSpace == 14 then
local msg = '[[Template:Requested move]] is not for categories,'
Line 141 ⟶ 166:
.. ' (use [[Template:Rename media]] instead)'
return err(msg)
-- User namespace check
elseif subjectSpace == 2 then
Line 154 ⟶ 179:
return err(msg)
end
▲ -- Check for invalid or missing currentn parameters
▲ if not current then
▲ local msg = '"current%d" parameter missing;'
▲ .. ' please add it or remove the "new%d" parameter'
▲ msg = string.format(msg, num, num)
▲ return err(msg)
▲ end
▲ -- Check for invalid currentn titles
▲ if not currentTitle then
▲ local msg = 'Invalid title detected in parameter "current' .. num .. '";'
▲ .. ' check for [[Wikipedia:Page name#'
▲ .. 'Technical restrictions and limitations|invalid characters]] and'
▲ .. ' incorrectly formatted'
▲ .. ' [[Help:Interwiki linking|interwiki prefixes]]'
▲ return err(msg)
▲ end
-- Check for non-existent titles.
if not currentTitle.exists then
Line 179 ⟶ 186:
return err(msg)
end
-- Check for duplicate current titles
-- We know the id isn't zero because we have already checked for
|