mirror of
https://github.com/friendica/friendica
synced 2025-02-06 22:58:52 +00:00
Merge pull request #14716 from Art4/fix-load-hooks
Fix App not loading Hooks
This commit is contained in:
commit
8df84ed217
6 changed files with 65 additions and 25 deletions
|
@ -52,4 +52,4 @@ $container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||||
|
|
||||||
$app = \Friendica\App::fromContainer($container);
|
$app = \Friendica\App::fromContainer($container);
|
||||||
|
|
||||||
$app->processEjabberd();
|
$app->processEjabberd($_SERVER);
|
||||||
|
|
|
@ -19,4 +19,4 @@ $container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||||
|
|
||||||
$app = \Friendica\App::fromContainer($container);
|
$app = \Friendica\App::fromContainer($container);
|
||||||
|
|
||||||
$app->processConsole($_SERVER['argv'] ?? []);
|
$app->processConsole($_SERVER);
|
||||||
|
|
|
@ -24,11 +24,13 @@ chdir(dirname(__DIR__));
|
||||||
|
|
||||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
// BC: Add console command as second argument
|
||||||
$argv = $_SERVER['argv'] ?? [];
|
$argv = $_SERVER['argv'] ?? [];
|
||||||
array_splice($argv, 1, 0, "daemon");
|
array_splice($argv, 1, 0, "daemon");
|
||||||
|
$_SERVER['argv'] = $argv;
|
||||||
|
|
||||||
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||||
|
|
||||||
$app = \Friendica\App::fromContainer($container);
|
$app = \Friendica\App::fromContainer($container);
|
||||||
|
|
||||||
$app->processConsole($argv);
|
$app->processConsole($_SERVER);
|
||||||
|
|
|
@ -19,11 +19,13 @@ chdir(dirname(__DIR__));
|
||||||
|
|
||||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
// BC: Add console command as second argument
|
||||||
$argv = $_SERVER['argv'] ?? [];
|
$argv = $_SERVER['argv'] ?? [];
|
||||||
array_splice($argv, 1, 0, "jetstream");
|
array_splice($argv, 1, 0, "jetstream");
|
||||||
|
$_SERVER['argv'] = $argv;
|
||||||
|
|
||||||
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||||
|
|
||||||
$app = \Friendica\App::fromContainer($container);
|
$app = \Friendica\App::fromContainer($container);
|
||||||
|
|
||||||
$app->processConsole($argv);
|
$app->processConsole($_SERVER);
|
||||||
|
|
|
@ -21,11 +21,13 @@ chdir(dirname(__DIR__));
|
||||||
|
|
||||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
// BC: Add console command as second argument
|
||||||
$argv = $_SERVER['argv'] ?? [];
|
$argv = $_SERVER['argv'] ?? [];
|
||||||
array_splice($argv, 1, 0, "worker");
|
array_splice($argv, 1, 0, "worker");
|
||||||
|
$_SERVER['argv'] = $argv;
|
||||||
|
|
||||||
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||||
|
|
||||||
$app = \Friendica\App::fromContainer($container);
|
$app = \Friendica\App::fromContainer($container);
|
||||||
|
|
||||||
$app->processConsole($argv);
|
$app->processConsole($_SERVER);
|
||||||
|
|
74
src/App.php
74
src/App.php
|
@ -158,16 +158,18 @@ class App
|
||||||
$this->session = $this->container->create(IHandleUserSessions::class);
|
$this->session = $this->container->create(IHandleUserSessions::class);
|
||||||
$this->appHelper = $this->container->create(AppHelper::class);
|
$this->appHelper = $this->container->create(AppHelper::class);
|
||||||
|
|
||||||
$this->loadSetupForFrontend(
|
$this->load(
|
||||||
$request,
|
$request->getServerParams(),
|
||||||
$this->container->create(DbaDefinition::class),
|
$this->container->create(DbaDefinition::class),
|
||||||
$this->container->create(ViewDefinition::class),
|
$this->container->create(ViewDefinition::class),
|
||||||
|
$this->mode,
|
||||||
|
$this->config,
|
||||||
|
$this->profiler,
|
||||||
|
$this->appHelper,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->registerTemplateEngine();
|
$this->registerTemplateEngine();
|
||||||
|
|
||||||
$this->mode->setExecutor(Mode::INDEX);
|
|
||||||
|
|
||||||
$this->runFrontend(
|
$this->runFrontend(
|
||||||
$this->container->create(IManagePersonalConfigValues::class),
|
$this->container->create(IManagePersonalConfigValues::class),
|
||||||
$this->container->create(Page::class),
|
$this->container->create(Page::class),
|
||||||
|
@ -178,8 +180,11 @@ class App
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processConsole(array $argv): void
|
|
||||||
|
public function processConsole(array $serverParams): void
|
||||||
{
|
{
|
||||||
|
$argv = $serverParams['argv'] ?? [];
|
||||||
|
|
||||||
$this->setupContainerForAddons();
|
$this->setupContainerForAddons();
|
||||||
|
|
||||||
$this->setupLogChannel($this->determineLogChannel($argv));
|
$this->setupLogChannel($this->determineLogChannel($argv));
|
||||||
|
@ -188,12 +193,22 @@ class App
|
||||||
|
|
||||||
$this->registerErrorHandler();
|
$this->registerErrorHandler();
|
||||||
|
|
||||||
|
$this->load(
|
||||||
|
$serverParams,
|
||||||
|
$this->container->create(DbaDefinition::class),
|
||||||
|
$this->container->create(ViewDefinition::class),
|
||||||
|
$this->container->create(Mode::class),
|
||||||
|
$this->container->create(IManageConfigValues::class),
|
||||||
|
$this->container->create(Profiler::class),
|
||||||
|
$this->container->create(AppHelper::class),
|
||||||
|
);
|
||||||
|
|
||||||
$this->registerTemplateEngine();
|
$this->registerTemplateEngine();
|
||||||
|
|
||||||
(\Friendica\Core\Console::create($this->container, $argv))->execute();
|
(\Friendica\Core\Console::create($this->container, $argv))->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processEjabberd(): void
|
public function processEjabberd(array $serverParams): void
|
||||||
{
|
{
|
||||||
$this->setupContainerForAddons();
|
$this->setupContainerForAddons();
|
||||||
|
|
||||||
|
@ -203,6 +218,16 @@ class App
|
||||||
|
|
||||||
$this->registerErrorHandler();
|
$this->registerErrorHandler();
|
||||||
|
|
||||||
|
$this->load(
|
||||||
|
$serverParams,
|
||||||
|
$this->container->create(DbaDefinition::class),
|
||||||
|
$this->container->create(ViewDefinition::class),
|
||||||
|
$this->container->create(Mode::class),
|
||||||
|
$this->container->create(IManageConfigValues::class),
|
||||||
|
$this->container->create(Profiler::class),
|
||||||
|
$this->container->create(AppHelper::class),
|
||||||
|
);
|
||||||
|
|
||||||
/** @var BasePath */
|
/** @var BasePath */
|
||||||
$basePath = $this->container->create(BasePath::class);
|
$basePath = $this->container->create(BasePath::class);
|
||||||
|
|
||||||
|
@ -272,14 +297,21 @@ class App
|
||||||
/**
|
/**
|
||||||
* Load the whole app instance
|
* Load the whole app instance
|
||||||
*/
|
*/
|
||||||
private function loadSetupForFrontend(ServerRequestInterface $request, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition)
|
private function load(
|
||||||
{
|
array $serverParams,
|
||||||
if ($this->config->get('system', 'ini_max_execution_time') !== false) {
|
DbaDefinition $dbaDefinition,
|
||||||
set_time_limit((int)$this->config->get('system', 'ini_max_execution_time'));
|
ViewDefinition $viewDefinition,
|
||||||
|
Mode $mode,
|
||||||
|
IManageConfigValues $config,
|
||||||
|
Profiler $profiler,
|
||||||
|
AppHelper $appHelper
|
||||||
|
): void {
|
||||||
|
if ($config->get('system', 'ini_max_execution_time') !== false) {
|
||||||
|
set_time_limit((int) $config->get('system', 'ini_max_execution_time'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config->get('system', 'ini_pcre_backtrack_limit') !== false) {
|
if ($config->get('system', 'ini_pcre_backtrack_limit') !== false) {
|
||||||
ini_set('pcre.backtrack_limit', (int)$this->config->get('system', 'ini_pcre_backtrack_limit'));
|
ini_set('pcre.backtrack_limit', (int) $config->get('system', 'ini_pcre_backtrack_limit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normally this constant is defined - but not if "pcntl" isn't installed
|
// Normally this constant is defined - but not if "pcntl" isn't installed
|
||||||
|
@ -290,11 +322,11 @@ class App
|
||||||
// Ensure that all "strtotime" operations do run timezone independent
|
// Ensure that all "strtotime" operations do run timezone independent
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
$this->profiler->reset();
|
$profiler->reset();
|
||||||
|
|
||||||
if ($this->mode->has(Mode::DBAVAILABLE)) {
|
if ($mode->has(Mode::DBAVAILABLE)) {
|
||||||
Core\Hook::loadHooks();
|
Core\Hook::loadHooks();
|
||||||
$loader = (new Config())->createConfigFileManager($this->appHelper->getBasePath(), $request->getServerParams());
|
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $serverParams);
|
||||||
Core\Hook::callAll('load_config', $loader);
|
Core\Hook::callAll('load_config', $loader);
|
||||||
|
|
||||||
// Hooks are now working, reload the whole definitions with hook enabled
|
// Hooks are now working, reload the whole definitions with hook enabled
|
||||||
|
@ -302,7 +334,7 @@ class App
|
||||||
$viewDefinition->load(true);
|
$viewDefinition->load(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadDefaultTimezone();
|
$this->loadDefaultTimezone($config, $appHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,16 +344,16 @@ class App
|
||||||
*
|
*
|
||||||
* @global string $default_timezone
|
* @global string $default_timezone
|
||||||
*/
|
*/
|
||||||
private function loadDefaultTimezone()
|
private function loadDefaultTimezone(IManageConfigValues $config, AppHelper $appHelper)
|
||||||
{
|
{
|
||||||
if ($this->config->get('system', 'default_timezone')) {
|
if ($config->get('system', 'default_timezone')) {
|
||||||
$timezone = $this->config->get('system', 'default_timezone', 'UTC');
|
$timezone = $config->get('system', 'default_timezone', 'UTC');
|
||||||
} else {
|
} else {
|
||||||
global $default_timezone;
|
global $default_timezone;
|
||||||
$timezone = $default_timezone ?? '' ?: 'UTC';
|
$timezone = $default_timezone ?? '' ?: 'UTC';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->appHelper->setTimeZone($timezone);
|
$appHelper->setTimeZone($timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,6 +380,8 @@ class App
|
||||||
float $start_time,
|
float $start_time,
|
||||||
ServerRequestInterface $request
|
ServerRequestInterface $request
|
||||||
) {
|
) {
|
||||||
|
$this->mode->setExecutor(Mode::INDEX);
|
||||||
|
|
||||||
$httpInput = new HTTPInputData($request->getServerParams());
|
$httpInput = new HTTPInputData($request->getServerParams());
|
||||||
$serverVars = $request->getServerParams();
|
$serverVars = $request->getServerParams();
|
||||||
$queryVars = $request->getQueryParams();
|
$queryVars = $request->getQueryParams();
|
||||||
|
|
Loading…
Add table
Reference in a new issue