Make WordPress Core

Opened 18 years ago

Closed 17 years ago

#4448 closed defect (bug) (fixed)

Update theme files

Reported by: neoen's profile neoen Owned by:
Milestone: 2.6 Priority: high
Severity: normal Version: 2.2
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

Hello, when I try to update theme files (in Presentation - Theme Editor), there is no change of this file after. There is message "File was successfully changed" but no change was saved. When I deactivate all plugins, then there is following error:

Warning: fopen(d:\WWW\www.test.cz/wp-content/themes/blue-lake-10/style.css) [function.fopen]: failed to open stream: Permission denied in d:\WWW\www.test.cz\wp-admin\theme-editor.php on line 44

Warning: fwrite(): supplied argument is not a valid stream resource in d:\WWW\www.test.cz\wp-admin\theme-editor.php on line 45

Warning: fclose(): supplied argument is not a valid stream resource in d:\WWW\www.test.cz\wp-admin\theme-editor.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at d:\WWW\www.test.cz\wp-admin\theme-editor.php:44) in d:\WWW\www.test.cz\wp-admin\theme-editor.php on line 55

I found similar problems in support forum, for example http://wordpress.org/support/topic/105052 or http://wordpress.org/support/topic/78867
Thank you for your help...

Attachments (1)

4448.patch (857 bytes) - added by pishmishy 17 years ago.
checks return value of fopen()

Download all attachments as: .zip

Change History (12)

#1 @Otto42
18 years ago

  • Resolution set to invalid
  • Status changed from new to closed
Warning: fopen...[function.fopen]: failed to open stream: Permission denied

If this happens, then there's not much that can be done about it. Are the files read-only or something? Either way, this is a permissions issue, not a Wordpress error.

#2 @rob1n
18 years ago

  • Milestone 2.2.1 deleted

#3 @neoen
18 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Yes, I had sometimes permission problems, but in this case, there was not button "Update File". In this case of bad permission of files, this button does not appear. But now - this button appears, but no change (update). I also tried to change chmod with no success. And what about message "File was successfully changed" but no change happens? Thank you for your help...

#4 @neoen
18 years ago

  • Milestone set to 2.2.2

#5 @rob1n
18 years ago

  • Milestone changed from 2.2.2 to 2.3 (trunk)

#6 @Nazgul
18 years ago

  • Milestone changed from 2.3 (trunk) to 2.4 (future)

#7 @westi
17 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.5 to 2.6

Moving to 2.6

#8 @pishmishy
17 years ago

Are you still experiencing this problem?

#9 @Otto42
17 years ago

Yes, it is possible to create this error in some situations. The theme editor does an is_writable check before attempting to write the file, but is_writable is not reliable in all situations and it can return true even if the file is not accessible.

In theme-editor.php, this code:

	if (is_writeable($real_file)) {
		$f = fopen($real_file, 'w+');
		fwrite($f, $newcontent);
		fclose($f);
		$location = "theme-editor.php?file=$file&theme=$theme&a=te";
	} else {
		$location = "theme-editor.php?file=$file&theme=$theme";
	}

...has no error checking on the fopen. $f needs to be compared to === FALSE before attempting to fwrite and fclose it.

@pishmishy
17 years ago

checks return value of fopen()

#10 @pishmishy
17 years ago

  • Keywords has-patch added; needs-patch removed

#11 @ryan
17 years ago

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

(In [8208]) Check fopen return value. Props Otto42 and pishmishy. fixes #4448

Note: See TracTickets for help on using tickets.