Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4102492
InterwikiLinksTable.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
InterwikiLinksTable.php
View Options
<?php
namespace
MediaWiki\Deferred\LinksUpdate
;
use
MediaWiki\Parser\ParserOutput
;
/**
* iwlinks
*
* Link ID format: string[]
* - 0: Interwiki prefix
* - 1: Foreign title
*
* @since 1.38
*/
class
InterwikiLinksTable
extends
LinksTable
{
/** @var array */
private
$newLinks
=
[];
/** @var array|null */
private
$existingLinks
;
public
function
setParserOutput
(
ParserOutput
$parserOutput
)
{
$this
->
newLinks
=
$parserOutput
->
getInterwikiLinks
();
}
protected
function
getTableName
()
{
return
'iwlinks'
;
}
protected
function
getFromField
()
{
return
'iwl_from'
;
}
protected
function
getExistingFields
()
{
return
[
'iwl_prefix'
,
'iwl_title'
];
}
protected
function
getNewLinkIDs
()
{
foreach
(
$this
->
newLinks
as
$prefix
=>
$links
)
{
foreach
(
$links
as
$title
=>
$unused
)
{
yield
[
(
string
)
$prefix
,
(
string
)
$title
];
}
}
}
/**
* Get the existing links as a 2-d array, with the prefix in the first key,
* the title in the second key, and the value arbitrary.
*
* @return array|null
*/
private
function
getExistingLinks
()
{
if
(
$this
->
existingLinks
===
null
)
{
$this
->
existingLinks
=
[];
foreach
(
$this
->
fetchExistingRows
()
as
$row
)
{
$this
->
existingLinks
[
$row
->
iwl_prefix
][
$row
->
iwl_title
]
=
true
;
}
}
return
$this
->
existingLinks
;
}
protected
function
getExistingLinkIDs
()
{
foreach
(
$this
->
getExistingLinks
()
as
$prefix
=>
$links
)
{
foreach
(
$links
as
$title
=>
$unused
)
{
yield
[
(
string
)
$prefix
,
(
string
)
$title
];
}
}
}
protected
function
isExisting
(
$linkId
)
{
$links
=
$this
->
getExistingLinks
();
[
$prefix
,
$title
]
=
$linkId
;
return
isset
(
$links
[
$prefix
][
$title
]
);
}
protected
function
isInNewSet
(
$linkId
)
{
[
$prefix
,
$title
]
=
$linkId
;
return
isset
(
$this
->
newLinks
[
$prefix
][
$title
]
);
}
protected
function
insertLink
(
$linkId
)
{
[
$prefix
,
$title
]
=
$linkId
;
$this
->
insertRow
(
[
'iwl_prefix'
=>
$prefix
,
'iwl_title'
=>
$title
]
);
}
protected
function
deleteLink
(
$linkId
)
{
[
$prefix
,
$title
]
=
$linkId
;
$this
->
deleteRow
(
[
'iwl_prefix'
=>
$prefix
,
'iwl_title'
=>
$title
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 17:28 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
52/48/0df13aca8283042b6997d12cf67e
Default Alt Text
InterwikiLinksTable.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment