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

Overwrite .htaccess file after deleting rules even if there is no content #6723

Conversation

tkalimullin-coludlinux
Copy link
Contributor

Description

Fixed the process of clearing the .htaccess file in cases where the .htaccess file was empty.

Documentation

User documentation

If during deactivation of the plugin there are no other rules that relate to WordPress, then the WP Rocket rules will not be deleted.

Technical documentation

The fwrite function will not write changes to a file if the $new_file_data variable is empty.
Even though fwrite returns 0, which is not an error, the following condition will not work:

if ( $bytes ) {
 ftruncate( $pointer, ftell( $pointer ) );
}

It is necessary to clearly determine that no error occurred when trying to work with the file, and only in this case do not try to truncate the file:

if ( $bytes !== false ) {
 ftruncate( $pointer, ftell( $pointer ) );
}

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Checklists

Code style

  • [+] I wrote self-explanatory code about what it does.
  • [+] I did not introduce unecessary complexity.

@MathieuLamiot MathieuLamiot requested review from Tabrisrp and a team July 1, 2024 08:42
@MathieuLamiot
Copy link
Contributor

CI tests are failing. Moving this back to "Todo" to be investigated.

@MathieuLamiot MathieuLamiot added the priority: low Issues that can wait label Jul 11, 2024
@Mai-Saad Mai-Saad self-requested a review July 15, 2024 07:21
@Mai-Saad
Copy link
Contributor

Working as expected, if nothing is needed for unit tests, we can merge this
testrail-report-615.pdf

@Tabrisrp Tabrisrp added this pull request to the merge queue Jul 15, 2024
Merged via the queue into wp-media:develop with commit 797981e Jul 15, 2024
5 of 12 checks passed
@piotrbak piotrbak added this to the 3.16.3 milestone Jul 15, 2024
@Tabrisrp Tabrisrp mentioned this pull request Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low Issues that can wait
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants