split DatabaseUpgrade into a separate event from InitExt
This commit is contained in:
parent
ee3754ae79
commit
031c441e47
32 changed files with 63 additions and 120 deletions
|
@ -77,4 +77,7 @@ _load_event_listeners();
|
|||
$_tracer->end();
|
||||
|
||||
send_event(new InitExtEvent());
|
||||
if(AUTO_DB_UPGRADE) {
|
||||
send_event(new DatabaseUpgradeEvent());
|
||||
}
|
||||
$_tracer->end();
|
||||
|
|
|
@ -316,3 +316,6 @@ class LogEvent extends Event
|
|||
$this->time = time();
|
||||
}
|
||||
}
|
||||
|
||||
class DatabaseUpgradeEvent extends Event {
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ _d("MIN_PHP_VERSION", '7.3');// string minimum supported PHP version
|
|||
_d("TRACE_FILE", null); // string file to log performance data into
|
||||
_d("TRACE_THRESHOLD", 0.0); // float log pages which take more time than this many seconds
|
||||
_d("ENABLED_MODS", "imageboard");
|
||||
_d("AUTO_DB_UPGRADE", true); // bool whether or not to automatically run DB schema updates
|
||||
|
||||
/*
|
||||
* Calculated settings - you should never need to change these
|
||||
|
|
|
@ -15,10 +15,6 @@ class Approval extends Extension
|
|||
|
||||
$config->set_default_bool(ApprovalConfig::IMAGES, false);
|
||||
$config->set_default_bool(ApprovalConfig::COMMENTS, false);
|
||||
|
||||
if ($config->get_int(ApprovalConfig::VERSION) < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
|
@ -241,7 +237,7 @@ class Approval extends Extension
|
|||
}
|
||||
|
||||
|
||||
private function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class Artists extends Extension
|
|||
}
|
||||
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Blocks extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
if ($config->get_int("ext_blocks_version") < 1) {
|
||||
|
|
|
@ -4,9 +4,14 @@ class Blotter extends Extension
|
|||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
/**
|
||||
* I love re-using this installer don't I...
|
||||
*/
|
||||
global $config;
|
||||
$config->set_default_int("blotter_recent", 5);
|
||||
$config->set_default_string("blotter_color", "FF0000");
|
||||
$config->set_default_string("blotter_position", "subheading");
|
||||
}
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config;
|
||||
$version = $config->get_int("blotter_version", 0);
|
||||
/**
|
||||
|
@ -33,10 +38,6 @@ class Blotter extends Extension
|
|||
log_info("blotter", "Installed tables for blotter extension.");
|
||||
$config->set_int("blotter_version", 1);
|
||||
}
|
||||
// Set default config:
|
||||
$config->set_default_int("blotter_recent", 5);
|
||||
$config->set_default_string("blotter_color", "FF0000");
|
||||
$config->set_default_string("blotter_position", "subheading");
|
||||
}
|
||||
|
||||
public function onSetupBuilding(SetupBuildingEvent $event)
|
||||
|
|
|
@ -90,15 +90,18 @@ class CommentList extends Extension
|
|||
/** @var CommentListTheme $theme */
|
||||
public $theme;
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
global $config;
|
||||
$config->set_default_int('comment_window', 5);
|
||||
$config->set_default_int('comment_limit', 10);
|
||||
$config->set_default_int('comment_list_count', 10);
|
||||
$config->set_default_int('comment_count', 5);
|
||||
$config->set_default_bool('comment_captcha', false);
|
||||
}
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
if ($config->get_int("ext_comments_version") < 3) {
|
||||
// shortcut to latest
|
||||
if ($config->get_int("ext_comments_version") < 1) {
|
||||
|
|
|
@ -22,14 +22,6 @@ class FavoriteSetEvent extends Event
|
|||
|
||||
class Favorites extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config;
|
||||
if ($config->get_int("ext_favorites_version", 0) < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||
{
|
||||
global $database, $user;
|
||||
|
@ -205,11 +197,10 @@ class Favorites extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
global $database;
|
||||
|
||||
if ($config->get_int("ext_favorites_version") < 1) {
|
||||
$database->Execute("ALTER TABLE images ADD COLUMN favorites INTEGER NOT NULL DEFAULT 0");
|
||||
|
|
|
@ -9,7 +9,7 @@ Todo:
|
|||
*/
|
||||
class Forum extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class AddImageHashBanEvent extends Event
|
|||
|
||||
class ImageBan extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
if ($config->get_int("ext_imageban_version") < 1) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class ImageViewCounter extends Extension
|
|||
}
|
||||
|
||||
# Installs DB table
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@ class IPBan extends Extension
|
|||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config;
|
||||
if ($config->get_int("ext_ipban_version") < 8) {
|
||||
$this->install();
|
||||
}
|
||||
$config->set_default_string(
|
||||
"ipban_message",
|
||||
'<p>IP <b>$IP</b> has been banned until <b>$DATE</b> by <b>$ADMIN</b> because of <b>$REASON</b>
|
||||
|
@ -128,7 +125,7 @@ class IPBan extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
|
|
@ -4,8 +4,12 @@ class LogDatabase extends Extension
|
|||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
$config->set_default_int("log_db_priority", SCORE_LOG_INFO);
|
||||
}
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int("ext_log_database_version") < 1) {
|
||||
$database->create_table("score_log", "
|
||||
|
@ -20,8 +24,6 @@ class LogDatabase extends Extension
|
|||
//INDEX(section)
|
||||
$config->set_int("ext_log_database_version", 1);
|
||||
}
|
||||
|
||||
$config->set_default_int("log_db_priority", SCORE_LOG_INFO);
|
||||
}
|
||||
|
||||
public function onSetupBuilding(SetupBuildingEvent $event)
|
||||
|
|
|
@ -76,11 +76,6 @@ class Media extends Extension
|
|||
$config->set_default_int(MediaConfig::MEM_LIMIT, parse_shorthand_int('8MB'));
|
||||
$config->set_default_string(MediaConfig::FFMPEG_PATH, 'ffmpeg');
|
||||
$config->set_default_string(MediaConfig::CONVERT_PATH, 'convert');
|
||||
|
||||
|
||||
if ($config->get_int(MediaConfig::VERSION) < 2) {
|
||||
$this->setup();
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
|
@ -994,7 +989,7 @@ class Media extends Extension
|
|||
return $size;
|
||||
}
|
||||
|
||||
private function setup()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
if ($config->get_int(MediaConfig::VERSION) < 1) {
|
||||
|
|
|
@ -7,7 +7,7 @@ class NotATag extends Extension
|
|||
return 30;
|
||||
} // before ImageUploadEvent and tag_history
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
if ($config->get_int("ext_notatag_version") < 1) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Notes extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -16,14 +16,6 @@ class NumericScoreSetEvent extends Event
|
|||
|
||||
class NumericScore extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config;
|
||||
if ($config->get_int("ext_numeric_score_version", 0) < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onDisplayingImage(DisplayingImageEvent $event)
|
||||
{
|
||||
global $user;
|
||||
|
@ -303,7 +295,7 @@ class NumericScore extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
private function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
|
|
@ -48,7 +48,7 @@ class PM
|
|||
|
||||
class PrivMsg extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -61,9 +61,8 @@ class PoolCreationEvent extends Event
|
|||
|
||||
class Pools extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
global $config;
|
||||
|
||||
// Set the defaults for the pools extension
|
||||
$config->set_default_int(PoolsConfig::MAX_IMPORT_RESULTS, 1000);
|
||||
|
@ -74,6 +73,10 @@ class Pools extends Extension
|
|||
$config->set_default_bool(PoolsConfig::ADDER_ON_VIEW_IMAGE, false);
|
||||
$config->set_default_bool(PoolsConfig::SHOW_NAV_LINKS, false);
|
||||
$config->set_default_bool(PoolsConfig::AUTO_INCREMENT_ORDER, false);
|
||||
}
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) {
|
||||
global $config, $database;
|
||||
|
||||
// Create the database tables
|
||||
if ($config->get_int("ext_pools_version") < 1) {
|
||||
|
|
|
@ -16,13 +16,9 @@ class PostTitles extends Extension
|
|||
|
||||
$config->set_default_bool(PostTitlesConfig::DEFAULT_TO_FILENAME, false);
|
||||
$config->set_default_bool(PostTitlesConfig::SHOW_IN_WINDOW_TITLE, false);
|
||||
|
||||
if ($config->get_int(PostTitlesConfig::VERSION) < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
private function install()
|
||||
private function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -130,10 +130,6 @@ class Ratings extends Extension
|
|||
{
|
||||
global $config, $_shm_user_classes, $_shm_ratings;
|
||||
|
||||
if ($config->get_int(RatingsConfig::VERSION) < 4) {
|
||||
$this->install();
|
||||
}
|
||||
|
||||
foreach (array_keys($_shm_user_classes) as $key) {
|
||||
if ($key == "base" || $key == "hellbanned") {
|
||||
continue;
|
||||
|
@ -525,7 +521,7 @@ class Ratings extends Extension
|
|||
return true;
|
||||
}
|
||||
|
||||
private function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ class Relationships extends Extension
|
|||
{
|
||||
public const NAME = "Relationships";
|
||||
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -41,15 +41,6 @@ class ImageReport
|
|||
|
||||
class ReportImage extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config->get_int("ext_report_image_version") < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $page, $user;
|
||||
|
@ -181,7 +172,7 @@ class ReportImage extends Extension
|
|||
$cache->delete("image-report-count");
|
||||
}
|
||||
|
||||
protected function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -12,11 +12,6 @@ class SourceHistory extends Extension
|
|||
{
|
||||
global $config;
|
||||
$config->set_default_int("history_limit", -1);
|
||||
|
||||
// shimmie is being installed so call install to create the table.
|
||||
if ($config->get_int("ext_source_history_version") < 3) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onAdminBuilding(AdminBuildingEvent $event)
|
||||
|
@ -95,7 +90,7 @@ class SourceHistory extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -5,13 +5,16 @@ require_once "config.php";
|
|||
|
||||
class TagCategories extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
global $config;
|
||||
|
||||
// whether we split out separate categories on post view by default
|
||||
// note: only takes effect if /post/view shows the image's exact tags
|
||||
$config->set_default_bool(TagCategoriesConfig::SPLIT_ON_VIEW, true);
|
||||
}
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int(TagCategoriesConfig::VERSION) < 1) {
|
||||
// primary extension database, holds all our stuff!
|
||||
|
|
|
@ -12,11 +12,6 @@ class TagHistory extends Extension
|
|||
{
|
||||
global $config;
|
||||
$config->set_default_int("history_limit", -1);
|
||||
|
||||
// shimmie is being installed so call install to create the table.
|
||||
if ($config->get_int("ext_tag_history_version") < 3) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onAdminBuilding(AdminBuildingEvent $event)
|
||||
|
@ -96,7 +91,7 @@ class TagHistory extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Tips extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -13,15 +13,6 @@ class Trash extends Extension
|
|||
return 10;
|
||||
}
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config->get_int(TrashConfig::VERSION) < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $page, $user;
|
||||
|
@ -158,8 +149,7 @@ class Trash extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function install()
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Upgrade extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -22,15 +22,6 @@ class UserConfig extends Extension
|
|||
{
|
||||
private const VERSION = "ext_user_config_version";
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config->get_int(self::VERSION, 0)<1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserLogin(UserLoginEvent $event)
|
||||
{
|
||||
global $database, $user_config;
|
||||
|
@ -39,7 +30,7 @@ class UserConfig extends Extension
|
|||
send_event(new InitUserConfigEvent($event->user, $user_config));
|
||||
}
|
||||
|
||||
private function install(): void
|
||||
private function onDatabaseUpgrade(DatabaseUpgradeEvent $event): void
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class WikiPage
|
|||
|
||||
class Wiki extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
|
|
Reference in a new issue