WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#3068 closed enhancement (wontfix)

Normalize working directory for plug-ins

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

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 10 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 10 years ago.
Example patch (just for generating ideas) 3: moving outside the foreach loop

Download all attachments as: .zip

Change History (9)

@shadytrees
10 years ago

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

#1 @RuddO
10 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
10 years ago

  • Keywords has-patch added

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

@shadytrees
10 years ago

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

#3 @ryan
10 years ago

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

#4 @shadytrees
10 years ago

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

#5 @Nazgul
9 years ago

  • Keywords has-patch removed
  • Milestone set to 2.4 (future)

#6 @DD32
9 years ago

  • Milestone changed from 2.4 to 2.5

#7 @jacobsantos
8 years ago

  • Milestone 2.9 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

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.