Skip to content

Commit b2fad31

Browse files
committed
Remove "mongo" handler type
1 parent c2c37a9 commit b2fad31

File tree

4 files changed

+1
-153
lines changed

4 files changed

+1
-153
lines changed

CHANGELOG-4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Remove `excluded_404s` option, use `excluded_http_codes` instead
1111
* Remove `console_formater_options` option, use `console_formatter_options` instead
1212
* Remove `elasticsearch` type, use `elastica` or `elastic_search` instead
13+
* Remove `mongo` type, use `mongodb` instead
1314
* Remove `sentry` and `raven` types, use a `service` type with [`sentry/sentry-symfony`](https://docs.sentryio/platforms/php/guides/symfony/logs/) instead
1415
* Remove `DebugHandlerPass`
1516
* Remove support for the `DebugHandler`

src/DependencyInjection/Configuration.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ public function getConfigTreeBuilder(): TreeBuilder
584584
->end();
585585

586586
$this->addGelfSection($handlerNode);
587-
$this->addMongoSection($handlerNode);
588587
$this->addMongoDBSection($handlerNode);
589588
$this->addElasticsearchSection($handlerNode);
590589
$this->addRedisSection($handlerNode);
@@ -742,46 +741,6 @@ private function addGelfSection(ArrayNodeDefinition $handlerNode): void
742741
;
743742
}
744743

745-
private function addMongoSection(ArrayNodeDefinition $handlerNode): void
746-
{
747-
$handlerNode
748-
->children()
749-
->arrayNode('mongo')
750-
->canBeUnset()
751-
->beforeNormalization()
752-
->ifString()
753-
->then(function ($v) { return ['id' => $v]; })
754-
->end()
755-
->children()
756-
->scalarNode('id')->end()
757-
->scalarNode('host')->end()
758-
->scalarNode('port')->defaultValue(27017)->end()
759-
->scalarNode('user')->end()
760-
->scalarNode('pass')->end()
761-
->scalarNode('database')->defaultValue('monolog')->end()
762-
->scalarNode('collection')->defaultValue('logs')->end()
763-
->end()
764-
->validate()
765-
->ifTrue(function ($v) {
766-
return !isset($v['id']) && !isset($v['host']);
767-
})
768-
->thenInvalid('The "mongo" handler configuration requires either a service "id" or a connection "host".')
769-
->end()
770-
->validate()
771-
->ifTrue(function ($v) {
772-
return isset($v['user']) && !isset($v['pass']);
773-
})
774-
->thenInvalid('If you set user, you must provide a password.')
775-
->end()
776-
->end()
777-
->end()
778-
->validate()
779-
->ifTrue(function ($v) { return 'mongo' === $v['type'] && !isset($v['mongo']); })
780-
->thenInvalid('The "mongo" configuration has to be specified to use a "mongo" handler type.')
781-
->end()
782-
;
783-
}
784-
785744
private function addMongoDBSection(ArrayNodeDefinition $handlerNode)
786745
{
787746
$handlerNode

src/DependencyInjection/MonologExtension.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -229,39 +229,6 @@ private function buildHandler(ContainerBuilder $container, string $name, array $
229229
]);
230230
break;
231231

232-
case 'mongo':
233-
trigger_deprecation('symfony/monolog-bundle', '3.11', 'The "mongo" handler type is deprecated in MonologBundle since version 3.11.0, use the "mongodb" type instead.');
234-
235-
if (!class_exists('MongoDB\Client')) {
236-
throw new \RuntimeException('The "mongo" handler requires the mongodb/mongodb package to be installed.');
237-
}
238-
239-
if (isset($handler['mongo']['id'])) {
240-
$client = new Reference($handler['mongo']['id']);
241-
} else {
242-
$server = 'mongodb://';
243-
244-
if (isset($handler['mongo']['user'])) {
245-
$server .= $handler['mongo']['user'].':'.$handler['mongo']['pass'].'@';
246-
}
247-
248-
$server .= $handler['mongo']['host'].':'.$handler['mongo']['port'];
249-
250-
$client = new Definition('MongoDB\Client', [
251-
$server,
252-
['appname' => 'monolog-bundle'],
253-
]);
254-
}
255-
256-
$definition->setArguments([
257-
$client,
258-
$handler['mongo']['database'],
259-
$handler['mongo']['collection'],
260-
$handler['level'],
261-
$handler['bubble'],
262-
]);
263-
break;
264-
265232
case 'mongodb':
266233
if (!class_exists('MongoDB\Client')) {
267234
throw new \RuntimeException('The "mongodb" handler requires the mongodb/mongodb package to be installed.');
@@ -857,7 +824,6 @@ private function getHandlerClassByType(string $handlerType): string
857824
'whatfailuregroup' => 'Monolog\Handler\WhatFailureGroupHandler',
858825
'fingers_crossed' => 'Monolog\Handler\FingersCrossedHandler',
859826
'filter' => 'Monolog\Handler\FilterHandler',
860-
'mongo' => 'Monolog\Handler\MongoDBHandler',
861827
'mongodb' => 'Monolog\Handler\MongoDBHandler',
862828
'telegram' => 'Monolog\Handler\TelegramBotHandler',
863829
'server_log' => 'Symfony\Bridge\Monolog\Handler\ServerLogHandler',

tests/DependencyInjection/MonologExtensionTest.php

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -559,84 +559,6 @@ public function testElasticsearchAndElasticaHandlers()
559559
$this->assertSame(['hosts' => ['es:9200'], 'transport' => 'Http'], $elasticaClient->getArgument(0));
560560
}
561561

562-
#[Group('legacy')]
563-
#[IgnoreDeprecations]
564-
public function testMongo()
565-
{
566-
if (!class_exists('MongoDB\Client')) {
567-
$this->markTestSkipped('mongodb/mongodb is not installed.');
568-
}
569-
570-
//$this->expectDeprecation('Since symfony/monolog-bundle 3.11: The "mongo" handler type is deprecated in MonologBundle since version 3.11.0, use the "mongodb" type instead.');
571-
572-
$container = new ContainerBuilder();
573-
$container->setDefinition('mongodb.client', new Definition('MongoDB\Client'));
574-
575-
$config = [[
576-
'handlers' => [
577-
'mongo_with_id' => [
578-
'type' => 'mongo',
579-
'mongo' => ['id' => 'mongodb.client'],
580-
],
581-
'mongo_with_string_id' => [
582-
'type' => 'mongo',
583-
'mongo' => 'mongodb.client',
584-
],
585-
'mongo_with_host' => [
586-
'type' => 'mongo',
587-
'mongo' => [
588-
'host' => 'localhost',
589-
'port' => '27018',
590-
'user' => 'username',
591-
'pass' => 'password',
592-
'database' => 'db',
593-
'collection' => 'coll',
594-
],
595-
],
596-
'mongo_with_host_and_default_args' => [
597-
'type' => 'mongo',
598-
'mongo' => [
599-
'host' => 'localhost',
600-
],
601-
],
602-
],
603-
]];
604-
605-
$extension = new MonologExtension();
606-
$extension->load($config, $container);
607-
608-
$this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_id'));
609-
$this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_string_id'));
610-
$this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_host'));
611-
$this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_host_and_default_args'));
612-
613-
// MongoDB handler should receive the mongodb.client as first argument
614-
$handler = $container->getDefinition('monolog.handler.mongo_with_id');
615-
$this->assertDICDefinitionClass($handler, MongoDBHandler::class);
616-
$this->assertDICConstructorArguments($handler, [new Reference('mongodb.client'), 'monolog', 'logs', 'DEBUG', true]);
617-
618-
// MongoDB handler should receive the mongodb.client as first argument
619-
$handler = $container->getDefinition('monolog.handler.mongo_with_string_id');
620-
$this->assertDICDefinitionClass($handler, MongoDBHandler::class);
621-
$this->assertDICConstructorArguments($handler, [new Reference('mongodb.client'), 'monolog', 'logs', 'DEBUG', true]);
622-
623-
// MongoDB handler with host and arguments
624-
$handler = $container->getDefinition('monolog.handler.mongo_with_host');
625-
$this->assertDICDefinitionClass($handler, MongoDBHandler::class);
626-
$client = $handler->getArgument(0);
627-
$this->assertDICDefinitionClass($client, 'MongoDB\Client');
628-
$this->assertDICConstructorArguments($client, ['mongodb://username:password@localhost:27018', ['appname' => 'monolog-bundle']]);
629-
$this->assertDICConstructorArguments($handler, [$client, 'db', 'coll', 'DEBUG', true]);
630-
631-
// MongoDB handler with host and default arguments
632-
$handler = $container->getDefinition('monolog.handler.mongo_with_host_and_default_args');
633-
$this->assertDICDefinitionClass($handler, MongoDBHandler::class);
634-
$client = $handler->getArgument(0);
635-
$this->assertDICDefinitionClass($client, 'MongoDB\Client');
636-
$this->assertDICConstructorArguments($client, ['mongodb://localhost:27017', ['appname' => 'monolog-bundle']]);
637-
$this->assertDICConstructorArguments($handler, [$client, 'monolog', 'logs', 'DEBUG', true]);
638-
}
639-
640562
public function testMongoDB()
641563
{
642564
if (!class_exists('MongoDB\Client')) {

0 commit comments

Comments
 (0)