mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 17:08:58 +03:00
Merge pull request #314 from acelaya/feature/fix-context
Feature/fix context
This commit is contained in:
commit
9e3dd82efe
6 changed files with 6 additions and 37 deletions
|
@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
#### Fixed
|
#### Fixed
|
||||||
|
|
||||||
* [#309](https://github.com/shlinkio/shlink/issues/309) Added missing favicon to prevent 404 errors logged when an error page is loaded in a browser.
|
* [#309](https://github.com/shlinkio/shlink/issues/309) Added missing favicon to prevent 404 errors logged when an error page is loaded in a browser.
|
||||||
|
* [#310](https://github.com/shlinkio/shlink/issues/310) Fixed execution context not being properly detected, making `CloseDbConnectionMiddlware` to be always piped. Now the check is not even made, which simplifies everything.
|
||||||
|
|
||||||
|
|
||||||
## 1.15.0 - 2018-12-02
|
## 1.15.0 - 2018-12-02
|
||||||
|
|
3
bin/cli
3
bin/cli
|
@ -3,11 +3,8 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
use Interop\Container\ContainerInterface;
|
||||||
use Shlinkio\Shlink\Common\Exec\ExecutionContext;
|
|
||||||
use Symfony\Component\Console\Application as CliApp;
|
use Symfony\Component\Console\Application as CliApp;
|
||||||
|
|
||||||
/** @var ContainerInterface $container */
|
/** @var ContainerInterface $container */
|
||||||
$container = include __DIR__ . '/../config/container.php';
|
$container = include __DIR__ . '/../config/container.php';
|
||||||
|
|
||||||
putenv(sprintf('CURRENT_SHLINK_CONTEXT=%s', ExecutionContext::CLI));
|
|
||||||
$container->get(CliApp::class)->run();
|
$container->get(CliApp::class)->run();
|
||||||
|
|
|
@ -10,18 +10,11 @@ return [
|
||||||
|
|
||||||
'middleware_pipeline' => [
|
'middleware_pipeline' => [
|
||||||
'pre-routing' => [
|
'pre-routing' => [
|
||||||
'middleware' => (function () {
|
'middleware' => [
|
||||||
$middleware = [
|
|
||||||
ErrorHandler::class,
|
ErrorHandler::class,
|
||||||
Expressive\Helper\ContentLengthMiddleware::class,
|
Expressive\Helper\ContentLengthMiddleware::class,
|
||||||
];
|
Common\Middleware\CloseDbConnectionMiddleware::class,
|
||||||
|
],
|
||||||
if (Common\Exec\ExecutionContext::currentContextIsSwoole()) {
|
|
||||||
$middleware[] = Common\Middleware\CloseDbConnectionMiddleware::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $middleware;
|
|
||||||
})(),
|
|
||||||
'priority' => 12,
|
'priority' => 12,
|
||||||
],
|
],
|
||||||
'pre-routing-rest' => [
|
'pre-routing-rest' => [
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Common\Exec;
|
|
||||||
|
|
||||||
use const PHP_SAPI;
|
|
||||||
use function Shlinkio\Shlink\Common\env;
|
|
||||||
|
|
||||||
abstract class ExecutionContext
|
|
||||||
{
|
|
||||||
public const WEB = 'shlink_web';
|
|
||||||
public const CLI = 'shlink_cli';
|
|
||||||
|
|
||||||
public static function currentContextIsSwoole(): bool
|
|
||||||
{
|
|
||||||
return PHP_SAPI === 'cli' && env('CURRENT_SHLINK_CONTEXT', self::WEB) === self::WEB;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,5 +18,4 @@
|
||||||
|
|
||||||
<!-- Paths to exclude -->
|
<!-- Paths to exclude -->
|
||||||
<exclude-pattern>config/params/*</exclude-pattern>
|
<exclude-pattern>config/params/*</exclude-pattern>
|
||||||
<exclude-pattern>public/index.php</exclude-pattern>
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -2,11 +2,8 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Shlinkio\Shlink\Common\Exec\ExecutionContext;
|
|
||||||
use Zend\Expressive\Application;
|
use Zend\Expressive\Application;
|
||||||
|
|
||||||
/** @var ContainerInterface $container */
|
/** @var ContainerInterface $container */
|
||||||
$container = include __DIR__ . '/../config/container.php';
|
$container = include __DIR__ . '/../config/container.php';
|
||||||
|
|
||||||
putenv(sprintf('CURRENT_SHLINK_CONTEXT=%s', ExecutionContext::WEB));
|
|
||||||
$container->get(Application::class)->run();
|
$container->get(Application::class)->run();
|
||||||
|
|
Loading…
Reference in a new issue