Make php -a
history conform to XDG Base Directory Specification
#12587
+55
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves GH-8546.
To keep existing installations working the code first checks if a history file already exists at
~/.php_history
. If it does, then everything works as before.If
~/.php_history
does not exist, we check whether the system supports the XDG Base Directory Specification. If it doesn't we continue using~/.php_history
; otherwise, we use a path that conforms to the XDG Base Directory Specification.We detect support for XDG Base Directory Specification by checking for environment variables that start with the
XDG_
prefix. This is analogous to what Composer does:composer/composer#1407
The specification can be found here:
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Suggestions on how to implement automated tests for this are welcome. 😸