WordPress.org

Make WordPress Core

Opened 8 years ago

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

Download all attachments as: .zip

Change History (9)

shadytrees8 years ago

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

comment:1 RuddO8 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?"

comment:2 shadytrees8 years ago

  • Keywords has-patch added

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

shadytrees8 years ago

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

comment:3 ryan8 years ago

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

comment:4 shadytrees8 years ago

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

comment:5 Nazgul7 years ago

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

comment:6 DD326 years ago

  • Milestone changed from 2.4 to 2.5

comment:7 jacobsantos6 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.