Skip to content

Commit

Permalink
Merge pull request #445 from jackalope/1-to-2
Browse files Browse the repository at this point in the history
1 to 2
  • Loading branch information
dbu authored Apr 3, 2024
2 parents f617820 + 453bdee commit dc07257
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Changelog
1.x
===

1.12.0
------

* Added: Factory now accepts an optional parameter `jackalope.case_sensitive_encoding` to set `Client::setCaseSensitiveEncoding`.
* Bugfix: Factory now actually accepts the optional parameter `jackalope.uuid_generator`

1.11.2
------

Expand Down
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,43 @@ $ composer require jackalope/jackalope-doctrine-dbal

## Create a repository

Set up a new database supported by Doctrine DBAL. You can use your favorite GUI frontend or just do something like this:
Set up a new database supported by Doctrine DBAL. You can use your favorite GUI
frontend or use the following commands:

### MySQL

Note that you need at least version 5.1.5 of MySQL, otherwise you will get ``SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cmf-app.EXTRACTVALUE does not exist``
Note that you need at least version 5.1.5 of MySQL, otherwise you will get
``SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cmf-app.EXTRACTVALUE does not exist``

```sh
$ mysqladmin -u root -p create database jackalope
$ echo "grant all privileges on jackalope.* to 'jackalope'@'localhost' identified by '1234test'; flush privileges;" | mysql -u root -p
mysqladmin -u root -p create database jackalope
echo "grant all privileges on jackalope.* to 'jackalope'@'localhost' identified by '1234test'; flush privileges;" | mysql -u root -p
```

Also note that with MySQL/MariaDB, you need to configure the encoding to be used (see "bootstrapping" below).

If you configured the encoding but still run into issues with the encoding, e.g.
`SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'`,
you can set the `jackalope.case_sensitive_encoding` parameter in the call to
`RepositoryFactoryDoctrineDBAL::getRepository`.

### PostgreSQL

```sh
$ psql -c "CREATE ROLE jackalope WITH ENCRYPTED PASSWORD '1234test' NOINHERIT LOGIN;" -U postgres
$ psql -c "CREATE DATABASE jackalope WITH OWNER = jackalope;" -U postgres
psql -c "CREATE ROLE jackalope WITH ENCRYPTED PASSWORD '1234test' NOINHERIT LOGIN;" -U postgres
psql -c "CREATE DATABASE jackalope WITH OWNER = jackalope;" -U postgres
```

### SQLite

Database is created automatically if you specify driver and path ("pdo_sqlite", "jackalope.db"). Database name is not needed.
Database is created automatically if you specify driver and path ("pdo_sqlite",
"jackalope.db"). Database name is not needed.

For further details, please see the [Doctrine configuration page](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connection-details).

### Oracle

Disclaimer: There is no continous integration with Oracle. Jackalope 1.8.0 was
Disclaimer: There is no continuous integration with Oracle. Jackalope 1.8.0 was
successfully tested by one of our users against `Oracle 19c Enterprise Edition`.
If you plan to use Jackalope with an Oracle Database, we recommend that you set
up the Jackalope test suite to ensure your version of Jackalope and Oracle work
Expand Down Expand Up @@ -232,12 +240,12 @@ use Jackalope\Transport\Logging\DebugStack;
$factory = new RepositoryFactoryDoctrineDBAL();
$logger = new DebugStack();

$options = [
$parameters = [
'jackalope.doctrine_dbal_connection' => $connection,
'jackalope.logger' => $logger,
];

$repository = $factory->getRepository($options);
$repository = $factory->getRepository($parameters);

//...

Expand All @@ -255,8 +263,8 @@ debug toolbar.
## Custom UUID generator

By default, Jackalope uses the UUIDHelper class from phpcr-utils. If you want
to use something else, you can provide a closure that returns UUIDs as option
`jackalope.uuid_generator` to `$factory->getRepository($options)`
to use something else, you can provide a closure that returns UUIDs as parameter
`jackalope.uuid_generator` to `$factory->getRepository($parameters)`


# Implementation notes
Expand Down
8 changes: 8 additions & 0 deletions src/Jackalope/RepositoryFactoryDoctrineDBAL.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class RepositoryFactoryDoctrineDBAL implements RepositoryFactoryInterface
public const JACKALOPE_DATA_CACHES = 'jackalope.data_caches';
public const JACKALOPE_CHECK_LOGIN_ON_SERVER = 'jackalope.check_login_on_server';
public const JACKALOPE_UUID_GENERATOR = 'jackalope.uuid_generator';
public const JACKALOPE_CASE_SENSITIVE_ENCODING = 'jackalope.case_sensitive_encoding';
public const JACKALOPE_LOGGER = 'jackalope.logger';
public const JACKALOPE_DISABLE_TRANSACTIONS = 'jackalope.disable_transactions';
public const JACKALOPE_DISABLE_STREAM_WRAPPER = 'jackalope.disable_stream_wrapper';
Expand All @@ -59,6 +60,8 @@ class RepositoryFactoryDoctrineDBAL implements RepositoryFactoryInterface
private static $optional = [
self::JACKALOPE_FACTORY => 'string or object: Use a custom factory class for Jackalope objects',
self::JACKALOPE_CHECK_LOGIN_ON_SERVER => 'boolean: if set to empty or false, skip initial check whether repository exists. Enabled by default, disable to gain a few milliseconds off each repository instantiation.',
self::JACKALOPE_UUID_GENERATOR => 'Closure: A callable that provides universally unique ids to overwrite the default generator.',
self::JACKALOPE_CASE_SENSITIVE_ENCODING => 'string: Define the collation for MySQL. Override if automatic determination fails.',
self::JACKALOPE_DISABLE_TRANSACTIONS => 'boolean: if set and not empty, transactions are disabled, otherwise transactions are enabled. If transactions are enabled but not actively used, every save operation is wrapped into a transaction.',
self::JACKALOPE_DISABLE_STREAM_WRAPPER => 'boolean: if set and not empty, stream wrapper is disabled, otherwise the stream wrapper is enabled and streams are only fetched when reading from for the first time. If your code always uses all binary properties it reads, you can disable this for a small performance gain.',
self::JACKALOPE_DATA_CACHES => 'array: an array of PSR-16 SimpleCache. Keys can be "meta" and "nodes", should be separate namespaces for best performance.',
Expand Down Expand Up @@ -108,6 +111,7 @@ public function getRepository(?array $parameters = null): RepositoryInterface
$canUseCache = array_key_exists(self::JACKALOPE_DATA_CACHES, $parameters)
&& array_key_exists('meta', $parameters[self::JACKALOPE_DATA_CACHES])
;
/** @var CachedClient|Client $transport */
$transport = $canUseCache
? $factory->get(CachedClient::class, [$dbConn, $parameters[self::JACKALOPE_DATA_CACHES]])
: $factory->get(Client::class, [$dbConn]);
Expand All @@ -120,6 +124,10 @@ public function getRepository(?array $parameters = null): RepositoryInterface
$transport->setUuidGenerator($parameters[self::JACKALOPE_UUID_GENERATOR]);
}

if (array_key_exists(self::JACKALOPE_CASE_SENSITIVE_ENCODING, $parameters)) {
$transport->setCaseSensitiveEncoding($parameters[self::JACKALOPE_CASE_SENSITIVE_ENCODING]);
}

if (array_key_exists(self::JACKALOPE_LOGGER, $parameters)) {
$transport = $factory->get(LoggingClient::class, [$transport, $parameters[self::JACKALOPE_LOGGER]]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ private function moveNode(string $srcAbsPath, string $destAbsPath): void
'path_prefix' => $srcAbsPath.'/%',
'path' => $srcAbsPath,
'workspace' => $this->workspaceName,
]);
]);

/*
* TODO: https://github.com/jackalope/jackalope-doctrine-dbal/pull/26/files#L0R1057
Expand Down

0 comments on commit dc07257

Please sign in to comment.