WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 8 months ago

#16971 new defect (bug)

Creation of .htaccess file leads to a 500 Error

Reported by: hakre Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 3.0
Component: Rewrite Rules Keywords: has-patch needs-refresh
Focuses: Cc:

Description

Turning on permalinks can render the whole blog into a 500 error situation under certain conditions.

The issue has been experienced with a WP 3.0.5 setup, other versions seem affected as well.

The creation of the .htaccess file does not reflect the systems umask setting which can result in creating a file that is not accessible by the server.

That triggers the 500 then.

Normally WP chmod's all files it creates. This is not done with the .htaccess file if it did not existed already.

Attachments (2)

16971.patch (914 bytes) - added by hakre 3 years ago.
16971.2.patch (2.9 KB) - added by hakre 3 years ago.
Example only

Download all attachments as: .zip

Change History (11)

hakre3 years ago

comment:1 hakre3 years ago

Patch against trunk.

I'm not sure if FS_CHMOD_FILE is the correct value to refer to, for my case the 0644 (rw-r--r) would have done it which is the default for FS_CHMOD_FILE.

Related: #10170

comment:2 follow-up: ramoonus3 years ago

you say it also happens in other versions than 3.0.5
does that include 3.1?

comment:3 ramoonus3 years ago

  • Keywords dev-feedback added

comment:4 in reply to: ↑ 2 ; follow-up: hakre3 years ago

Replying to ramoonus:

you say it also happens in other versions than 3.0.5
does that include 3.1?

I said: "other versions seem affected as well".

I'm sure that 3.1 is affected as well as the code looks the same.

comment:5 hakre3 years ago

The flow in that function could be simplified to first check if a file exists or not and handle everything related to file creation upfront.

See the example attached which demonstrates this next to the following:

Then the replacement of the area(s) defined by $marker could be buffered and thanks to that simplified as well.

The second benefit of a buffer is that it can be written buffered to disc reducing I/O.

The function can benefit from defining the input variables, it's a bit unclear if $insertion must or can be an array. Not addressed in the example, just came to my mind.

hakre3 years ago

Example only

comment:6 in reply to: ↑ 4 ramoonus3 years ago

  • Component changed from General to Rewrite Rules
  • Keywords dev-feedback removed
  • Severity changed from normal to major
  • Version changed from 3.0.5 to 3.1

Replying to hakre:

Replying to ramoonus:

you say it also happens in other versions than 3.0.5
does that include 3.1?

I said: "other versions seem affected as well".

I'm sure that 3.1 is affected as well as the code looks the same.

comment:7 nacin3 years ago

  • Version changed from 3.1 to 3.0

OP said he could reproduce this on the 3.0 branch.

comment:9 c3mdigital8 months ago

  • Keywords needs-refresh added
Note: See TracTickets for help on using tickets.