Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#1082 closed defect (bug) (fixed)

Superfluous newlines added to .htaccess on update

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


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 (1)

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

Download all attachments as: .zip

Change History (10)

comment:1 @Blu_Matt10 years ago

  • Patch set to No

comment:2 @dissurion9 years ago

  • Milestone set to 2.0
  • Version changed from 1.5 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.

comment:3 @skeltoac9 years ago

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

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.

@skeltoac9 years ago

comment:4 @matt9 years ago

  • Milestone changed from 2.0.1 to 2.1

comment:5 @sjmurdoch9 years ago

  • Cc sjmurdoch added

comment:6 @sjmurdoch9 years ago

  • 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.

comment:7 @davidhouse9 years ago

  • Keywords bg|needs-testing bg|commit added


comment:8 @abhay9 years ago

  • 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 @ryan9 years ago

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

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

Note: See TracTickets for help on using tickets.