Anonymous user
Module:Protection banner: Difference between revisions
Fix Protection:makeProtectionCategory for office-protected pages. For these, the reason needs to be the no. 1 priority, not just higher priority than the namespace.
Enwikipedia>Mr. Stradivarius (remove parameter methods specific to individual reasons - the logic has been moved to Moudle:Protection banner/config) |
Enwikipedia>Mr. Stradivarius (Fix Protection:makeProtectionCategory for office-protected pages. For these, the reason needs to be the no. 1 priority, not just higher priority than the namespace.) |
||
Line 51:
display
)
end
local function toTableEnd(t, pos)
-- Sends the value at position pos to the end of array t, and shifts the
-- other items down accordingly.
return table.insert(t, table.remove(t, pos))
end
Line 185 ⟶ 191:
}
--[[
-- The old protection templates used an ad-hoc protection category system,
-- with some templates prioritising namespaces in their categories, and
--
-- we use the config table cfg.reasonsWithNamespacePriority to set the
-- reasons for which namespaces have priority over protection reason.
-- If we are dealing with one of those reasons, move the namespace table to
-- the end of the order table, i.e. give it highest priority. If not, the
-- reason should have highest priority, so move that to the end of the table
-- instead.
--]]
if self.reason and cfg.reasonsWithNamespacePriority[self.reason] then
-- table.insert(order, 3, table.remove(order, 2))
toTableEnd(order, 2)
else
toTableEnd(order, 3)
end
|