#8830 closed defect (bug) (fixed)
wp_mkdir_p doesn't work with safe mode enabled
| Reported by: | remi | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Filesystem API | Version: | 2.7 |
| Severity: | normal | Keywords: | needs-patch bug-hunt |
| Cc: | Focuses: |
Description
The wp_mkdir_p function (which is used by many WP features like media uploading) doesn't work when PHP's safe-mode is enabled because it allows trailing slashes at the end of the directories it tries to create.
Adding this code at the beginning of the function solves the problem:
if (substr($target, -1) == "/") {
$target = substr($target, 0, -1);
}
Attachments (1)
Change History (16)
#7
@
17 years ago
- Keywords needs-patch added; has-patch needs-review removed
- Milestone 2.9 → Future Release
- Type defect (bug) → enhancement
$target = / is problematic.
#10
follow-up:
↓ 12
@
17 years ago
perhaps this should be added instead:
$target = untrailingslashit($target); if ( empty($target) ) $target = '/';
#11
@
17 years ago
- Type enhancement → defect (bug)
also, this is a defect, It doesnt operate correctly under safe mode.
#12
in reply to: ↑ 10
@
17 years ago
Replying to dd32:
perhaps this should be added instead:
$target = untrailingslashit($target); if ( empty($target) ) $target = '/';
Sounds good.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I'm not 100% this won't have side effects