diff --git a/components/external_media_links/external_media_link.lua b/components/external_media_links/external_media_link.lua index 5045ff2fd85..082d5e0f2a8 100644 --- a/components/external_media_links/external_media_link.lua +++ b/components/external_media_links/external_media_link.lua @@ -74,8 +74,7 @@ function ExternalMediaLink._store(args) local authors = {} for _, author, authorIndex in Table.iter.pairsByPrefix(args, 'by') do - authors['author' .. authorIndex] = - mw.ext.TeamLiquidIntegration.resolve_redirect(args['by_link' .. authorIndex] or author) + authors['author' .. authorIndex] = Page.pageifyLink(args['by_link' .. authorIndex] or author) authors['author' .. authorIndex .. 'dn'] = author end -- set a maximum for authors due to the same being used in queries @@ -87,7 +86,7 @@ function ExternalMediaLink._store(args) translation = args.translation, translator = args.translator, event = args.event, - event_link = mw.ext.TeamLiquidIntegration.resolve_redirect( + event_link = Page.pageifyLink( Logic.emptyOr(args['event-link'], args.event) or '' ), subject_organization = args.subject_organization1, --legacy @@ -95,7 +94,7 @@ function ExternalMediaLink._store(args) local orgs = {} for _, org, orgIndex in Table.iter.pairsByPrefix(args, 'subject_organization') do - orgs['subject_organization' .. orgIndex] = mw.ext.TeamLiquidIntegration.resolve_redirect(org) + orgs['subject_organization' .. orgIndex] = Page.pageifyLink(org) end -- set a maximum for orgs due to the same being used in queries assert(Table.size(orgs) <= MAXIMUM_VALUES.organisations, @@ -103,7 +102,7 @@ function ExternalMediaLink._store(args) local subjects = {} for _, subject, subjectIndex in Table.iter.pairsByPrefix(args, 'subject') do - subjects['subject' .. subjectIndex] = mw.ext.TeamLiquidIntegration.resolve_redirect(subject) + subjects['subject' .. subjectIndex] = Page.pageifyLink(subject) end -- set a maximum for subjects due to the same being used in queries assert(Table.size(subjects) <= MAXIMUM_VALUES.subjects, diff --git a/components/external_media_links/external_media_list.lua b/components/external_media_links/external_media_list.lua index a6b7e3cebe3..64e7c6e4778 100644 --- a/components/external_media_links/external_media_list.lua +++ b/components/external_media_links/external_media_list.lua @@ -107,8 +107,15 @@ function MediaList._buildConditions(args) end if args.org then - table.insert(additionalConditions, '[[extradata_subject_organization::' .. args.org .. ']]') - table.insert(additionalConditions, MediaList._buildMultiKeyCondition(args.org, 'extradata_subject_organization', 5)) + table.insert( + additionalConditions, + '([[extradata_subject_organization::' + .. args.org + ']] OR [[extradata_subject_organization::' + .. args.org:gsub(' ', '_') + .. ']])' + ) + table.insert(additionalConditions, MediaList._buildMultiKeyCondition(args.org, 'extraata_subject_organization', 5)) end if args.author then @@ -116,7 +123,14 @@ function MediaList._buildConditions(args) end if args.event then - table.insert(additionalConditions, '[[extradata_event_link::' .. args.event .. ']]') + table.insert( + additionalConditions, + '([[extradata_event_link::' + .. args.event + .. ']] OR [[extradata_event_link::' + .. args.event:gsub(' ', '_') + .. ']])' + ) end if Logic.isNotEmpty(additionalConditions) then @@ -125,6 +139,7 @@ function MediaList._buildConditions(args) return table.concat(conditions, ' AND ') end + ---Builds a multi key condition for a given prefix and value ---@param value string|number ---@param prefix string @@ -132,7 +147,8 @@ end ---@return string function MediaList._buildMultiKeyCondition(value, prefix, limit) return table.concat(Array.map(Array.range(1, limit), function(index) - return '[[' .. prefix .. index .. '::' .. value .. ']]' + return '([[' .. prefix .. index .. '::' .. value .. ']]' + .. ' OR [['.. prefix .. index .. '::' .. value:gsub(' ', '_') .. ']])' end), ' OR ') end