Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#10181 closed defect (bug) (fixed)

Warnings after post/page save

Reported by: viper007bond's profile Viper007Bond Owned by:
Milestone: 2.8.1 Priority: normal
Severity: blocker Version: 2.8
Component: Autosave Keywords: has-patch needs-testing
Focuses: Cc:

Description

Inside the autosave box and after I save/publish a post or page, I get the following:

Warning: fopen(/var/www/hosted/finalgear.com/htdocs/.htaccess) [function.fopen]: failed to open stream: Operation not permitted in /var/www/hosted/finalgear.com/htdocs/wordpress/wp-admin/includes/misc.php on line 75

Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/hosted/finalgear.com/htdocs/wordpress/wp-admin/includes/misc.php on line 84

The second error message is repeated a few dozen times. Looks like it's trying to write to the .htaccess file every single time something is saved (which doesn't make sense).

Regardless, attached patch should silence the errors.

Attachments (2)

10181.patch (453 bytes) - added by Viper007Bond 16 years ago.
10181.diff (1.8 KB) - added by ryan 16 years ago.

Download all attachments as: .zip

Change History (10)

@Viper007Bond
16 years ago

#1 @Denis-de-Bernardy
16 years ago

  • Milestone changed from Future Release to 2.8.1

#2 @Denis-de-Bernardy
16 years ago

Rather than silencing it, we'd better nail down why it's writing it so many times.

The warning comes on IIS or apache?

#3 @Denis-de-Bernardy
16 years ago

  • Component changed from Administration to Autosave

#4 @Denis-de-Bernardy
16 years ago

posting the IRC logs for reference:

1:31 AM ddebernardy
I think there are two issues
1:31 AM Viper007Bond
there are
1:31 AM ddebernardy
one is we don't check that it's writable
1:31 AM Viper007Bond
(it is)
1:31 AM ddebernardy
the is_writable check is different for IIS and apache, but we can manage that
1:31 AM Viper007Bond
i'm on apache
1:31 AM
the file is 777
1:31 AM ddebernardy
the other is that we're trying to do this a dozen times, and that definitely isn't normal
1:32 AM Viper007Bond
one write per line or something
1:32 AM
foreach ( $markerdata as $n => $markerline ) {
1:32 AM
oh, wait, maybe not
1:32 AM
hmm
1:33 AM ddebernardy
nah, I'd think it's related to do_action(save_post) et al being called multiple times (once per post, and once per autosave, and once per revision, etc, and possibly more than once each
1:33 AM Viper007Bond
save_mod_rewrite_rules() is getting called too often
1:34 AM
infact it doesn't even need to be called at all when you save a post
1:34 AM
not since like 2.0.x
1:34 AM ddebernardy
it used to, when the rules were all in the htaccess file
1:34 AM Viper007Bond
yep
1:34 AM ddebernardy
but indeed, now they don't, we merely need to update the option thingy
1:35 AM
even then, though, we need to make sure it only ever gets called once when needed

#5 @Denis-de-Bernardy
16 years ago

  • Keywords needs-patch added; has-patch removed
1:45 AM rboren
We need a soft flush_rules() for use on page updates.
1:45 AM rboren
No writing to .htaccess unles verbose page rules are on.

@ryan
16 years ago

#6 @ryan
16 years ago

Untested patch adds hard and soft flushing.

#7 @Denis-de-Bernardy
16 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Haven't tested, but the logic seems correct. The other flush_rules need to be hard indeed. Had a doubt on the one for import, but seemed right too on second though.

#8 @ryan
16 years ago

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

(In [11579]) Don't write to htaccess every time page is saved. Add hard/soft flush flag to flush_rules(). Make sure fopen is successful and silence errors. Props Viper007Bond. fixes #10181 for 2.8.1

Note: See TracTickets for help on using tickets.