Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/wikis/ageofempires/Match/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Json = Lua.import('Module:Json')
local Operator = Lua.import('Module:Operator')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchLegacyUtil = Lua.import('Module:MatchGroup/Legacy/Util')
Expand Down Expand Up @@ -131,7 +132,7 @@ function MatchLegacy._convertParameters(match2)
match[prefix .. 'flag'] = player.flag
match.extradata[prefix .. 'name'] = player.displayname
elseif opponent.type == Opponent.team then
match[prefix] = mw.ext.TeamTemplate.raw(opponent.template).page
match[prefix] = TeamTemplate.getRaw(opponent.template).page
match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
local opponentplayers = {}
for i, player in pairs(opponentmatch2players) do
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/ageofempires/MatchGroup/Input/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local Operator = Lua.import('Module:Operator')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')
Expand Down Expand Up @@ -88,7 +89,7 @@ function MatchFunctions.readOpponent(match, opponentIndex, options)
local manualPlayersInput = MatchGroupInputUtil.extractManualPlayersInput(match, opponentIndex, opponentInput)
substitutions = manualPlayersInput.substitutions
-- Change compared to commons MatchGroupInputUtil.readOpponent
local template = mw.ext.TeamTemplate.raw(opponent.template or '') or {}
local template = TeamTemplate.getRawOrNil(opponent.template or '') or {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the or '' needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamTemplate.getRawOrNil expects a non-nil string argument
we could add nil handling there instead though

opponent.players = MatchGroupInputUtil.readPlayersOfTeam(
template.page or '',
manualPlayersInput,
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/apexlegends/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Logic = Lua.import('Module:Logic')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local UpcomingMatches = Lua.import('Module:Matches Player')

local Injector = Lua.import('Module:Widget/Injector')
Expand Down Expand Up @@ -112,7 +113,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args)
end

if String.isNotEmpty(args.team2) then
lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page
lpdbData.extradata.team2 = TeamTemplate.getRaw(args.team2).page
end

return lpdbData
Expand Down
7 changes: 4 additions & 3 deletions lua/wikis/commons/Infobox/Person.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local NameOrder = Lua.import('Module:NameOrder')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local AgeCalculation = Lua.import('Module:AgeCalculation')
Expand Down Expand Up @@ -299,7 +300,7 @@ end
function Person:_setLpdbData(args, links, status, personType)
local teamLink, teamTemplate
local team = args.teamlink or args.team
local teamRaw = team and mw.ext.TeamTemplate.raw(team) or nil
local teamRaw = team and TeamTemplate.getRawOrNil(team)
if teamRaw then
teamLink = teamRaw.page
teamTemplate = teamRaw.templatename
Expand Down Expand Up @@ -343,7 +344,7 @@ function Person:_setLpdbData(args, links, status, personType)
for teamKey, otherTeam, teamIndex in Table.iter.pairsByPrefix(args, 'team', {requireIndex = false}) do
if teamIndex > 1 then
otherTeam = args[teamKey .. 'link'] or otherTeam
lpdbData.extradata[teamKey] = (mw.ext.TeamTemplate.raw(otherTeam) or {}).templatename
lpdbData.extradata[teamKey] = (TeamTemplate.getRawOrNil(otherTeam) or {}).templatename
end
end

Expand Down Expand Up @@ -546,7 +547,7 @@ function Person:_createTeam(team, link)
end
---@cast link -nil

local teamRaw = mw.ext.TeamTemplate.raw(link)
local teamRaw = TeamTemplate.getRawOrNil(link)
if teamRaw then
link, team = teamRaw.page, teamRaw.name
end
Expand Down
15 changes: 6 additions & 9 deletions lua/wikis/commons/Infobox/Team.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local Namespace = Lua.import('Module:Namespace')
local MatchTicker = Lua.import('Module:MatchTicker/Custom')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local BasicInfobox = Lua.import('Module:Infobox/Basic')
Expand Down Expand Up @@ -73,7 +74,7 @@ function Team:createInfobox()

-- Team Information
local team = args.teamtemplate or self.pagename
self.teamTemplate = mw.ext.TeamTemplate.raw(team) or {}
self.teamTemplate = TeamTemplate.getRawOrNil(team) or {}

args.imagedark = args.imagedark or args.imagedarkmode or args.image or self.teamTemplate.imagedark
args.image = args.image or self.teamTemplate.image
Expand Down Expand Up @@ -240,15 +241,11 @@ function Team:_getTeamIcon(date)
return
end

local icon = self.teamTemplate.historicaltemplate
and mw.ext.TeamTemplate.raw(self.teamTemplate.historicaltemplate, date).image
or self.teamTemplate.image
local historicalTemplateName = self.teamTemplate.historicaltemplate
and TeamTemplate.resolve(self.teamTemplate.historicaltemplate, date)
or self.teamTemplate.templatename

local iconDark = self.teamTemplate.historicaltemplate
and mw.ext.TeamTemplate.raw(self.teamTemplate.historicaltemplate, date).imagedark
or self.teamTemplate.imagedark

return icon, iconDark
return TeamTemplate.getIcon(historicalTemplateName)
end

---@param date? string
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PlayerIntroduction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Flags = Lua.import('Module:Flags')
local Logic = Lua.import('Module:Logic')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Roles = Lua.import('Module:Roles')

Expand Down Expand Up @@ -603,7 +604,7 @@ end
function PlayerIntroduction._displayTeam(team, date)
team = team:gsub('_', ' ')

local rawTeam = mw.ext.TeamTemplate.raw(team, date)
local rawTeam = TeamTemplate.getRawOrNil(team, date)
if rawTeam then
return ' [[' .. rawTeam.page .. '|' .. rawTeam.name .. ']]'
end
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PrizePool/Award/Placement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local Lua = require('Module:Lua')

local Class = Lua.import('Module:Class')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local BasePlacement = Lua.import('Module:PrizePool/Placement/Base')

Expand Down Expand Up @@ -57,7 +58,7 @@ function AwardPlacement:_getLpdbData(...)
local opponentType = opponent.opponentData.type

if opponentType == Opponent.team then
local teamTemplate = mw.ext.TeamTemplate.raw(opponent.opponentData.template) or {}
local teamTemplate = TeamTemplate.getRawOrNil(opponent.opponentData.template) or {}

participant = teamTemplate.page or ''
if self.parent.options.resolveRedirect then
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/PrizePool/Placement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Ordinal = Lua.import('Module:Ordinal')
local PlacementInfo = Lua.import('Module:Placement')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

---@class PrizePoolPlacement: BasePlacement
---@field opponents BasePlacementOpponent[]
Expand Down Expand Up @@ -223,7 +224,7 @@ function Placement:_getLpdbData(...)
local opponentType = opponent.opponentData.type

if opponentType == Opponent.team then
local teamTemplate = mw.ext.TeamTemplate.raw(opponent.opponentData.template) or {}
local teamTemplate = TeamTemplate.getRawOrNil(opponent.opponentData.template) or {}

participant = teamTemplate.page or ''
if self.parent.options.resolveRedirect then
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/SeriesMedalStats/Participant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Opponent = Lua.import('Module:Opponent/Custom')
local OpponentDisplay = Lua.import('Module:OpponentDisplay/Custom')
Expand Down Expand Up @@ -48,7 +49,7 @@ function MedalStats:_processData()
---@param teamTemplate string
---@return string?
local resolveTeamToIdentifier = function(teamTemplate)
local rawData = mw.ext.TeamTemplate.raw(teamTemplate)
local rawData = TeamTemplate.getRawOrNil(teamTemplate)

if not rawData or not rawData.page then return end

Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/SeriesMedalStats/ParticipantTeam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Opponent = Lua.import('Module:Opponent/Custom')

Expand Down Expand Up @@ -60,7 +61,7 @@ function MedalStats:_processData()
---@param teamTemplate string
---@return string?
local resolveTeamToIdentifier = function(teamTemplate)
local rawData = mw.ext.TeamTemplate.raw(teamTemplate)
local rawData = TeamTemplate.getRawOrNil(teamTemplate)

if not rawData or not rawData.page then return end

Expand Down
5 changes: 3 additions & 2 deletions lua/wikis/commons/Service/Team.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local Lua = require('Module:Lua')
local Array = Lua.import('Module:Array')
local Page = Lua.import('Module:Page')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local TeamService = {}

Expand All @@ -31,11 +32,11 @@ local LPDB_TEAM_FIELDS = {
---@param teamTemplate string
---@return StandardTeam?
function TeamService.getTeamByTemplate(teamTemplate)
if not teamTemplate or not mw.ext.TeamTemplate.teamexists(teamTemplate) then
if not teamTemplate or not TeamTemplate.exists(teamTemplate) then
return nil
end

local team = mw.ext.TeamTemplate.raw(teamTemplate)
local team = TeamTemplate.getRawOrNil(teamTemplate)

if not team then
return nil
Expand Down
5 changes: 3 additions & 2 deletions lua/wikis/commons/Squad/Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Logic = Lua.import('Module:Logic')
local ReferenceCleaner = Lua.import('Module:ReferenceCleaner')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local Lpdb = Lua.import('Module:Lpdb')
Expand Down Expand Up @@ -126,10 +127,10 @@ end
---@return ModelRow
function SquadUtils.readSquadPersonArgs(args)
local function getTeamInfo(page, property)
if not page or not mw.ext.TeamTemplate.teamexists(page) then
if not page or not TeamTemplate.exists(page) then
return
end
return mw.ext.TeamTemplate.raw(page)[property]
return TeamTemplate.getRawOrNil(page)[property]
end

local name = String.nilIfEmpty(args.name)
Expand Down
5 changes: 3 additions & 2 deletions lua/wikis/commons/Standings/Storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Logic = Lua.import('Module:Logic')
local Namespace = Lua.import('Module:Namespace')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local Opponent = Lua.import('Module:Opponent/Custom')
Expand Down Expand Up @@ -297,10 +298,10 @@ function StandingsStorage.fromTemplateEntry(frame)

-- Input contains an actual team
if data.team and mw.ext.TeamTemplate.teamexists(data.team) then
team = mw.ext.TeamTemplate.raw(data.team, date)
team = TeamTemplate.getRawOrNil(data.team, date)
-- Input is link (possiblity with icon etc), and we managed to parse it
elseif teamPage and mw.ext.TeamTemplate.teamexists(teamPage) then
team = mw.ext.TeamTemplate.raw(teamPage, date)
team = TeamTemplate.getRawOrNil(teamPage, date)
end

opponentArgs = {type = Opponent.team}
Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/commons/TeamLogoGallery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function TeamLogoGallery._getImageData(name, showPresentLogo)
for startDate, teamTemplate in Table.iter.spairs(historicalTeamTemplates) do
table.insert(imageDatas, {
startDate = startDate,
raw = mw.ext.TeamTemplate.raw(teamTemplate)
raw = TeamTemplate.getRawOrNil(teamTemplate)
})
end

Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/commons/TransferRow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local Logic = Lua.import('Module:Logic')
local Namespace = Lua.import('Module:Namespace')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Variables = Lua.import('Module:Variables')

local Platform = Lua.import('Module:Platform')
Expand Down Expand Up @@ -124,7 +125,7 @@ function TransferRow:_readBaseData()
---@param teamInput string
---@return {name: string?, template: string?}
local checkTeam = function(dateInput, teamInput)
local teamData = Logic.isNotEmpty(teamInput) and mw.ext.TeamTemplate.raw(teamInput, dateInput)
local teamData = Logic.isNotEmpty(teamInput) and TeamTemplate.getRawOrNil(teamInput, dateInput)
if not teamData then
return {}
end
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/freefire/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local Lua = require('Module:Lua')
local Class = Lua.import('Module:Class')
local String = Lua.import('Module:StringUtils')
local Page = Lua.import('Module:Page')
local TeamTemplate = Lua.import('Module:TeamTemplate')
local Template = Lua.import('Module:Template')

local Injector = Lua.import('Module:Widget/Injector')
Expand Down Expand Up @@ -59,7 +60,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args, personType)

local team2 = args.team2link or args.team2
if String.isNotEmpty(team2) then
lpdbData.extradata.team2 = (mw.ext.TeamTemplate.raw(team2) or {}).page or team2
lpdbData.extradata.team2 = (TeamTemplate.getRawOrNil(team2) or {}).page or team2
end
return lpdbData
end
Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/overwatch/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args)
lpdbData.region = Template.safeExpand(mw.getCurrentFrame(), 'Player region', {args.country})

if String.isNotEmpty(args.team2) then
lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page
lpdbData.extradata.team2 = TeamTemplate.getRaw(args.team2).page
end

return lpdbData
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/pubg/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local Lua = require('Module:Lua')

local Class = Lua.import('Module:Class')
local String = Lua.import('Module:StringUtils')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Injector = Lua.import('Module:Widget/Injector')
local Player = Lua.import('Module:Infobox/Person')
Expand Down Expand Up @@ -54,7 +55,7 @@ end
---@return table
function CustomPlayer:adjustLPDB(lpdbData, args)
if String.isNotEmpty(args.team2) then
lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page
lpdbData.extradata.team2 = TeamTemplate.getRaw(args.team2).page
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use TeamTemplate.getPageName?
(same in several of the other cases too)

Copy link
Collaborator Author

@ElectricalBoy ElectricalBoy Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPageName has resolve_redirect slapped onto the return value, so not using it is to avoid breaking historic stuff

end

return lpdbData
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/pubgmobile/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local Lua = require('Module:Lua')
local Class = Lua.import('Module:Class')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local Injector = Lua.import('Module:Widget/Injector')
local Player = Lua.import('Module:Infobox/Person')
Expand Down Expand Up @@ -60,7 +61,7 @@ end
---@return table
function CustomPlayer:adjustLPDB(lpdbData, args, personType)
if String.isNotEmpty(args.team2) then
lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page
lpdbData.extradata.team2 = TeamTemplate.getRaw(args.team2).page
end

return lpdbData
Expand Down
5 changes: 3 additions & 2 deletions lua/wikis/rocketleague/Ratings/Display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local Lua = require('Module:Lua')
local Arguments = Lua.import('Module:Arguments')
local Array = Lua.import('Module:Array')
local RatingsStorageLpdb = Lua.import('Module:Ratings/Storage/Lpdb')
local TeamTemplate = Lua.import('Module:TeamTemplate')

local RatingsDisplay = {}

Expand Down Expand Up @@ -78,8 +79,8 @@ function RatingsDisplay._getTeamInfo(teamName)

return {
region = teamInfo.region or '???',
shortName = mw.ext.TeamTemplate.teamexists(teamInfo.template or '')
and mw.ext.TeamTemplate.raw(teamInfo.template).shortname or teamName
shortName = TeamTemplate.exists(teamInfo.template or '')
and TeamTemplate.getRaw(teamInfo.template).shortname or teamName
}
end

Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/wildrift/Infobox/Person/Player/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function CustomPlayer:adjustLPDB(lpdbData, args, personType)
lpdbData.region = Template.safeExpand(mw.getCurrentFrame(), 'Player region', {args.country})

if String.isNotEmpty(args.team2) then
lpdbData.extradata.team2 = mw.ext.TeamTemplate.raw(args.team2).page
lpdbData.extradata.team2 = TeamTemplate.getRaw(args.team2).page
end

return lpdbData
Expand Down
Loading