Package: php-monolog
Version: 1.23.0-1
Followup-For: Bug #882944
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu bionic ubuntu-patch
Dear Maintainer,
In Ubuntu, the attached patch was applied to achieve the following:
* debian/patches/phpunit6_compatibility_changes.patch: PHPUnit 6 is
not backwards compatible in various ways. Closes LP: #1749001.
* debian/patches/mongodb_fixes.patch: Multiple upstream MongoDB
handler changes.
I had to backport a lot of changes from upstream to get the build to
succeed and to get the DEP8 tests to pass.
I'm most unhappy with the redis/predis stuff, but I think it's actually
a bug in libphp-predis, which does not ship an autoload.php file?
Thanks for considering the patch.
*** /tmp/tmpXKFgpx/php-monolog_1.23.0-1ubuntu1.debdiff
diff -Nru php-monolog-1.23.0/debian/patches/mongodb_fixes.patch
php-monolog-1.23.0/debian/patches/mongodb_fixes.patch
--- php-monolog-1.23.0/debian/patches/mongodb_fixes.patch 1969-12-31
16:00:00.0 -0800
+++ php-monolog-1.23.0/debian/patches/mongodb_fixes.patch 2018-02-12
21:09:52.0 -0800
@@ -0,0 +1,207 @@
+Description: Multiple upstream MongoDB handler changes
+Author: Nishanth Aravamudan
+Origin: upstream,
https://github.com/Seldaek/monolog/commit/ad37c8e6638d6d21cf4deaca1aafb8c4a29a6d1b.patch
+Origin: upstream,
https://github.com/Seldaek/monolog/commit/f6a9fdbb2c9ad9ef7f26269a1edb1de1c3b6d3cc.patch
+Origin: upstream,
https://github.com/Seldaek/monolog/commit/d860b763cb0419930e9bce71cec7408f215d5a6d.patch
+Origin: upstream,
https://github.com/Seldaek/monolog/commit/aa6ab660bdb32f4568514ad8ed0167b86a57809b.patch
+Forwarded: Will be done by Nishanth Aravamudan
+Last-Update: 2018-02-13
+
+--- a/composer.json
b/composer.json
+@@ -38,8 +38,8 @@
+ "ruflin/elastica": "Allow sending log messages to an Elastic Search
server",
+ "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP
server using php-amqplib",
+ "ext-amqp": "Allow sending log messages to an AMQP server (1.0+
required)",
+-"ext-mongo": "Allow sending log messages to a MongoDB server",
+-"mongodb/mongodb": "Allow sending log messages to a MongoDB server
via PHP Driver",
++"ext-mongodb": "Allow sending log messages to a MongoDB server (via
driver)",
++"mongodb/mongodb": "Allow sending log messages to a MongoDB server
(via library)",
+ "aws/aws-sdk-php": "Allow sending log messages to AWS services like
DynamoDB",
+ "rollbar/rollbar": "Allow sending log messages to Rollbar",
+ "php-console/php-console": "Allow sending log messages to Google
Chrome"
+--- a/src/Monolog/Handler/MongoDBHandler.php
b/src/Monolog/Handler/MongoDBHandler.php
+@@ -11,41 +11,66 @@
+
+ namespace Monolog\Handler;
+
++use MongoDB\Driver\BulkWrite;
++use MongoDB\Driver\Manager;
++use MongoDB\Client;
+ use Monolog\Logger;
+ use Monolog\Formatter\NormalizerFormatter;
+
+ /**
+ * Logs to a MongoDB database.
+ *
+- * usage example:
++ * Usage example:
+ *
+- * $log = new Logger('application');
+- * $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"),
"logs", "prod");
++ * $log = new \Monolog\Logger('application');
++ * $client = new \MongoDB\Client('mongodb://localhost:27017');
++ * $mongodb = new \Monolog\Handler\MongoDBHandler($client, 'logs', 'prod');
+ * $log->pushHandler($mongodb);
+ *
+- * @author Thomas Tourlourat
++ * The above examples uses the MongoDB PHP library's client class; however,
the
++ * MongoDB\Driver\Manager class from ext-mongodb is also supported.
+ */
+ class MongoDBHandler extends AbstractProcessingHandler
+ {
+-protected $mongoCollection;
++private $collection;
++private $manager;
++private $namespace;
+
+-public function __construct($mongo, $database, $collection, $level =
Logger::DEBUG, $bubble = true)
++/**
++ * Constructor.
++ *
++ * @param Client|Manager $mongodbMongoDB library or driver client
++ * @param string $database Database name
++ * @param string $collection Collection name
++ * @param int$level The minimum logging level at which
this handler will be triggered
++ * @param Boolean$bubble Whether the messages that are
handled can bubble up the stack or not
++ */
++public function __construct($mongodb, $database, $collection, $level =
Logger::DEBUG, $bubble = true)
+ {
+-if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo ||
$mongo instanceof \MongoDB\Client)) {
+-throw new \InvalidArgumentException('MongoClient, Mongo or
MongoDB\Client instance required');
++if (!($mongodb instanceof Client || $mongodb instanceof Manager)) {
++throw new \InvalidArgumentException('MongoDB\Client or
MongoDB\Driver\Manager instance required');
+ }
+
+-$this->mongoCollection = $mongo->selectCollection($databas