Opened 6 years ago

Closed 5 years ago

#4448 closed defect (bug) (fixed)

Update theme files

Reported by: neoen Owned by: anonymous
Priority: high Milestone: 2.6
Component: Administration Version: 2.2
Severity: normal Keywords: has-patch
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 5 years ago.
checks return value of fopen()

Download all attachments as: .zip

Change History (12)

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

  • Milestone 2.2.1 deleted
  • 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...

  • Milestone set to 2.2.2
  • Milestone changed from 2.2.2 to 2.3 (trunk)
  • Milestone changed from 2.3 (trunk) to 2.4 (future)
  • Keywords needs-patch added
  • Milestone changed from 2.5 to 2.6

Moving to 2.6

Are you still experiencing this problem?

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.

checks return value of fopen()

  • Keywords has-patch added; needs-patch removed
  • 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.