Module:Navbar: Difference between revisions
handle expensive parser function limit without killing the box
m>Dragons flight m (Changed protection level of Module:Navbar: Highly visible template or Lua module ([Edit=Block all non-admin users] (indefinite) [Move=Block all non-admin users] (indefinite))) |
m>Dragons flight (handle expensive parser function limit without killing the box) |
||
Line 17: | Line 17: | ||
return tostring(span) | return tostring(span) | ||
end | |||
function getTitle( pageName ) | |||
pageName = trim( pageName ); | |||
if mw.ustring.sub(pageName, 1, 1) == ':' then | |||
return mw.title.new( mw.ustring.sub(pageName, 2) ); | |||
else | |||
return mw.title.new( pageName, 'Template' ); | |||
end | |||
end | end | ||
Line 24: | Line 33: | ||
end | end | ||
local title; | local good, title; | ||
good, title = pcall( getTitle, args[1] ); | |||
if | if not good then | ||
return error('Expensive parser function limit exceeded'); | |||
end | |||
end | |||
if not title then | if not title then | ||
return error('Page does not exist') | return error('Page does not exist') |