mirror of
https://github.com/friendica/friendica
synced 2025-01-29 02:19:48 +00:00
Merge pull request #14718 from Art4/mark-internal-code
Mark internal code, move deprecation warnings into entry points
This commit is contained in:
commit
0d97118cfb
14 changed files with 39 additions and 62 deletions
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*
|
||||
* @deprecated 2025.02 use bin/console.php daemon instead
|
||||
* @deprecated 2025.02 use `bin/console.php daemon` instead
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,8 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/daemon.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php daemon` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
array_splice($argv, 1, 0, "daemon");
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*
|
||||
* @deprecated 2025.02 use bin/console.php jetstream instead
|
||||
* @deprecated 2025.02 use `bin/console.php jetstream` instead
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
|
@ -19,6 +19,8 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/jetstream.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php jetstream` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
array_splice($argv, 1, 0, "jetstream");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
* Starts the background processing
|
||||
*
|
||||
* @deprecated 2025.02 use bin/console.php worker instead
|
||||
* @deprecated 2025.02 use `bin/console.php worker` instead
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
|
@ -21,6 +21,8 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/worker.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php worker` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
array_splice($argv, 1, 0, "worker");
|
||||
|
|
14
src/App.php
14
src/App.php
|
@ -57,6 +57,7 @@ use Psr\Log\LoggerInterface;
|
|||
* and anything else that might need to be passed around
|
||||
* before we spit the page out.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class App
|
||||
{
|
||||
|
@ -64,6 +65,9 @@ class App
|
|||
const CODENAME = 'Interrupted Fern';
|
||||
const VERSION = '2025.02-dev';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function fromContainer(Container $container): self
|
||||
{
|
||||
return new self($container);
|
||||
|
@ -130,6 +134,9 @@ class App
|
|||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function processRequest(ServerRequestInterface $request, float $start_time): void
|
||||
{
|
||||
$this->container->addRule(Mode::class, [
|
||||
|
@ -180,7 +187,9 @@ class App
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function processConsole(array $serverParams): void
|
||||
{
|
||||
$argv = $serverParams['argv'] ?? [];
|
||||
|
@ -208,6 +217,9 @@ class App
|
|||
(\Friendica\Core\Console::create($this->container, $argv))->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function processEjabberd(array $serverParams): void
|
||||
{
|
||||
$this->setupContainerForAddons();
|
||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Util\Strings;
|
|||
* and anything else that might need to be passed around
|
||||
* before we spit the page out.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class AppLegacy implements AppHelper
|
||||
{
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\Core\Console as CoreConsole;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
|
||||
/**
|
||||
* Abstract Console class for common settings
|
||||
*/
|
||||
abstract class AbstractConsole extends Console
|
||||
{
|
||||
/**
|
||||
* Overwrite this const in case you want to switch the LogChannel for this console command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const LOG_CHANNEL = LogChannel::CONSOLE;
|
||||
|
||||
/**
|
||||
* Checks, if the Console command was executed outside `bin/console.php` and prints the correct execution
|
||||
*
|
||||
* @param string $command the current command
|
||||
*/
|
||||
protected function checkDeprecated(string $command): void
|
||||
{
|
||||
if (substr($this->executable, -strlen(CoreConsole::getDefaultExecutable())) !== CoreConsole::getDefaultExecutable()) {
|
||||
$this->out(sprintf("'%s' is deprecated and will removed. Please use 'bin/console.php %s' instead", $this->executable, $command));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,10 +10,10 @@ declare(strict_types=1);
|
|||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\CommandArgsException;
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -27,10 +27,8 @@ use RuntimeException;
|
|||
/**
|
||||
* Console command for interacting with the daemon
|
||||
*/
|
||||
final class Daemon extends AbstractConsole
|
||||
final class Daemon extends Console
|
||||
{
|
||||
public const LOG_CHANNEL = LogChannel::DAEMON;
|
||||
|
||||
private Mode $mode;
|
||||
private IManageConfigValues $config;
|
||||
private IManageKeyValuePairs $keyValue;
|
||||
|
@ -93,8 +91,6 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$this->checkDeprecated('daemon');
|
||||
|
||||
if ($this->mode->isInstall()) {
|
||||
throw new RuntimeException("Friendica isn't properly installed yet");
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
use Friendica\Protocol\ATProtocol\Jetstream;
|
||||
use Friendica\System\Daemon as SysDaemon;
|
||||
use RuntimeException;
|
||||
|
@ -22,10 +22,8 @@ use RuntimeException;
|
|||
/**
|
||||
* Console command for interacting with the daemon
|
||||
*/
|
||||
final class JetstreamDaemon extends AbstractConsole
|
||||
final class JetstreamDaemon extends Console
|
||||
{
|
||||
public const LOG_CHANNEL = LogChannel::DAEMON;
|
||||
|
||||
private Mode $mode;
|
||||
private IManageConfigValues $config;
|
||||
private IManageKeyValuePairs $keyValue;
|
||||
|
@ -79,8 +77,6 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$this->checkDeprecated('jetstream');
|
||||
|
||||
if ($this->mode->isInstall()) {
|
||||
throw new RuntimeException("Friendica isn't properly installed yet");
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Core\Worker as CoreWorker;
|
||||
use Friendica\Core\Worker\Repository\Process as ProcessRepository;
|
||||
|
@ -19,10 +19,8 @@ use Friendica\Util\BasePath;
|
|||
/**
|
||||
* Console command for starting worker
|
||||
*/
|
||||
final class Worker extends AbstractConsole
|
||||
final class Worker extends Console
|
||||
{
|
||||
public const LOG_CHANNEL = LogChannel::WORKER;
|
||||
|
||||
private Mode $mode;
|
||||
private BasePath $basePath;
|
||||
private ProcessRepository $processRepo;
|
||||
|
@ -69,8 +67,6 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$this->checkDeprecated('worker');
|
||||
|
||||
$this->mode->setExecutor(Mode::WORKER);
|
||||
|
||||
// Check the database structure and possibly fixes it
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Friendica\Core;
|
|||
|
||||
/**
|
||||
* Dependency Injection Container
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Container
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@ use Dice\Dice;
|
|||
|
||||
/**
|
||||
* Wrapper for the Dice class to make some basic setups
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class DiceContainer implements Container
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@ use Psr\Log\LoggerInterface;
|
|||
*
|
||||
* @see \Friendica\Core\Logger\Factory\StreamLogger
|
||||
* @see \Friendica\Core\Logger\Factory\SyslogLogger
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class LegacyLoggerFactory implements LoggerFactory
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ use Psr\Log\NullLogger;
|
|||
|
||||
/**
|
||||
* Manager for the core logging instances
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class LoggerManager
|
||||
{
|
||||
|
|
|
@ -60,7 +60,8 @@ abstract class DI
|
|||
|
||||
/**
|
||||
* Returns a clone of the current dice instance
|
||||
* This useful for overloading the current instance with mocked methods during tests
|
||||
*
|
||||
* @internal This useful for overloading the current instance with mocked methods during tests
|
||||
*
|
||||
* @return Dice
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue