Ticket #4448 (closed defect: fixed)

Opened 1 year ago

Last modified 2 months ago

Update theme files

Reported by: neoen Assigned to: 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

4448.patch (0.8 kB) - added by pishmishy on 06/27/08 16:00:09.
checks return value of fopen()

Change History

06/13/07 16:15:08 changed by Otto42

  • status changed from new to closed.
  • resolution set to invalid.
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.

06/13/07 16:33:52 changed by rob1n

  • milestone deleted.

06/14/07 08:09:34 changed by neoen

  • status changed from closed to reopened.
  • resolution deleted.

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

06/15/07 07:50:40 changed by neoen

  • milestone set to 2.2.2.

06/15/07 16:42:30 changed by rob1n

  • milestone changed from 2.2.2 to 2.3 (trunk).

07/21/07 16:22:59 changed by Nazgul

  • milestone changed from 2.3 (trunk) to 2.4 (future).

03/07/08 14:43:37 changed by westi

  • keywords set to needs-patch.
  • milestone changed from 2.5 to 2.6.

Moving to 2.6

06/27/08 14:48:35 changed by pishmishy

Are you still experiencing this problem?

06/27/08 14:57:31 changed by Otto42

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.

06/27/08 16:00:09 changed by pishmishy

  • attachment 4448.patch added.

checks return value of fopen()

06/27/08 16:00:38 changed by pishmishy

  • keywords changed from needs-patch to has-patch.

06/27/08 20:14:51 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

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