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

Don't remove static files if automated static files are turned off #14228

Merged
merged 1 commit into from Jan 12, 2019
Merged

Don't remove static files if automated static files are turned off #14228

merged 1 commit into from Jan 12, 2019

Conversation

Jako
Copy link
Collaborator

@Jako Jako commented Dec 31, 2018

This really fixes the issue where old static files where removed even if the automate static files system setting was turned off for that element type. It was only partly fixed in #14208, which added a check for removing the file, when the static file path was changed.

What does it do?

A check for the automatic static files system setting is added to the modElementRemoveProcessor class.

Related issue(s)/PR(s)

Issue: #14206, #140206
PR that created the issue: #14135

@Jako Jako added bug The issue in the code or project, which should be addressed. area-core pr/review-needed Pull request requires review and testing. labels Dec 31, 2018
@Jako Jako added this to the v2.7.1 milestone Dec 31, 2018
}

/* Check if parent directory is empty, if so remove parent directory. */
$pathinfo = pathinfo($this->staticFilePath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$pathinfo = pathinfo($this->staticFilePath);
$dirname = pathinfo($this->staticFilePath, PATHINFO_DIRNAME);

/* Check if parent directory is empty, if so remove parent directory. */
$pathinfo = pathinfo($this->staticFilePath);

if (!empty($pathinfo['dirname'])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To me it would make more sense to check for things like this in the cleanupStaticDirectories method to prevent code duplication.

$pathinfo = pathinfo($this->staticFilePath);

if (!empty($pathinfo['dirname'])) {
$this->cleanupStaticDirectories($pathinfo['dirname']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->cleanupStaticDirectories($pathinfo['dirname']);
$this->cleanupStaticDirectories($dirname);

@Jako
Copy link
Collaborator Author

Jako commented Jan 1, 2019

@JoshuaLuckers I agree with your review, but code changes that are not bugfixes should be done in 3.x.

Copy link
Collaborator

@Mark-H Mark-H left a comment

Choose a reason for hiding this comment

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

👍

@Mark-H Mark-H added pr/ready-for-merging Pull request reviewed and tested and ready for merging. and removed pr/review-needed Pull request requires review and testing. labels Jan 9, 2019
@alroniks alroniks self-assigned this Jan 9, 2019
@alroniks alroniks merged commit 79e8c21 into modxcms:2.x Jan 12, 2019
alroniks pushed a commit that referenced this pull request Jan 12, 2019
…4228

* upstream/pr/14228:
  Don't remove static files if automated static files are turned off
@Jako Jako deleted the fix-14206 branch January 12, 2019 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core bug The issue in the code or project, which should be addressed. pr/ready-for-merging Pull request reviewed and tested and ready for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants