Module:Lua banner: Difference between revisions

protect against "mw.title.new()" returns "nil"
 
m Fix syntax issue
 
(3 intermediate revisions by the same user not shown)
Line 111: Line 111:
if module ~= "WP:libraryUtil" then
if module ~= "WP:libraryUtil" then
local moduleTitle = mw.title.new(module)
local moduleTitle = mw.title.new(module)
local moduleProt = moduleTitle and moduleTitle.protectionLevels["edit"][1]
local editLevel = moduleTitle.protectionLevels["edit"]
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
local moduleProt = 0
if moduleProt < currentProt then
if editLevel == nil then moduleProt = 0 else
cats[#cats + 1] = protCatName
moduleProt = moduleTitle and moduleTitle.protectionLevels["edit"][1]
break
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt < currentProt then
cats[#cats + 1] = protCatName
break
end
end
end
end
end