Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Versioning Support #316

Open
wants to merge 16 commits into
base: 2.x
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"php": ">=5.3.3",
"doctrine/dbal": ">=2.4.5,<3.0.x-dev",
"phpcr/phpcr": "~2.1.2",
"phpcr/phpcr-utils": "^1.2.8",
"jackalope/jackalope": "~1.2.6"
"phpcr/phpcr-utils": "dev-versioning as 1.2.9",
"jackalope/jackalope": "dev-versioning as 1.3.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when ready, merge and release jackalope/jackalope#296 and then require versions that have that code.

},
"provide": {
"jackalope/jackalope-transport": "1.1.0"
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@

<exclude>
<!-- ignore whats not implemented yet -->
<directory>vendor/phpcr/phpcr/src/PHPCR/Version</directory>
<directory>vendor/jackalope/jackalope/src/Jackalope/Version</directory>

<directory>vendor/phpcr/phpcr/src/PHPCR/Lock</directory>
<directory>vendor/jackalope/jackalope/src/Jackalope/Lock</directory>

Expand Down
67 changes: 63 additions & 4 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Jackalope\Transport\DoctrineDBAL;

use Jackalope\Version\GenericVersioningInterface;
use Jackalope\Version\VersionHandler;
use PHPCR\LoginException;
use PHPCR\NodeType\NodeDefinitionInterface;
use PHPCR\NodeType\NodeTypeExistsException;
Expand All @@ -23,6 +25,7 @@
use PHPCR\PathNotFoundException;
use PHPCR\Query\InvalidQueryException;
use PHPCR\NodeType\ConstraintViolationException;
use PHPCR\UnsupportedRepositoryOperationException;
use PHPCR\Util\QOM\Sql2ToQomQueryConverter;
use PHPCR\Util\ValueConverter;
use PHPCR\Util\UUIDHelper;
Expand All @@ -48,6 +51,7 @@
use Jackalope\FactoryInterface;
use Jackalope\NotImplementedException;
use Jackalope\NodeType\NodeProcessor;
use PHPCR\Version\VersionException;

/**
* Class to handle the communication between Jackalope and RDBMS via Doctrine DBAL.
Expand All @@ -58,7 +62,7 @@
* @author Benjamin Eberlei <[email protected]>
* @author Lukas Kahwe Smith <[email protected]>
*/
class Client extends BaseTransport implements QueryTransport, WritingInterface, WorkspaceManagementInterface, NodeTypeManagementInterface, TransactionInterface
class Client extends BaseTransport implements QueryTransport, WritingInterface, WorkspaceManagementInterface, NodeTypeManagementInterface, TransactionInterface, GenericVersioningInterface
{
/**
* SQlite can only handle a maximum of 999 parameters inside an IN statement
Expand Down Expand Up @@ -189,6 +193,11 @@ class Client extends BaseTransport implements QueryTransport, WritingInterface,
*/
private $nodeProcessor;

/**
* @var VersionHandler
*/
private $versionHandler;

/**
* @param FactoryInterface $factory
* @param Connection $conn
Expand Down Expand Up @@ -1899,7 +1908,8 @@ private function getNodeProcessor()
$this->nodeProcessor = new NodeProcessor(
$this->credentials->getUserID(),
$this->getNamespacesObject(),
$this->getAutoLastModified()
$this->getAutoLastModified(),
$this->versionHandler
);

return $this->nodeProcessor;
Expand Down Expand Up @@ -2588,8 +2598,12 @@ public function rollbackSave()
public function updateProperties(Node $node)
{
$this->assertLoggedIn();
// we can ignore the operations returned, there will be no additions because of property updates
$this->getNodeProcessor()->process($node);

$additionalAddOperations = $this->getNodeProcessor()->process($node);

if (!empty($additionalAddOperations)) {
$this->storeNodes($additionalAddOperations);
}

$this->syncNode($node->getIdentifier(), $node->getPath(), $node->getPrimaryNodeType(), false, $node->getProperties());

Expand Down Expand Up @@ -2617,4 +2631,49 @@ private function initConnection()

$this->connectionInitialized = true;
}

/**
* {@inheritDoc}
*/
public function checkinItem($path)
{
return $this->versionHandler->checkinItem($path);
}

/**
* {@inheritDoc}
*/
public function checkoutItem($path)
{
return $this->versionHandler->checkoutItem($path);
}

/**
* {@inheritDoc}
*/
public function restoreItem($removeExisting, $versionPath, $path)
{
throw new NotImplementedException();
}

/**
* {@inheritDoc}
*/
public function removeVersion($versionPath, $versionName)
{
throw new NotImplementedException();
}

/**
* Sets the generic version handler delivered by jackalope
* @param VersionHandler $versionHandler
*/
public function setVersionHandler(VersionHandler $versionHandler)
{
if ($this->versionHandler) {
throw new \InvalidArgumentException('Version handler is already set');
}

$this->versionHandler = $versionHandler;
}
}
12 changes: 10 additions & 2 deletions tests/ImplementationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protected function __construct(Connection $connection, $fixturePath)
'SameNameSiblings', //TODO: Not implemented, no test currently written for it
'PermissionsAndCapabilities', //TODO: Transport does not support permissions
'Observation', //TODO: Transport does not support observation
'Versioning', //TODO: Transport does not support versioning
'Locking', //TODO: Transport does not support locking
);

Expand Down Expand Up @@ -82,7 +81,16 @@ protected function __construct(Connection $connection, $fixturePath)

// TODO: implement creating workspace with source
'WorkspaceManagement\\WorkspaceManagementTest::testCreateWorkspaceWithSource',
'WorkspaceManagement\\WorkspaceManagementTest::testCreateWorkspaceWithInvalidSource'
'WorkspaceManagement\\WorkspaceManagementTest::testCreateWorkspaceWithInvalidSource',

// TODO: implement remove version
'Versioning\\VersionHistoryTest::testDeleteVersion',
'Versioning\\VersionHistoryTest::testDeleteLatestVersion',
'Versioning\\VersionHistoryTest::testDeleteUnexistingVersion',
'Versioning\\VersionManagerTest::testRestoreByPathAndName',
'Versioning\\VersionManagerTest::testRestoreByVersionObject',
'Versioning\\VersionManagerTest::testRestoreRootVersion',
'Versioning\\VersionManagerTest::testWriteNotCheckedOutVersion',
);

if ($connection->getDatabasePlatform() instanceof Doctrine\DBAL\Platforms\SqlitePlatform) {
Expand Down
Loading