• I’m trying to get direct access to the filesystem in wordpress so i can stream a file to another location.
    WP_Filesystem() always returns false. The file i try to read is in the wp-content/uploads folder which the www-data user has full access to, www-data user is owner of the entire wp-content folder. I have even tried setting all the folders in the entire app to 777.

    My code runs in a filter attached to the media upload.

    I’m hosting the app using the php:7.1-apache docker image.
    I don’t understand how to troubleshoot this.

    • This topic was modified 6 years, 11 months ago by alexgrip.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Examine the function’s source code and determine under what conditions it returns false. If needed, temporarily add debug code to the source file (uploading to the server after each edit) to help you determine where the false is coming from. Be sure to maintain a clean backup or otherwise keep track of edits so the default state can be restored.

    You may have to drill down into other functions in order to zero in on the true cause. Once you find out exactly why false is being returned, hopefully that will indicate what needs to be done to resolve the problem.

    Thread Starter alexgrip

    (@alexgrip)

    ok, so the problem was that when checking what type of FS access to get wp compares
    owner on __FILE__ constant
    /var/www/html/wp-admin/includes/file.php
    with a temp file
    /var/www/html/wp-content/temp-write-test-1513759002

    I hade only set owner to www-data on wp-content, so the compare was a miss causing it to fallback to ftp access. Setting owner in wp-admin as well solved it.

    @bcworkz thanks for pointing me in the right direction.

    Moderator bcworkz

    (@bcworkz)

    Heh, quite the process to discover a owner issue. Whatever gets us there ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problems calling WP_Filesystem’ is closed to new replies.