Skip to content
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

Fix handling of `__FILE__` and `__DIR__` constants in `eval()`'d code. #38

Merged
merged 2 commits into from Apr 10, 2019

Conversation

@schlessera
Copy link
Member

commented Apr 10, 2019

Using a regular expression to match all __FILE__ and __DIR__ constants that are not wrapped in quotes ( see https://regex101.com/r/9hXp5d/2/ ), we replace these with single-quoted strings that are the realpath() of the current file, or the dirname() of that file, respectively.

Fixes #37

schlessera added some commits Apr 10, 2019

@schlessera schlessera requested a review from wp-cli/committers as a code owner Apr 10, 2019

@danielbachhuber danielbachhuber added this to the 2.0.3 milestone Apr 10, 2019

@danielbachhuber
Copy link
Member

left a comment

Nice find!

@danielbachhuber danielbachhuber merged commit fc44091 into master Apr 10, 2019

2 checks passed

DEP All dependencies are resolved
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@delete-merged-branch delete-merged-branch bot deleted the 37-fix-file-constant branch Apr 10, 2019

@t-my

This comment has been minimized.

Copy link

commented May 9, 2019

This caused regression while running from crontab file, require 'file.php' didn't work anymore as previously, requiring the file in the same folder than the called script.

I had crontab * * * * * wp eval-file /directory/script.php

script.php: require 'file.php'

and the /directory contained file.php

Got error from the script.php file: unable to find file.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.