Make WordPress Core

Opened 20 years ago

Closed 18 years ago

Last modified 3 years ago

#3068 closed enhancement (wontfix)

Normalize working directory for plug-ins

Reported by: shadytrees Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: minor Keywords:
Cc: Focuses:

Description

For plug-ins, the working directory can vary for similar actions. comment_post can have a cwd of / (when a guest posts a comment to a post) while delete_comment can have a cwd of /wp-admin (when an administrator deletes a comment).

I ran into this when trying to figure out why a file to which I was (over)writing from a plug-in wasn't changing for all hooks. It (embarrassingly) took me a while to realize the file was in two different locations, / and /wp-admin, depending on the hook.

Could Wordpress normalize the cwd to / or something similar for plug-ins? For example, change the working directory to / before firing plug-in hooks.

Sorry if duplicate; my Trac search-fu isn't up to snuff.

Attachments (2)

testcase.php (686 bytes ) - added by shadytrees 20 years ago.
An example cache plug-in that could write data to two different places
normalize_working_directory.patch (1.2 KB ) - added by shadytrees 20 years ago.
Example patch (just for generating ideas) 3: moving outside the foreach loop

Download all attachments as: .zip

Change History (9)

@shadytrees
20 years ago

An example cache plug-in that could write data to two different places

#1 @RuddO
20 years ago

I second that case, after submitting the bug "damn, why doesn't my WP find my wp-config.php if WP is built out of symlinks?"

#2 @shadytrees
20 years ago

  • Keywords has-patch added

Adding has-patch keyword; hoping it'll attract more attention. :)

@shadytrees
20 years ago

Example patch (just for generating ideas) 3: moving outside the foreach loop

#3 @ryan
20 years ago

getcwd() and chdir() are unreliable. safe_mode can cripple them, and many hosts disable them.

#4 @shadytrees
20 years ago

Is there any interest in doing this in alternative ways, or is this ticket moot?

#5 @Nazgul
19 years ago

  • Keywords has-patch removed
  • Milestone2.4 (future)

#6 @DD32
19 years ago

  • Milestone 2.42.5

#7 @jacobsantos
18 years ago

  • Milestone 2.9
  • Resolutionwontfix
  • Status newclosed

You should use the constants WordPress provides in order to know where your plugin is located. There are other constants that should be used instead of this method.

Note: See TracTickets for help on using tickets.