Merged in sentry_logging (pull request #20)
Sentry logging and dep updates
This commit is contained in:
commit
101619f7b5
|
@ -22,6 +22,7 @@ class AppKernel extends Kernel
|
||||||
new Ob\HighchartsBundle\ObHighchartsBundle(),
|
new Ob\HighchartsBundle\ObHighchartsBundle(),
|
||||||
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
|
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
|
||||||
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
|
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
|
||||||
|
new Sentry\SentryBundle\SentryBundle(),
|
||||||
new Skobkin\Bundle\PointToolsBundle\SkobkinPointToolsBundle(),
|
new Skobkin\Bundle\PointToolsBundle\SkobkinPointToolsBundle(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -30,10 +31,6 @@ class AppKernel extends Kernel
|
||||||
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
|
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
|
||||||
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
|
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
|
||||||
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
|
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
|
||||||
|
|
||||||
if ('dev' === $this->getEnvironment()) {
|
|
||||||
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bundles;
|
return $bundles;
|
||||||
|
|
|
@ -389,7 +389,7 @@ class SymfonyRequirements extends RequirementCollection
|
||||||
{
|
{
|
||||||
/* mandatory requirements follow */
|
/* mandatory requirements follow */
|
||||||
|
|
||||||
$installedPhpVersion = phpversion();
|
$installedPhpVersion = PHP_VERSION;
|
||||||
$requiredPhpVersion = $this->getPhpRequiredVersion();
|
$requiredPhpVersion = $this->getPhpRequiredVersion();
|
||||||
|
|
||||||
$this->addRecommendation(
|
$this->addRecommendation(
|
||||||
|
@ -448,15 +448,8 @@ class SymfonyRequirements extends RequirementCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) {
|
if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) {
|
||||||
$timezones = array();
|
|
||||||
foreach (DateTimeZone::listAbbreviations() as $abbreviations) {
|
|
||||||
foreach ($abbreviations as $abbreviation) {
|
|
||||||
$timezones[$abbreviation['timezone_id']] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addRequirement(
|
$this->addRequirement(
|
||||||
isset($timezones[@date_default_timezone_get()]),
|
in_array(@date_default_timezone_get(), DateTimeZone::listIdentifiers(), true),
|
||||||
sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()),
|
sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()),
|
||||||
'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.'
|
'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.'
|
||||||
);
|
);
|
||||||
|
@ -731,7 +724,7 @@ class SymfonyRequirements extends RequirementCollection
|
||||||
'Install and/or enable a <strong>PHP accelerator</strong> (highly recommended).'
|
'Install and/or enable a <strong>PHP accelerator</strong> (highly recommended).'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
|
||||||
$this->addRecommendation(
|
$this->addRecommendation(
|
||||||
$this->getRealpathCacheSize() >= 5 * 1024 * 1024,
|
$this->getRealpathCacheSize() >= 5 * 1024 * 1024,
|
||||||
'realpath_cache_size should be at least 5M in php.ini',
|
'realpath_cache_size should be at least 5M in php.ini',
|
||||||
|
|
|
@ -92,3 +92,6 @@ knp_paginator:
|
||||||
|
|
||||||
csa_guzzle:
|
csa_guzzle:
|
||||||
profiler: '%kernel.debug%'
|
profiler: '%kernel.debug%'
|
||||||
|
|
||||||
|
sentry:
|
||||||
|
dsn: "%sentry_dsn%"
|
||||||
|
|
|
@ -37,3 +37,6 @@ parameters:
|
||||||
telegram_max_connections: 2
|
telegram_max_connections: 2
|
||||||
# Telegram monolog handler
|
# Telegram monolog handler
|
||||||
telegram_log_chat_id: ~
|
telegram_log_chat_id: ~
|
||||||
|
|
||||||
|
# Sentry
|
||||||
|
sentry_dsn: ~
|
||||||
|
|
17
app/console
17
app/console
|
@ -1,29 +1,20 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\Debug\Debug;
|
use Symfony\Component\Debug\Debug;
|
||||||
|
|
||||||
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
|
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
|
||||||
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
||||||
// for more information
|
// for more information
|
||||||
//umask(0000);
|
|
||||||
umask(0002);
|
umask(0002);
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
/** @var \Composer\Autoload\ClassLoader $loader */
|
|
||||||
$loader = require __DIR__.'/autoload.php';
|
|
||||||
|
|
||||||
$input = new ArgvInput();
|
$input = new ArgvInput();
|
||||||
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
|
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev', true);
|
||||||
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
|
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption('--no-debug', true) && $env !== 'prod';
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
Debug::enable();
|
Debug::enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = new AppKernel($env, $debug);
|
$kernel = new AppKernel($env, $debug);
|
||||||
$application = new Application($kernel);
|
$application = new Application($kernel);
|
||||||
$application->run($input);
|
$application->run($input);
|
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1.0",
|
"php": ">=7.1.0",
|
||||||
"symfony/symfony": "3.4.x-dev",
|
"symfony/symfony": "^3.4",
|
||||||
"doctrine/orm": "^2.5",
|
"doctrine/orm": "^2.5",
|
||||||
"doctrine/annotations": "^1.3.0",
|
"doctrine/annotations": "^1.3.0",
|
||||||
"doctrine/doctrine-bundle": "^1.6",
|
"doctrine/doctrine-bundle": "^1.6",
|
||||||
|
@ -33,10 +33,10 @@
|
||||||
"unreal4u/telegram-api": "^2.2",
|
"unreal4u/telegram-api": "^2.2",
|
||||||
"csa/guzzle-bundle": "3.0.x-dev",
|
"csa/guzzle-bundle": "3.0.x-dev",
|
||||||
"unreal4u/monolog-telegram": "^0.2.0",
|
"unreal4u/monolog-telegram": "^0.2.0",
|
||||||
"symfony/web-server-bundle": "^3.3"
|
"symfony/web-server-bundle": "^3.3",
|
||||||
|
"sentry/sentry-symfony": "^2.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sensio/generator-bundle": "^3.0",
|
|
||||||
"symfony/phpunit-bridge": "^3.0",
|
"symfony/phpunit-bridge": "^3.0",
|
||||||
"phpunit/phpunit": "^5.7",
|
"phpunit/phpunit": "^5.7",
|
||||||
"doctrine/doctrine-fixtures-bundle": "^2.3"
|
"doctrine/doctrine-fixtures-bundle": "^2.3"
|
||||||
|
|
1824
composer.lock
generated
1824
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -192,16 +192,19 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
try {
|
try {
|
||||||
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
|
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $appUserId]);
|
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $this->appUserId]);
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$serviceUser) {
|
if (!$serviceUser) {
|
||||||
$this->logger->critical('Service user not found or marked as removed');
|
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
|
||||||
// @todo Retrieving user
|
|
||||||
|
|
||||||
throw new \RuntimeException('Service user not found in the database');
|
try {
|
||||||
|
$serviceUser = $this->api->getUserById($this->appUserId);
|
||||||
|
} catch (UserNotFoundException $e) {
|
||||||
|
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('Getting service subscribers');
|
$this->logger->info('Getting service subscribers');
|
||||||
|
|
|
@ -164,9 +164,13 @@ class UpdateUsersPrivacyCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$serviceUser) {
|
if (!$serviceUser) {
|
||||||
$this->logger->critical('Service user not found or marked as removed');
|
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
|
||||||
|
|
||||||
throw new \RuntimeException('Service user not found in the database');
|
try {
|
||||||
|
$serviceUser = $this->api->getUserById($this->appUserId);
|
||||||
|
} catch (UserNotFoundException $e) {
|
||||||
|
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('Getting service subscribers');
|
$this->logger->info('Getting service subscribers');
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
||||||
|
|
||||||
use Knp\Component\Pager\Paginator;
|
use Knp\Component\Pager\PaginatorInterface;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
|
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\{Request, Response};
|
use Symfony\Component\HttpFoundation\{Request, Response};
|
||||||
|
|
||||||
class EventsController extends AbstractController
|
class EventsController extends AbstractController
|
||||||
{
|
{
|
||||||
public function lastAction(Request $request, SubscriptionEventRepository $eventRepository, Paginator $paginator): Response
|
public function lastAction(Request $request, SubscriptionEventRepository $eventRepository, PaginatorInterface $paginator): Response
|
||||||
{
|
{
|
||||||
$eventsPagination = $paginator->paginate(
|
$eventsPagination = $paginator->paginate(
|
||||||
$eventRepository->createLastSubscriptionEventsQuery(),
|
$eventRepository->createLastSubscriptionEventsQuery(),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
||||||
|
|
||||||
use Knp\Component\Pager\Paginator;
|
use Knp\Component\Pager\PaginatorInterface;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
|
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
@ -11,7 +11,7 @@ class PublicFeedController extends AbstractController
|
||||||
{
|
{
|
||||||
private const POSTS_PER_PAGE = 20;
|
private const POSTS_PER_PAGE = 20;
|
||||||
|
|
||||||
public function indexAction(Request $request, PostRepository $postRepository, Paginator $paginator)
|
public function indexAction(Request $request, PostRepository $postRepository, PaginatorInterface $paginator)
|
||||||
{
|
{
|
||||||
$postsPagination = $paginator->paginate(
|
$postsPagination = $paginator->paginate(
|
||||||
$postRepository->createPublicFeedPostsQuery(),
|
$postRepository->createPublicFeedPostsQuery(),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
namespace Skobkin\Bundle\PointToolsBundle\Controller;
|
||||||
|
|
||||||
use Knp\Component\Pager\Paginator;
|
use Knp\Component\Pager\PaginatorInterface;
|
||||||
use Skobkin\Bundle\PointToolsBundle\DTO\{DailyEvents, TopUserDTO};
|
use Skobkin\Bundle\PointToolsBundle\DTO\{DailyEvents, TopUserDTO};
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Repository\{SubscriptionEventRepository, UserRenameEventRepository, UserRepository};
|
use Skobkin\Bundle\PointToolsBundle\Repository\{SubscriptionEventRepository, UserRenameEventRepository, UserRepository};
|
||||||
|
@ -30,7 +30,7 @@ class UserController extends AbstractController
|
||||||
SubscriptionEventRepository $subscriptionEventRepository,
|
SubscriptionEventRepository $subscriptionEventRepository,
|
||||||
UserRepository $userRepository,
|
UserRepository $userRepository,
|
||||||
UserRenameEventRepository $renameEventRepository,
|
UserRenameEventRepository $renameEventRepository,
|
||||||
Paginator $paginator
|
PaginatorInterface $paginator
|
||||||
): Response {
|
): Response {
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $userRepository->findUserByLogin($login);
|
$user = $userRepository->findUserByLogin($login);
|
||||||
|
|
13
web/app.php
13
web/app.php
|
@ -1,17 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
/** @var \Composer\Autoload\ClassLoader $loader */
|
if (PHP_VERSION_ID < 70000) {
|
||||||
$loader = require __DIR__.'/../app/autoload.php';
|
|
||||||
include_once __DIR__.'/../app/bootstrap.php.cache';
|
include_once __DIR__.'/../app/bootstrap.php.cache';
|
||||||
|
}
|
||||||
umask(0002);
|
|
||||||
|
|
||||||
$kernel = new AppKernel('prod', false);
|
$kernel = new AppKernel('prod', false);
|
||||||
|
if (PHP_VERSION_ID < 70000) {
|
||||||
$kernel->loadClassCache();
|
$kernel->loadClassCache();
|
||||||
|
}
|
||||||
//$kernel = new AppCache($kernel);
|
//$kernel = new AppCache($kernel);
|
||||||
|
|
||||||
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
|
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
|
||||||
//Request::enableHttpMethodParameterOverride();
|
//Request::enableHttpMethodParameterOverride();
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
|
|
|
@ -1,31 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\Debug\Debug;
|
use Symfony\Component\Debug\Debug;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
|
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
|
||||||
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
|
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
||||||
|
// for more information
|
||||||
umask(0002);
|
umask(0002);
|
||||||
|
|
||||||
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
||||||
// Feel free to remove this, extend it, or make something more sophisticated.
|
// Feel free to remove this, extend it, or make something more sophisticated.
|
||||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||||
|| !(
|
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
|
||||||
in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) ||
|
|
||||||
php_sapi_name() === 'cli-server'
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
header('HTTP/1.0 403 Forbidden');
|
header('HTTP/1.0 403 Forbidden');
|
||||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||||
}
|
}
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
/** @var \Composer\Autoload\ClassLoader $loader */
|
|
||||||
$loader = require __DIR__.'/../app/autoload.php';
|
|
||||||
Debug::enable();
|
Debug::enable();
|
||||||
|
|
||||||
$kernel = new AppKernel('dev', true);
|
$kernel = new AppKernel('dev', true);
|
||||||
|
if (PHP_VERSION_ID < 70000) {
|
||||||
$kernel->loadClassCache();
|
$kernel->loadClassCache();
|
||||||
|
}
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
$response = $kernel->handle($request);
|
$response = $kernel->handle($request);
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
Loading…
Reference in a new issue