Module:Article history: Difference between revisions

Content deleted Content added
use correct variable for Action:getParameter
add more Action class errors
Line 288:
 
-- Set the ID
do
if not data.code then
local codeParam = obj.cfg.actionParamPrefix .. tostring(obj.paramNum)
obj:raiseError(
obj:message('action-error-no-code', codeParamobj:getParameter('code')),
obj:message('action-error-no-code-help')
)
end
obj.id local = obj.cfg.actions[data.code] and= objmw.cfgustring.actions[upper(data.code].id)
obj.id = obj.cfg.actions[code] and obj.cfg.actions[code].id
if not obj.id then
if not obj:raiseError(.id then
obj:raiseError(
obj:message('action-error-invalid-code', data.code, obj:getParameter('code')),
obj:message(
'action-error-invalid-code-help'),
data.code,
)
obj:getParameter('code')
),
obj:message('action-error-invalid-code-help', data.code, obj:getParameter('code')),
)
end
end
 
Line 310 ⟶ 316:
 
-- Set the result ID
do
if obj.actionCfg.results[data.resultCode] then
obj.resultIdlocal resultCode = obj.actionCfg.results[data.resultCode].id
and mw.ustring.lower(data.resultCode)
else
or '_BLANK'
-- @TODO: Error
if obj.actionCfg.results[data.resultCode] then
obj.resultId = obj.actionCfg.results[resultCode].id
elseif resultCode == '_BLANK' then
obj:raiseError(
obj:message(
'action-error-blank-result',
obj.id,
obj:getParameter('resultCode')
),
obj:message('action-error-blank-result-help')
)
else
obj:raiseError(
obj:message(
'action-error-invalid-result',
data.resultCode,
obj.id,
obj:getParameter('resultCode')
),
obj:message('action-error-invalid-result-help')
)
end
end
 
Line 327 ⟶ 355:
obj.date = date
else
obj:addWarning(
-- @TODO: Error
obj:message(
'action-error-invalid-date',
data.date,
obj:getParameter('date')
),
obj:message('action-error-invalid-date-help')
)
end
else
obj:addWarning(
-- @TODO: Error
obj:message(
'action-error-no-date',
obj.paramNum,
obj:getParameter('date')
),
obj:message('action-error-no-date-help')
)
end
obj.date = obj.date or obj:message('action-date-missing')
 
-- Set the oldid
obj.oldid = tonumber(data.oldid)
if data.oldid and (not obj.oldid or not isPositiveInteger(obj.oldid)) then
obj:raiseError(
-- @TODO: Error
obj:message(
'action-error-invalid-oldid',
data.oldid,
obj:getParameter('oldid')
),
obj:message('action-error-invalid-oldid-help')
)
end