Skip to content

Commit

Permalink
Merge pull request #3075 from stof/deprecate_couchdb
Browse files Browse the repository at this point in the history
Deprecate the CouchDB ODM integration
  • Loading branch information
stof authored Jun 24, 2024
2 parents 682ebb6 + 495bab8 commit 33cb79a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ common tasks such as user registration and password retrieval.

Features include:

- Users can be stored via Doctrine ORM or MongoDB/CouchDB ODM
- Users can be stored via Doctrine ORM or MongoDB ODM
- Registration support, with an optional confirmation per email
- Password reset support
- Unit tested
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"ext-json": "*",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/deprecation-contracts": "^2.5 || ^3.5",
"symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0 || ^3.0",
"symfony/form": "^4.4 || ^5.0 || ^6.0",
Expand Down
14 changes: 8 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Step 3: Create your User class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The goal of this bundle is to persist some ``User`` class to a database (MySql,
MongoDB, CouchDB, etc). Your first job, then, is to create the ``User`` class
MongoDB, etc). Your first job, then, is to create the ``User`` class
for your application. This class can look and act however you want: add any
properties or methods you find useful. This is *your* ``User`` class.

Expand All @@ -98,8 +98,7 @@ to make it easier to create your entity. Here is how you use it:
redefine the mapping for the other fields as it is provided by the bundle.

In the following sections, you'll see examples of how your ``User`` class should
look, depending on how you're storing your users (Doctrine ORM, MongoDB ODM,
or CouchDB ODM).
look, depending on how you're storing your users (Doctrine ORM or MongoDB ODM).

.. note::

Expand Down Expand Up @@ -220,6 +219,9 @@ this to start:
c) CouchDB User class
.....................

.. note::
Support for the CouchDB ODM is deprecated as the Doctrine CouchDB ODM is unmaintained.

If you're persisting your users via the Doctrine CouchDB ODM, then your ``User``
class should live in the ``CouchDocument`` namespace of your bundle and look
like this to start:
Expand Down Expand Up @@ -349,7 +351,7 @@ of datastore you are using.
# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'custom'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
Expand All @@ -360,7 +362,7 @@ of datastore you are using.
<!-- app/config/config.xml -->
<!-- other valid 'db-driver' values are 'mongodb' and 'couchdb' -->
<!-- other valid 'db-driver' values are 'mongodb', 'couchdb' and 'custom' -->
<fos_user:config
db-driver="orm"
firewall-name="main"
Expand All @@ -369,7 +371,7 @@ of datastore you are using.
Only four configuration's nodes are required to use the bundle:

* The type of datastore you are using (``orm``, ``mongodb`` or ``couchdb``).
* The type of datastore you are using (``orm``, ``mongodb``, ``couchdb`` or ``custom```).
* The firewall name which you configured in Step 4.
* The fully qualified class name (FQCN) of the ``User`` class which you created in Step 3.
* The default email address to use when the bundle send a registration confirmation to the user.
Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public function getConfigTreeBuilder(): TreeBuilder
->ifNotInArray($supportedDrivers)
->thenInvalid('The driver %s is not supported. Please choose one of '.json_encode($supportedDrivers))
->end()
->validate()
->ifInArray(['couchdb'])
->then(function ($v) {
trigger_deprecation('friendsofsymfony/user-bundle', '3.3.0', 'The CouchDB ODM integration is deprecated because the CouchDB ODM itself is unmaintained.');

return $v;
})
->end()
->cannotBeOverwritten()
->isRequired()
->cannotBeEmpty()
Expand Down
2 changes: 2 additions & 0 deletions src/Doctrine/CouchDB/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @internal
*
* @final
*
* @deprecated The CouchDB ODM integration is deprecated since 3.3.0 because the CouchDB ODM itself is unmaintained.
*/
class UserListener implements EventSubscriber
{
Expand Down
23 changes: 22 additions & 1 deletion tests/DependencyInjection/FOSUserExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,32 @@ public function userManagerSetFactoryProvider()
{
return [
['orm', 'doctrine'],
['couchdb', 'doctrine_couchdb'],
['mongodb', 'doctrine_mongodb'],
];
}

/**
* @group legacy
*/
public function testUserManagerSetFactoryCouchdb()
{
$this->configuration = new ContainerBuilder();
$loader = new FOSUserExtension();
$config = $this->getEmptyConfig();
$config['db_driver'] = 'couchdb';
$loader->load([$config], $this->configuration);

$definition = $this->configuration->getDefinition('fos_user.object_manager');

$this->assertAlias('doctrine_couchdb', 'fos_user.doctrine_registry');

$factory = $definition->getFactory();

$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $factory[0]);
$this->assertSame('fos_user.doctrine_registry', (string) $factory[0]);
$this->assertSame('getManager', $factory[1]);
}

protected function createEmptyConfiguration()
{
$this->configuration = new ContainerBuilder();
Expand Down

0 comments on commit 33cb79a

Please sign in to comment.