/httpdocs/wp-content/plugins/download-manager/libs/class.AssetManager.php:246
-
I’m not sure when, but I’ve started getting some fatal errors with the Download Manager plugin which were completely blocking my website.
I got my website at least running again by making a change in
/httpdocs/wp-content/plugins/download-manager/libs/class.AssetManager.php:246after examining my error logs.I’m using PHP 8.0.5 and WPDM 3.1.27 .
The error in my logs is:
child 3917085 said into stderr: "NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: array_diff(): Argument #1 ($array) must be of type array, bool given in /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/download-manager/libs/class.AssetManager.php:246"function scanDir() { if (!isset($_REQUEST['__wpdm_scandir']) || !wp_verify_nonce($_REQUEST['__wpdm_scandir'], NONCE_KEY)) wp_send_json(array('success' => false, 'message' => __("Error! Session Expired. Try refreshing page.", "download-manager"))); check_ajax_referer(NONCE_KEY, '__wpdm_scandir'); if (!current_user_can('access_server_browser')) wp_send_json(array('success' => false, 'message' => __("Error! Unauthorized access.", "download-manager"))); global $current_user; $root = AssetManager::root(); $relpath = Crypt::decrypt(wpdm_query_var('path')); $path = AssetManager::root($relpath); if (!$path) wp_send_json(array('success' => false, 'message' => __("Error! Unauthorized Path.", "download-manager"))); $items = scandir($path, SCANDIR_SORT_ASCENDING); $items = array_diff($items, array('.', '..')); $_items = array(); $_dirs = array(); Session::set('working_dir', $path); foreach ($items as $item) { $item_label = $item; $item_label = esc_attr($item_label); //$item_label = strlen($item_label) > 30 ? substr($item_label, 0, 15) . "..." . substr($item_label, strlen($item_label) - 15) : $item_label; $ext = explode('.', $item); $ext = end($ext); $icon = \WPDM\libs\FileSystem::fileTypeIcon($ext); $type = is_dir($path . $item) ? 'dir' : 'file'; $note = is_dir($path . $item) ? (count(scandir($path . $item)) - 2) . ' items' : number_format((filesize($path . $item) / 1024), 2) . ' KB'; $rpath = str_replace($root, "", $path . $item); $wp_rel_path = str_replace(UPLOAD_DIR, '', $path . $item); $wp_rel_path = str_replace(ABSPATH, '', $wp_rel_path); $_rpath = Crypt::encrypt($rpath); if ($type === 'dir') { $_dirs[] = array('item_label' => $item_label, 'item' => $item, 'icon' => $icon, 'type' => $type, 'note' => $note, 'path' => $_rpath, 'id' => md5($rpath)); } else { $contenttype = function_exists('mime_content_type') ? mime_content_type($path . $item) : self::mimeType($item); $_items[] = array('item_label' => $item_label, 'item' => $item, 'icon' => $icon, 'type' => $type, 'contenttype' => $contenttype, 'note' => $note, 'path_on' => $path . $item, 'wp_rel_path' => $wp_rel_path, 'path' => $_rpath, 'id' => md5($rpath)); } } $allitems = $_dirs; foreach ($_items as $_item) { $allitems[] = $_item; } $parts = explode("/", $relpath); $breadcrumb[] = "<i class='fa fa-hdd color-purple'></i><a href='#' class='media-folder' data-path=''>" . __("Home", "download-manager") . "</a>"; $topath = array(); foreach ($parts as $part) { $topath[] = $part; $rpath = Crypt::encrypt(implode("/", $topath)); $breadcrumb[] = "<a href='#' class='media-folder' data-path='{$rpath}'>" . esc_attr($part) . "</a>"; } $breadcrumb = implode("<i class='fa fa-folder-open'></i>", $breadcrumb); if ((int)wpdm_query_var('dirs') === 1) wp_send_json($_dirs); else wp_send_json(array('success' => true, 'items' => $allitems, 'breadcrumb' => $breadcrumb, 'root' => $root, WPDM_ADMIN_CAP => current_user_can(WPDM_ADMIN_CAP), 'roles' => $current_user->roles)); die(); }I added an
elsecondition afterif (!path):function scanDir() { if (!isset($_REQUEST['__wpdm_scandir']) || !wp_verify_nonce($_REQUEST['__wpdm_scandir'], NONCE_KEY)) wp_send_json(array('success' => false, 'message' => __("Error! Session Expired. Try refreshing page.", "download-manager"))); check_ajax_referer(NONCE_KEY, '__wpdm_scandir'); if (!current_user_can('access_server_browser')) wp_send_json(array('success' => false, 'message' => __("Error! Unauthorized access.", "download-manager"))); global $current_user; $root = AssetManager::root(); $relpath = Crypt::decrypt(wpdm_query_var('path')); $path = AssetManager::root($relpath); if (!$path) { wp_send_json(array('success' => false, 'message' => __("Error! Unauthorized Path.", "download-manager"))); } else { $items = scandir($path, SCANDIR_SORT_ASCENDING); $items = array_diff($items, array('.', '..')); $_items = array(); $_dirs = array(); Session::set('working_dir', $path); foreach ($items as $item) { $item_label = $item; $item_label = esc_attr($item_label); //$item_label = strlen($item_label) > 30 ? substr($item_label, 0, 15) . "..." . substr($item_label, strlen($item_label) - 15) : $item_label; $ext = explode('.', $item); $ext = end($ext); $icon = \WPDM\libs\FileSystem::fileTypeIcon($ext); $type = is_dir($path . $item) ? 'dir' : 'file'; $note = is_dir($path . $item) ? (count(scandir($path . $item)) - 2) . ' items' : number_format((filesize($path . $item) / 1024), 2) . ' KB'; $rpath = str_replace($root, "", $path . $item); $wp_rel_path = str_replace(UPLOAD_DIR, '', $path . $item); $wp_rel_path = str_replace(ABSPATH, '', $wp_rel_path); $_rpath = Crypt::encrypt($rpath); if ($type === 'dir') { $_dirs[] = array('item_label' => $item_label, 'item' => $item, 'icon' => $icon, 'type' => $type, 'note' => $note, 'path' => $_rpath, 'id' => md5($rpath)); } else { $contenttype = function_exists('mime_content_type') ? mime_content_type($path . $item) : self::mimeType($item); $_items[] = array('item_label' => $item_label, 'item' => $item, 'icon' => $icon, 'type' => $type, 'contenttype' => $contenttype, 'note' => $note, 'path_on' => $path . $item, 'wp_rel_path' => $wp_rel_path, 'path' => $_rpath, 'id' => md5($rpath)); } } $allitems = $_dirs; foreach ($_items as $_item) { $allitems[] = $_item; } $parts = explode("/", $relpath); $breadcrumb[] = "<i class='fa fa-hdd color-purple'></i><a href='#' class='media-folder' data-path=''>" . __("Home", "download-manager") . "</a>"; $topath = array(); foreach ($parts as $part) { $topath[] = $part; $rpath = Crypt::encrypt(implode("/", $topath)); $breadcrumb[] = "<a href='#' class='media-folder' data-path='{$rpath}'>" . esc_attr($part) . "</a>"; } $breadcrumb = implode("<i class='fa fa-folder-open'></i>", $breadcrumb); } if ((int)wpdm_query_var('dirs') === 1) wp_send_json($_dirs); else wp_send_json(array('success' => true, 'items' => $allitems, 'breadcrumb' => $breadcrumb, 'root' => $root, WPDM_ADMIN_CAP => current_user_can(WPDM_ADMIN_CAP), 'roles' => $current_user->roles)); die(); }I have open_basedir restrictions in place, so the wordpress websites can only access their own spaces under httpdocs.
The topic ‘/httpdocs/wp-content/plugins/download-manager/libs/class.AssetManager.php:246’ is closed to new replies.