Skip to content

Commit e2c4f5b

Browse files
committed
Error on non-eistant file and expand path for profile
- Throw an exception if the file specified by `db-path` does not exist. - Always expand the path to an absolute path for storage in profile.
1 parent 3d0bc36 commit e2c4f5b

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
@@ -15,6 +15,11 @@ alpha-4
1515
- [args] 28 instances of bad InputArgument constructor fixed
1616
- [node] `node:list` Catch exceptions when rendering property rows (e.g. on invalid references)
1717

18+
### Improvements
19+
20+
- [connect] Always expand relative paths for `db-path`
21+
- [connect] Throw exception if file indicated by `db-path` does not exist.
22+
1823
alpha-3
1924
-------
2025

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)