-
Notifications
You must be signed in to change notification settings - Fork 30
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
Allow node names to be passed to getNodeName #95
Conversation
Hm, the phpdoc ja quite clear that you must pass valid absolute paths to this method. Can you Post a Link where you call this? If its user input, you might rather absolutize and normalize first. Imagine i type .. to get up one level. |
Infact its used in phpcr-utils: https://github.com/phpcr/phpcr-utils/blob/master/src/PHPCR/Util/Console/Command/NodeTouchCommand.php#L108 If the spec says the path should be absolute I should fix that in my code -- but maybe we should throw an exception if there are no path delimiters in the given "path", otherwise $nodeName = PathHelper::nodeName('foobar');
echo $nodeName; yields |
okay, regardless of this, the touch command should validate that the path is absolute and throw an error if its not absolute. there is no context available there, and i think there is little value in creating nodes unter the root node if you do not specify the leading slash. |
what should we do here? validate the parameter to getNodeName? i am a bit concerned about the overhead we generate for this. maybe we should just insist that this must be an absolute path, or do a simpler check for a leading slash? and add validation in the touch command parameter? |
@dantleech would you agree with my proposal to add validation in the touch command and just specify that the client code must be sure to pass in a valid absolute path to getNodeName? constantly validating any parameters could get rather expensive. |
Not sure, I think if we allow this behavior it is going to make people scratch their heads in the future. But looking at the code again, we could do this without any "overhead": $strpos = strpos($path, '/');
if (false === $strpos) { throw Exception(); }
return substr($path, $strpos + 1); |
okay, that makes sense. lets use can you update the PR? |
if you can update this way, we can merge and tag 1.1.0-RC1 hopefully. |
Updated. |
Allow node names to be passed to getNodeName
great, thanks! |
hmm, this causes problems in jackalope-doctrine-dbal:
|
this was because of very bad mocking code in TestCase, see jackalope/jackalope#199 |
This was required in my shell where the path arguments are sometimes relative node names,