fix merge

This commit is contained in:
Shish 2019-09-29 14:50:31 +01:00
parent ebe4075469
commit 54067f02a4
9 changed files with 13 additions and 23 deletions

View file

@ -37,6 +37,12 @@ unset($_shm_files);
unset($_shm_filename);
$_tracer->end();
// connect to the database
$_tracer->begin("Connecting to DB");
$database = new Database();
$config = new DatabaseConfig($database);
$_tracer->end();
$_tracer->begin("Loading extension info");
ExtensionInfo::load_all_extension_info();
Extension::determine_enabled_extensions();
@ -53,12 +59,6 @@ unset($_shm_files);
unset($_shm_filename);
$_tracer->end();
// connect to the database
$_tracer->begin("Connecting to DB");
$database = new Database();
$config = new DatabaseConfig($database);
$_tracer->end();
// load the theme parts
$_tracer->begin("Loading themelets");
foreach (_get_themelet_files(get_theme()) as $themelet) {

View file

@ -137,9 +137,10 @@ abstract class Extension
explode(",", EXTRA_EXTS)
) as $key) {
$ext = ExtensionInfo::get_by_key($key);
if ($ext===null) {
if ($ext===null || !$ext->is_supported()) {
continue;
}
// FIXME: error if one of our dependencies isn't supported
self::$enabled_extensions[] = $ext->key;
if (!empty($ext->dependencies)) {
foreach ($ext->dependencies as $dep) {
@ -253,7 +254,7 @@ abstract class ExtensionInfo
{
global $database;
$this->support_info = "";
if (!empty($this->db_support)&&!in_array($database->get_driver_name(), $this->db_support)) {
if (!empty($this->db_support) && !in_array($database->get_driver_name(), $this->db_support)) {
$this->support_info .= "Database not supported. ";
}
// Additional checks here as needed

View file

@ -302,7 +302,7 @@ class Image
["tag"=>$tags[0]]
);
} else {
if (ext_is_live("Ratings")) {
if (Extension::is_enabled(RatingsInfo::KEY)) {
$tags[] = "rating:*";
}
list($tag_conditions, $img_conditions) = self::terms_to_conditions($tags);

View file

@ -398,7 +398,7 @@ class CommentList extends Extension
LIMIT :limit OFFSET :offset
", ["limit"=>$threads_per_page, "offset"=>$start]);
$user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_privs($user) : "";
$user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_class_privs($user) : "";
$images = [];
while ($row = $result->fetch()) {

View file

@ -101,8 +101,6 @@ abstract class RatingsConfig
class Ratings extends Extension
{
protected $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::PGSQL];
public const UNRATED_KEYWORDS = ["unknown","unrated"];
private $search_regexp;

View file

@ -7,8 +7,6 @@ abstract class TrashConfig
class Trash extends Extension
{
protected $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::PGSQL];
public function get_priority(): int
{
// Needs to be early to intercept delete events
@ -24,7 +22,6 @@ class Trash extends Extension
}
}
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;
@ -45,8 +42,6 @@ class Trash extends Extension
}
}
public function onDisplayingImage(DisplayingImageEvent $event)
{
global $user, $page;

View file

@ -31,12 +31,12 @@ class UserConfig extends Extension
}
}
public function onInitUserConfig(InitUserConfigEvent $event)
public function onUserLogin(UserLoginEvent $event)
{
global $database, $user_config;
$user_config = new DatabaseConfig($database, "user_config", "user_id", $event->user->id);
$event->user_config = $user_config;
send_event(new InitUserConfigEvent($event->user, $user_config));
}
private function install(): void

View file

@ -91,7 +91,6 @@ try {
// start the page generation waterfall
$user = _get_user();
send_event(new UserLoginEvent($user));
send_event(new InitUserConfigEvent($user));
if (PHP_SAPI === 'cli' || PHP_SAPI == 'phpdbg') {
send_event(new CommandEvent($argv));
} else {

View file

@ -134,7 +134,6 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
$user = User::by_name('demo');
$this->assertNotNull($user);
send_event(new UserLoginEvent($user));
send_event(new InitUserConfigEvent($user));
}
protected function log_in_as_user()
@ -143,7 +142,6 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
$user = User::by_name('test');
$this->assertNotNull($user);
send_event(new UserLoginEvent($user));
send_event(new InitUserConfigEvent($user));
}
protected function log_out()
@ -152,7 +150,6 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
$user = User::by_id($config->get_int("anon_id", 0));
$this->assertNotNull($user);
send_event(new UserLoginEvent($user));
send_event(new InitUserConfigEvent($user));
}
// post things