• Plugin Name: Media Library Folders
    Plugin Version: 8.3.2 
    Problem: If a folder is deleted from the filesystem but Media Press Library see’s it as still existing. This happens:
    [05-Jun-2025 02:26:06 UTC] PHP Warning: scandir(/home/mysite/htdocs/www.mysite.com/wp-content/uploads/test): Failed to open directory: No such file or directory in /home/mysite/htdocs/www.mysite.com/wp-content/plugins/media-library-plus/media-library-plus.php on line 3910
    [05-Jun-2025 02:26:06 UTC] PHP Warning: scandir(): (errno 2): No such file or directory in /home/mysite/htdocs/www.mysite.com/wp-content/plugins/media-library-plus/media-library-plus.php on line 3910
    [05-Jun-2025 02:26:06 UTC] PHP Fatal error: Uncaught TypeError: array_diff(): Argument #1 ($array) must be of type array, false given in /home/mysite/htdocs/www.mysite.com/wp-content/plugins/media-library-plus/media-library-plus.php:3910
    Stack trace: 0 /home/mysite/htdocs/www.mysite.com/wp-content/plugins/media-library-plus/media-library-plus.php(3910): array_diff() 1 /home/mysite.com/htdocs/www.mysite.com/wp-content/plugins/media-library-plus/media-library-plus.php(5547): MGMediaLibraryFolders->max_sync_contents() 2 /home/mysite.com/htdocs/wwwmysite.com/wp-includes/class-wp-hook.php(324): MGMediaLibraryFolders->mlfp_run_sync_process() 3 /home/mysite/htdocs/www.mysite.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 4 /home/mysite/htdocs/www.mysite.comt/wp-includes/plugin.php(517): WP_Hook->do_action() 5 /home/mysite/htdocs/www.mysite.com/wp-admin/admin-ajax.php(192): do_action() 6 {main}thrown in /home/mysite/htdocs/www.mysite.com/wp-content/plugins/media-library-plus/media-library-plus.php on line 3910.

    Change: array_diff(scandir($path), [‘.’, ‘..’]);

    To: $scanned = @scandir($path);
    if (!is_array($scanned)) {
    $scanned = [];
    }
    $diff = array_diff($scanned, [‘.’, ‘..’]);

    • This topic was modified 9 months, 3 weeks ago by pbolduc99.
    • This topic was modified 9 months, 3 weeks ago by pbolduc99.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author AlanP57

    (@alanp57)

    The media library is actually a database and not a live picture of the file system. A folder should be deleted through Media Library Folder which should delete it from the file system and the database. In some cases, deleting a folder with Media Library Folder fails due to a folder containing a hidden file. In this case, first delete the folder from the file system and then from Media Library Folder.

    Thread Starter pbolduc99

    (@pbolduc99)

    I think what may have happened was my attempt to delete a folder using Media Library was denied because there were still contents in the folder. I had then deleted the folder manually from the file system when I notice the folder still appeared. Now Media Library still had them indexed when they no longer existed and using Media Library sync wasn’t observing the changes made to the file system. This caused problems and threw an error. My suggested fix worked as expected by eliminating the error from being displayed but I just needed to manually delete the file and folder references in Media folder library to clear the problem. The data itself does not live in the database, however it would be nice if phantom references exist in the database for a folder or file that Media Library would purge these references and only display what is current on the filesystem, instead of getting stuck with phantom references and mis-leading information being displayed in the Media Library. The Media Library should always reflect what is found on the file system not rely on stale cache which isn’t refreshed after a sync.

    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
    • This reply was modified 9 months, 3 weeks ago by pbolduc99.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Error in media-library-plus.php’ is closed to new replies.