Ticket #1082 (closed defect (bug): fixed)

Opened 7 years ago

Last modified 6 years ago

Superfluous newlines added to .htaccess on update

Reported by: Blu_Matt Owned by: ryan
Priority: normal Milestone: 2.1
Component: General Version: 2.0
Severity: minor Keywords: has-patch commit
Cc: Blu_Matt, sjmurdoch

Description

After a page update, when only the content has changed (i.e. no change to the page slug or choice of parent page) the .htaccess gets rewritten, undoing any customisations.

Attachments

stunt-htaccess.diff Download (780 bytes) - added by skeltoac 6 years ago.

Change History

  • Patch set to No
  • Version changed from 1.5 to 2.0
  • Milestone set to 2.0

I experience something similar: it adds blank lines everytime a page is edited (edited or moved). Eg every time I edit the content or move a page it adds 1 blank line, thus adding 1 byte.

  • Keywords bg|has-patch added
  • Owner changed from anonymous to ryan
  • Severity changed from enhancement to minor
  • Milestone changed from 2.0 to 2.0.1

Attached stunt-htaccess.diff fixes the newline issue.

If you are customizing .htaccess between the WordPress markers, you are cutting your own throat if you don't do it programmatically. Use the API or make the file unwritable.

comment:4   matt6 years ago

  • Milestone changed from 2.0.1 to 2.1
  • Cc sjmurdoch added
  • Component changed from Optimization to General
  • Summary changed from .htaccess rewritten after trivial page update to Superfluous newlines added to .htaccess on update

As the main point of this ticket seems to have moved from the fact that .htaccess is updated to that when it is updated, extra newlines are added (and the included patch fixes this), I have updated the summary accordingly.

This bug can be reproduced by clicking "Update Permanlink Structure >>" in "Customize Permalink Structure", even if no changes are made to the settings. This appears to be fixed by the attached patch.

  • Keywords bg|needs-testing bg|commit added

I

  • Keywords has-patch commit added; bg|has-patch bg|needs-testing bg|commit removed

I may be playing semantics but the reasoning is that the code should be checking if the N-th element in the array is the second to last element not if the N+1-th element is the last element.

This may be a little more meaninful:

+				if ($state) {
+					fwrite($f, "{$markerline}");
+					if ( $n < count($markerdata) - 1)
+						fwrite($f, "\n");
+				}

Either, this seems ready for a commit.

comment:9   ryan6 years ago

  • Status changed from new to closed
  • Resolution set to fixed

(In [3688]) Control those newlines. Props to that Andy guy. fixes #1082

Note: See TracTickets for help on using tickets.