Merged
Conversation
schlessera
requested changes
Jul 10, 2018
src/MakePotCommand.php
Outdated
| } | ||
|
|
||
| // Determine destination. | ||
| $this->destination = $this->source . DIRECTORY_SEPARATOR . $this->slug . '.pot'; |
Member
There was a problem hiding this comment.
The use of DIRECTORY_SEPARATOR is actually not a good practice here. That constant should be sued for functions like explode() or (r|l)trim. If you compose a filesystem string for the server, just use / instead.
So, I'd write this line as follows:
$this->destination = "{$this->source}/{$this->slug}.pot";
Member
Author
There was a problem hiding this comment.
Thanks, that makes sense!
src/MakePotCommand.php
Outdated
|
|
||
| if ( ! empty( $file_data['Domain Path'] ) ) { | ||
| // Domain Path inside source folder. | ||
| $this->destination = $this->source . DIRECTORY_SEPARATOR . $file_data['Domain Path'] . DIRECTORY_SEPARATOR . $this->slug . '.pot'; |
Member
There was a problem hiding this comment.
Again, use of DIRECTORY_SEPARATOR counterproductive here.
| * @return string String without leading and trailing slashes. | ||
| */ | ||
| protected function unslashit( $string ) { | ||
| return ltrim( rtrim( $string, '/\\' ), '/\\' ); |
Member
There was a problem hiding this comment.
This would actually be a good use of DIRECTORY_SEPARATOR. However, as we are not quite sure what we get and what we already did with it, I'd say we leave it as is now to stay on the safe side (especially with Cygwin on Windows).
schlessera
approved these changes
Jul 10, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #41.
Note: while working on this I uncovered a bug in the destination file determination.
It previously used
isset()to check whether theDomain Pathheader was present. However, it is always set, but can be empty.This meant that the default value,
$this->destination = $this->slug . '.pot';was never used. Also, that default value is wrong anyway as it doesn't generate the POT file in the plugin's directory, but the current working dir.