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

Correctly publish new folders #1282

Merged
merged 1 commit into from Feb 7, 2020
Merged

Correctly publish new folders #1282

merged 1 commit into from Feb 7, 2020

Conversation

@leofeyer
Copy link
Member

leofeyer commented Feb 4, 2020

Fixes #1208

@leofeyer leofeyer added the defect label Feb 4, 2020
@leofeyer leofeyer added this to the 4.9 milestone Feb 4, 2020
@leofeyer leofeyer requested a review from contao/reviewers Feb 4, 2020
@leofeyer leofeyer self-assigned this Feb 4, 2020
Copy link
Contributor

aschempp left a comment

How does that code make a difference?

@leofeyer

This comment has been minimized.

Copy link
Member Author

leofeyer commented Feb 4, 2020

This is what happened:

$count = 0;
$strName = basename($strPath);

if (($strNewPath = str_replace($strName, Contao\Input::post('name'), $strPath, $count)) && $count > 0 && is_dir($rootDir . '/' . $strNewPath))

Then the code inspector said "$count > 0 costs less than the previous condition, so we switched to:

$count = 0;
$strName = basename($strPath);

if ($count > 0 && ($strNewPath = str_replace($strName, Contao\Input::post('name'), $strPath, $count)) && is_dir($rootDir . '/' . $strNewPath))

And then the if branch was no longer executed. 🤷‍♂

Now we are back at what we had before, only $strNewPath is declared before the if condition to not confuse the code inspector.

$count = 0;
$strName = basename($strPath);
$strNewPath = str_replace($strName, Contao\Input::post('name'), $strPath, $count);

if ($strNewPath && $count > 0 && is_dir($rootDir . '/' . $strNewPath))
Copy link
Contributor

aschempp left a comment

I see. Because $count is set by the str_replace call.

@leofeyer leofeyer merged commit fbefbf9 into 4.9 Feb 7, 2020
9 checks passed
9 checks passed
Coverage
Details
Coding Style
Details
PHP 7.2
Details
PHP 7.3
Details
PHP 7.4
Details
Prefer Lowest
Details
Bundles
Details
Windows
Details
codecov/project 89.89% remains the same compared to 231e0e9
Details
@leofeyer leofeyer deleted the bugfix/pusblish-new-folders branch Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.