-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Rulesets cannot be loaded if the path contains urlencoded characters #1089
Conversation
Your fix seems to be tailored just to undo result of urlencoding done by you.
Are you certain, that |
This might be a side effect of |
@aik099, this affects any project in a regular path containing %2F. For example, if you clone PHP_CodeSniffer into /tmp/PHP_CodeSniffer_%2F_new and run the tests: $ pwd $ php scripts/phpcs . --standard=PHPCS -np Warning: simplexml_load_file(): I/O warning : failed to load external entity "/tmp/PHP_CodeSniffer_%2F_new/CodeSniffer/Standards/PHPCS/ruleset.xml" in /tmp/PHP_CodeSniffer_%2F_new/CodeSniffer.php on line 714 Fatal error: Uncaught PHP_CodeSniffer_Exception: Ruleset /tmp/PHP_CodeSniffer_%2F_new/CodeSniffer/Standards/PHPCS/ruleset.xml is not valid in /tmp/PHP_CodeSniffer_%2F_new/CodeSniffer.php:716 |
According to documentation page (see http://php.net/manual/en/function.simplexml-load-file.php) since PHP 5.1 the |
Do you suggest opening a bug on PHP itself? |
Nope. I've just found out documented behavior in PHP that explains why it happens. Opening bug in PHP won't do us any good, because it will be fixed only in PHP 7.0.0. |
Can you please share your findings and maybe propose some other solution? |
Already did in #1089 (comment). I haven't copy-pasted relevant fragment from documentation, but just added a link to PHP website. Your solution does exactly what's needed, even though code looks very unusual for anyone without knowledge of that problem. |
When I read those docs, it suggests that from PHP 5.1.0, PHP should be taking care of the encoding for you so you don't need to wrap every call to |
Note that this PR only changes one of the lines where this function is used, so I'll do it to the other as well. |
Thanks for finding and fixing this. |
I had to revert this change because HHVM completely failed, but worked on all standard PHP versions. I ended up putting back the old code that used Thanks for reporting the issue. |
Thank you very much! |
phpcs versions beyond 2.6.1 fail to process xml files in directories containing "%2F". This is because of this change:
322fa24
We discovered this because we build all our sources via Jenkins which transforms / into %2F so a directory looks like:
/home/jenkins/workspace/project/feature%2Fname
This is needed because in Linux0, / is a directory separator and cannot be used as part of the directory/file name.
phpcs will print an error:
Warning: simplexml_load_file(): I/O warning : failed to load external entity "/home/jenkins/workspace/project/feature%2Fname/phpcs.xml" in /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 715
Fatal error: Uncaught PHP_CodeSniffer_Exception: Ruleset /home/jenkins/workspace/project/feature%2Fname/phpcs.xml is not valid in /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php:717
Stack trace:
#0 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php(562): PHP_CodeSniffer->processRuleset('/home/jenkins/w...')
#1 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(907): PHP_CodeSniffer->initStandard(Array, Array, Array)
#2 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(106): PHP_CodeSniffer_CLI->process()
#3 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/scripts/phpcs(25): PHP_CodeSniffer_CLI->ru in /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 717
PHP Warning: simplexml_load_file(): I/O warning : failed to load external entity "/home/jenkins/workspace/project/feature%2Fname/phpcs.xml" in /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 715
PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: Ruleset /home/jenkins/workspace/project/feature%2Fname/phpcs.xml is not valid in /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php:717
Stack trace:
#0 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php(562): PHP_CodeSniffer->processRuleset('/home/jenkins/w...')
#1 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(907): PHP_CodeSniffer->initStandard(Array, Array, Array)
#2 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(106): PHP_CodeSniffer_CLI->process()
#3 /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/scripts/phpcs(25): PHP_CodeSniffer_CLI->ru in /home/jenkins/workspace/project/feature%2Fname/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 717
Reference:
doctrine/orm#5705