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 leofeyer commented Feb 4, 2020

Fixes #1208

@leofeyer leofeyer added the bug label Feb 4, 2020
@leofeyer leofeyer added this to the 4.9 milestone Feb 4, 2020
@leofeyer leofeyer requested a review from a team February 4, 2020 13:55
@leofeyer leofeyer self-assigned this Feb 4, 2020
Copy link
Member

@aschempp aschempp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does that code make a difference?

@leofeyer
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
Member

@aschempp aschempp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@leofeyer leofeyer merged commit fbefbf9 into 4.9 Feb 7, 2020
@leofeyer leofeyer deleted the bugfix/pusblish-new-folders branch February 7, 2020 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants