Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4022396
CNDatabasePatcher.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
CNDatabasePatcher.php
View Options
<?php
/**
* @file
* @license GPL-2.0-or-later
*/
use
MediaWiki\Installer\DatabaseUpdater
;
use
MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook
;
/**
* Maintenance helper class that updates the database schema when required.
*
* Apply patches with /maintenance/update.php
*/
class
CNDatabasePatcher
implements
LoadExtensionSchemaUpdatesHook
{
/**
* LoadExtensionSchemaUpdates hook handler
* This function makes sure that the database schema is up to date.
*
* @param DatabaseUpdater $updater
*/
public
function
onLoadExtensionSchemaUpdates
(
$updater
)
{
$base
=
__DIR__
.
'/../sql'
;
$dbType
=
$updater
->
getDB
()->
getType
();
$updater
->
addExtensionTable
(
'cn_notices'
,
"$base/$dbType/tables-generated.sql"
);
if
(
$dbType
===
'mysql'
)
{
// 1.35
// Adds geotargeted regions for notices and the corresponding log columns
$updater
->
addExtensionUpdate
(
[
'addTable'
,
'cn_notice_regions'
,
$base
.
'/mysql/patch-notice_regions.sql'
,
true
]
);
$updater
->
addExtensionUpdate
(
[
'addField'
,
'cn_templates'
,
'tmp_is_template'
,
$base
.
'/mysql/patch_template_banners.sql'
,
true
]
);
$updater
->
addExtensionUpdate
(
[
'modifyField'
,
'cn_templates'
,
'tmp_is_template'
,
$base
.
'/mysql/patch_template_banners_field_update.sql'
,
true
]
);
// 1.36
$updater
->
addExtensionField
(
'cn_notices'
,
'not_type'
,
$base
.
'/mysql/patch-notice_not_type.sql'
);
// This adds both notlog_begin_type and notlog_end_type fields
$updater
->
addExtensionField
(
'cn_notice_log'
,
'notlog_begin_type'
,
$base
.
'/mysql/patch-notice-type-log.sql'
);
// 1.39
$updater
->
modifyExtensionField
(
'cn_notices'
,
'not_end'
,
$base
.
'/mysql/patch-cn_notices-timestamps.sql'
);
$updater
->
modifyExtensionField
(
'cn_notice_log'
,
'notlog_end_end'
,
$base
.
'/mysql/patch-cn_notice_log-timestamps.sql'
);
}
// 1.40
$updater
->
dropExtensionIndex
(
'cn_notice_languages'
,
'nl_notice_id_language'
,
"$base/$dbType/patch-cn_notice_languages-unique-to-pk.sql"
);
$updater
->
dropExtensionIndex
(
'cn_notice_projects'
,
'np_notice_id_project'
,
"$base/$dbType/patch-cn_notice_projects-unique-to-pk.sql"
);
$updater
->
dropExtensionIndex
(
'cn_notice_countries'
,
'nc_notice_id_country'
,
"$base/$dbType/patch-cn_notice_countries-unique-to-pk.sql"
);
$updater
->
dropExtensionIndex
(
'cn_notice_regions'
,
'nr_notice_id_region'
,
"$base/$dbType/patch-cn_notice_regions-unique-to-pk.sql"
);
$updater
->
addExtensionUpdate
(
[
[
__CLASS__
,
'doOnSchemaUpdatesPopulateKnownDevices'
],
]
);
}
public
static
function
doOnSchemaUpdatesPopulateKnownDevices
(
DatabaseUpdater
$updater
):
void
{
$updateKey
=
'populateKnownDevices-1.24'
;
if
(
$updater
->
updateRowExists
(
$updateKey
)
)
{
$updater
->
output
(
"...default known devices already added
\n
"
);
return
;
}
$updater
->
output
(
"Adding known devices...
\n
"
);
$dbw
=
$updater
->
getDB
();
$dbw
->
newInsertQueryBuilder
()
->
insertInto
(
'cn_known_devices'
)
->
ignore
()
->
rows
(
[
[
'dev_id'
=>
1
,
'dev_name'
=>
'desktop'
,
'dev_display_label'
=>
'{{int:centralnotice-devicetype-desktop}}'
],
// 1.24
[
'dev_id'
=>
2
,
'dev_name'
=>
'android'
,
'dev_display_label'
=>
'{{int:centralnotice-devicetype-android}}'
],
[
'dev_id'
=>
3
,
'dev_name'
=>
'iphone'
,
'dev_display_label'
=>
'{{int:centralnotice-devicetype-iphone}}'
],
[
'dev_id'
=>
4
,
'dev_name'
=>
'ipad'
,
'dev_display_label'
=>
'{{int:centralnotice-devicetype-ipad}}'
],
[
'dev_id'
=>
5
,
'dev_name'
=>
'unknown'
,
'dev_display_label'
=>
'{{int:centralnotice-devicetype-unknown}}'
],
]
)
->
caller
(
__METHOD__
)
->
execute
();
$updater
->
output
(
"Done
\n
"
);
$updater
->
insertUpdateRow
(
$updateKey
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 14 2026, 18:50 (14 w, 12 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
de/0d/cc8a1c52e92e4234c57592c54a7a
Default Alt Text
CNDatabasePatcher.php (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment