Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7400443
PopulateInterwikiTask.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PopulateInterwikiTask.php
View Options
<?php
namespace
MediaWiki\Installer\Task
;
use
MediaWiki\Status\Status
;
use
Wikimedia\AtEase\AtEase
;
/**
* Populate the interwiki table from maintenance/interwiki.list
*
* @internal For use by the installer
*/
class
PopulateInterwikiTask
extends
Task
{
/** @inheritDoc */
public
function
getName
()
{
return
'interwiki'
;
}
/** @inheritDoc */
public
function
getDependencies
()
{
return
'tables'
;
}
public
function
execute
():
Status
{
$status
=
$this
->
getConnection
(
ITaskContext
::
CONN_CREATE_TABLES
);
if
(
!
$status
->
isOK
()
)
{
return
$status
;
}
$conn
=
$status
->
getDB
();
$row
=
$conn
->
newSelectQueryBuilder
()
->
select
(
'1'
)
->
from
(
'interwiki'
)
->
caller
(
__METHOD__
)->
fetchRow
();
if
(
$row
)
{
$status
->
warning
(
'config-install-interwiki-exists'
);
return
$status
;
}
AtEase
::
suppressWarnings
();
$rows
=
file
(
MW_INSTALL_PATH
.
'/maintenance/interwiki.list'
,
FILE_IGNORE_NEW_LINES
|
FILE_SKIP_EMPTY_LINES
);
AtEase
::
restoreWarnings
();
if
(
!
$rows
)
{
return
Status
::
newFatal
(
'config-install-interwiki-list'
);
}
$insert
=
$conn
->
newInsertQueryBuilder
()
->
insertInto
(
'interwiki'
);
foreach
(
$rows
as
$row
)
{
$row
=
preg_replace
(
'/^
\s
*([^#]*?)
\s
*(#.*)?$/'
,
'
\\
1'
,
$row
);
// strip comments - whee
if
(
$row
==
""
)
{
continue
;
}
$row
.=
"|"
;
$insert
->
row
(
array_combine
(
[
'iw_prefix'
,
'iw_url'
,
'iw_local'
,
'iw_api'
,
'iw_wikiid'
],
explode
(
'|'
,
$row
)
)
);
}
$insert
->
caller
(
__METHOD__
)->
execute
();
return
Status
::
newGood
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 16:42 (10 h, 10 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cd/4e/3460cd359a781c9915ba903cda09
Default Alt Text
PopulateInterwikiTask.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment