Skip to content

Commit ee22142

Browse files
committed
Various fixes:
Closes #146, #148
1 parent 0f42bea commit ee22142

13 files changed

+40
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ dev-master
1616
- [embedded] No exit code returned
1717
- [profile] Profile configuration overwritten by session parameters
1818
- [node:list] Incorrect node count
19+
- [node:edit] Multivalue references encoded as arrays when editing
20+
- [node:edit] Fixed undefined variable
21+
- [version] Versioning commands can use relative paths
1922

2023
beta1
2124
-----

features/all/phpcr_version_history.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Feature: Node Version History
77
Given that I am logged in as "testuser"
88
And the "versionable.xml" fixtures are loaded
99

10-
Scenario: Checkout a a given node
11-
Given I execute the "version:history /tests_version_base/versioned" command
10+
Scenario: Show history for a node
11+
When I execute the "version:history /tests_version_base/versioned" command
1212
Then the command should not fail
1313
And I should see a table containing the following rows:
1414
| Name | Created |
1515

1616
Scenario: History on a non versionable node
17-
Given I execute the "version:history /tests_version_base" command
17+
When I execute the "version:history /tests_version_base" command
1818
Then the command should fail
1919
And I should see the following:
2020
"""

features/all/phpcr_version_remove.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: Remove node version
88
And the "versionable.xml" fixtures are loaded
99

1010
Scenario: Checkout a a given node
11-
Given I execute the following commands:
11+
When I execute the following commands:
1212
| cd /tests_version_base/versioned |
1313
| version:checkout /tests_version_base/versioned |
1414
| node:property:set foo baz |
@@ -21,7 +21,7 @@ Feature: Remove node version
2121
And I execute the "version:remove /tests_version_base/versioned 1.0" command
2222
Then the command should not fail
2323
And I execute the "version:history /tests_version_base/versioned" command
24-
Then I should not see the following:
24+
And I should not see the following:
2525
"""
2626
| 1.0 |
2727
"""

features/all/phpcr_version_restore.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: Restore a version
88
And the "versionable.xml" fixtures are loaded
99

1010
Scenario: Restore node version
11-
Given I execute the following commands:
11+
When I execute the following commands:
1212
| cd /tests_version_base/versioned |
1313
| node:property:set foo initalbar |
1414
| session:save |

src/PHPCR/Shell/Config/ProfileLoader.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ public function loadProfile(Profile $profile)
8080
$profile->set('transport', $data['transport']);
8181
}
8282

83+
$profileWorkspace = $profile->get('phpcr', 'workspace');
8384
if (isset($data['phpcr'])) {
8485
$profile->set('phpcr', $data['phpcr']);
8586
}
87+
88+
// workspace argument overrides profile workspace
89+
if ($profileWorkspace && $profileWorkspace !== 'default') {
90+
$profile->set('phpcr', 'workspace', $profileWorkspace);
91+
}
8692
}
8793

8894
public function saveProfile(Profile $profile, $overwrite = false)

src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function execute(InputInterface $input, OutputInterface $output)
4646

4747
$workspace = $session->getWorkspace();
4848

49+
$start = microtime(true);
4950
$workspace->copy($srcAbsPath, $destAbsPath, $srcWorkspace);
51+
$end = microtime(true) - $start;
52+
$output->writeln(number_format($end, 6));
5053
}
5154
}

src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckinCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function execute(InputInterface $input, OutputInterface $output)
6868
$node = $session->getNodeByPathOrIdentifier($path);
6969
$nodeHelper->assertNodeIsVersionable($node);
7070

71-
$version = $versionManager->checkin($path);
71+
$version = $versionManager->checkin($node->getPath());
7272

7373
$output->writeln('Version: ' . $version->getName());
7474
}

src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function execute(InputInterface $input, OutputInterface $output)
5454
$nodeHelper->assertNodeIsVersionable($node);
5555

5656
$versionManager = $workspace->getVersionManager();
57-
$version = $versionManager->checkout($absPath);
57+
$version = $versionManager->checkout($node->getPath());
5858
}
5959
}

src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function execute(InputInterface $input, OutputInterface $output)
4343
$node = $session->getNodeByPathOrIdentifier($path);
4444
$nodeHelper->assertNodeIsVersionable($node);
4545
$versionManager = $workspace->getVersionManager();
46-
$version = $versionManager->checkpoint($path);
46+
$version = $versionManager->checkpoint($node->getPath());
4747

4848
$output->writeln('Version: ' . $version->getName());
4949
}

src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ public function execute(InputInterface $input, OutputInterface $output)
4040
$workspace = $session->getWorkspace();
4141

4242
$node = $session->getNodeByPathOrIdentifier($path);
43+
4344
$nodeHelper->assertNodeIsVersionable($node);
4445
$versionManager = $workspace->getVersionManager();
45-
$history = $versionManager->getVersionHistory($path);
46+
$history = $versionManager->getVersionHistory($node->getPath());
4647

4748
$versions = $history->getAllVersions();
4849

src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ protected function configure()
4848
public function execute(InputInterface $input, OutputInterface $output)
4949
{
5050
$session = $this->get('phpcr.session');
51+
$nodeHelper = $this->get('helper.node');
52+
$path = $input->getArgument('path');
5153

5254
$versionName = $input->getArgument('versionName');
53-
$path = $session->getAbsPath($input->getArgument('path'));
55+
$node = $session->getNodeByPathOrIdentifier($path);
56+
$nodeHelper->assertNodeIsVersionable($node);
57+
5458
$workspace = $session->getWorkspace();
5559
$versionManager = $workspace->getVersionManager();
5660

57-
$history = $versionManager->getVersionHistory($path);
61+
$history = $versionManager->getVersionHistory($node->getPath());
5862
$history->removeVersion($versionName);
5963
}
6064
}

src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ protected function configure()
4242
public function execute(InputInterface $input, OutputInterface $output)
4343
{
4444
$session = $this->get('phpcr.session');
45+
$nodeHelper = $this->get('helper.node');
46+
$path = $input->getArgument('path');
47+
48+
$node = $session->getNodeByPathOrIdentifier($path);
49+
$nodeHelper->assertNodeIsVersionable($node);
4550

46-
$path = $session->getAbsPath($input->getArgument('path'));
4751
$versionName = $input->getArgument('versionName');
4852
$removeExisting = $input->getOption('remove-existing');
4953
$workspace = $session->getWorkspace();
5054
$versionManager = $workspace->getVersionManager();
51-
$versionManager->restore($removeExisting, $versionName, $path);
55+
$versionManager->restore($removeExisting, $versionName, $node->getPath());
5256
}
5357
}

src/PHPCR/Shell/Serializer/NodeNormalizer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function normalize($node, $format = null, array $context = array())
5656
$propertyName = $property->getName();
5757

5858
if (in_array($property->getType(), array(PropertyType::REFERENCE, PropertyType::WEAKREFERENCE))) {
59-
$nodesUuids = array();
59+
$nodeUuids = array();
6060

6161
if (false === is_array($propertyValue)) {
6262
$propertyValue = array($propertyValue);
@@ -66,6 +66,10 @@ public function normalize($node, $format = null, array $context = array())
6666
$nodeUuids[] = $node->getIdentifier();
6767
}
6868
$propertyValue = $nodeUuids;
69+
70+
if (false === $property->isMultiple()) {
71+
$propertyValue = reset($propertyValue);
72+
}
6973
}
7074

7175
$res[$propertyName] = array(

0 commit comments

Comments
 (0)