WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#11712 closed defect (bug) (invalid)

Theme Editor -> "Sorry, that file cannot be edited."

Reported by: Frumph Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Filesystem API Keywords:
Focuses: Cc:

Description

What causes this error to come up, I heard it had something to do with a particular theme however it's still doing it with the default theme in wordpress 2.9.1 rc 1 and the svn 3.0 repo.

If this is a theme situation, what would cause this that I can look at in our code/plugins?

Change History (12)

comment:1 in reply to: ↑ description @Frumph6 years ago

Replying to Frumph:

What causes this error to come up, I heard it had something to do with a particular theme however it's still doing it with the default theme in wordpress 2.9.1 rc 1 and the svn 3.0 repo.

If this is a theme situation, what would cause this that I can look at in our code/plugins?

Yeah sorry, *NOT* doing it on default theme, so I know it's our theme, I just want to figure out what would cause it and clean that up in our theme.

comment:2 @scribu6 years ago

  • Milestone Unassigned deleted
  • Resolution set to invalid
  • Status changed from new to closed

Please post your question on the support forums or on the wp-hackers mailing list, providing the path of the file you're trying to edit.

comment:3 @Frumph6 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Reopening

function validate_file( in wp-includes/functions.php 
}}

is returning $file as not a valid comparison to the array

example:
{{{
 string(29) "/themes/comicpress/footer.php" 
}}}

however the array:

{{{
array(78) { [0]=>  string(59) "C:\inetpub\localhost/wp-content/themes/comicpress/style.css" 
}}}

because the C:\inetpub\localhost is there it will never come back with a correct value





comment:4 @scribu6 years ago

  • Component changed from General to Filesystem
  • Milestone set to 3.0

comment:5 @scribu6 years ago

  • Type changed from defect (bug) to enhancement

From the function doc:

A return value of '2' means that the $file contains ':' after the first character.

So it's documented behaviour.

No ideea why that restriction is imposed, so I'll leave it to someone more knowledgeable.

comment:6 @Frumph6 years ago

its returning a value of 3, not 2

comment:7 @Frumph6 years ago

	if (':' == substr( $file, 1, 1 ))
		return 2;

Note that it's currently checking $file, while file is string(29) "/themes/comicpress/footer.php"

thats why it's returning 3 because it actually stop ahead of that line at this:

	if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
		return 3;

which is actually before the return 2 in the function validate_file

comment:8 @Frumph6 years ago

..the bug here is that $file doesn't always return the full abspath with it so it doesn't match the array.

This is not an enhancement, it's a bug.

comment:9 @scribu6 years ago

  • Type changed from enhancement to defect (bug)

So it is. I need some sleep.

comment:10 @hakre6 years ago

Can you provide a link to the theme so other developers are more easy to reproduce the bug? That should help to solve the issue.

comment:11 @johncoswell6 years ago

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

The theme was using a variable in the global scope -- $dir -- that theme-editor.php was expecting to have full use of. This has been fixed in the latest revision of the theme.

comment:12 @nacin6 years ago

  • Milestone 3.0 deleted
Note: See TracTickets for help on using tickets.