Skip to content

Commit 9541f5a

Browse files
committed
Merge pull request #67 from phpcr/always_use_absolute_path
Error on non-eistant file and expand path for profile
2 parents 9e7d72e + e2c4f5b commit 9541f5a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ alpha-4
1818
- [args] 28 instances of bad InputArgument constructor fixed
1919
- [node] `node:list` Catch exceptions when rendering property rows (e.g. on invalid references)
2020

21+
### Improvements
22+
23+
- [connect] Always expand relative paths for `db-path`
24+
- [connect] Throw exception if file indicated by `db-path` does not exist.
25+
2126
alpha-3
2227
-------
2328

src/PHPCR/Shell/Subscriber/ProfileFromSessionInputSubscriber.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,26 @@ public function handleProfileInit(ProfileInitEvent $e)
3838
);
3939

4040
foreach ($transportOptions as $optionName => $configName) {
41-
$profile->set('transport', $configName, (string) $input->getOption($optionName));
41+
$value = $input->getOption($optionName);
42+
43+
if (null !== $value) {
44+
// sanitize some input values
45+
switch ($optionName) {
46+
case 'db-path':
47+
if (!file_exists($value)) {
48+
throw new \InvalidArgumentException(sprintf(
49+
'DB file "%s" does not exist.'
50+
, $value));
51+
}
52+
53+
$value = realpath(dirname($value)) . DIRECTORY_SEPARATOR . basename($value);
54+
break;
55+
default:
56+
// all good
57+
}
58+
}
59+
60+
$profile->set('transport', $configName, (string) $value);
4261
}
4362

4463
foreach ($phpcrOptions as $optionName => $configName) {

0 commit comments

Comments
 (0)