#41329 closed defect (bug) (wontfix)
Undefined constants in class WP_Filesystem_Direct
Reported by: | nabil_kadimi | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9 |
Component: | Filesystem API | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
I'm using the WordPress filesystem classes, it seems the classes assume some constants are always defined.
Anyways, the errors:
Notice: Use of undefined constant FS_CHMOD_FILE - assumed 'FS_CHMOD_FILE' in /var/www/public/wp-admin/includes/class-wp-filesystem-direct.php on line 152 Notice: Use of undefined constant FS_CHMOD_FILE - assumed 'FS_CHMOD_FILE' in /var/www/public/wp-admin/includes/class-wp-filesystem-direct.php on line 152 Notice: Use of undefined constant FS_CHMOD_FILE - assumed 'FS_CHMOD_FILE' in /var/www/public/wp-admin/includes/class-wp-filesystem-direct.php on line 152
I thought I would suggest a patch...
Thanks,
Nabil
Attachments (1)
Change History (9)
#1
@
7 years ago
- Summary changed from Undefined constants in WP_class Filesystem_Direct to Undefined constants in class WP_Filesystem_Direct
#3
@
7 years ago
To reproduce:
<?php require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; $filesystem = new WP_Filesystem_Direct();
This ticket was mentioned in Slack in #core by nabil_kadimi. View the logs.
7 years ago
#5
@
7 years ago
- Focuses performance removed
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
WP_Filesystem_Direct()
is not designed to be used stand alone. Plugins shouldn't use it if they simply want to modify files directly on the filesystem, instead they should use functions such as file_get_contents()
directly.
WP_Filesystem_Direct
should only be accessed through using the WP_Filesystem()
method (found in wp-admin/includes/file.php). If you're using it in any other way, you're complicating your own code and increasing the chances of your code breaking in the future.
#6
@
7 years ago
Thanks for your feedback @dd32, I had to use WP_Filesystem
instead of file_get_contents()
in order to have my theme pass Theme Checker validations.
Thanks for the advice about not using WP_Filesystem_Direct
.
Patch