#1951 - Icons missing for some uninstalled addons in Adminzone>Structure>Addons

Identifier #1951
Issue type Minor issue (breaks specific functionality)
Title Icons missing for some uninstalled addons in Adminzone>Structure>Addons
Status Completed
Handling member Chris Graham
Addon General / Uncategorised
Description For uninstalled addons that have a custom icon file and the icon file is defined in the addon_registry hook get_default_icon() method, the icon won't display in the Admin Zone Addons page because the icon file was uninstalled when the addon was uninstalled.

Steps to reproduce

Additional information There were at least a couple of ways to attack this bug. I chose to make an edit to the find_addon_icon() function in sources\addons.php where it returns the URL based on what is returned from the addon_registry hook. I changed this:

if (($ob !== null) && (method_exists($ob, 'get_default_icon'))) {
return get_base_url() . '/' . str_replace('%2F', '/', urlencode($ob->get_default_icon()));
}


to this:

if (($ob !== null) && (method_exists($ob, 'get_default_icon'))) {
$file = $ob->get_default_icon();
if (file_exists(get_file_base() . '/' . $file)) {
return get_base_url() . '/' . str_replace('%2F', '/', urlencode($ob->get_default_icon()));
} else {
require_code('mime_types');
$file = $ob->get_default_icon();
$image_data = tar_get_file($tar_file, $file);
if ($image_data === null) {
continue;
}
return 'data:' . get_mime_type(get_file_extension($file), true) . ';base64,' . base64_encode($image_data['data']);
}
}
}

If the addon_registry hook returns a file path of an existing icon file, it will use that icon file. If the addon_registry hook returns a file path that doesn't exist, it will use that path to try to get the file icon out of the addon .tar archive. If the icon file does not exist on disk or in the .tar archive, it should fall through to the end and use the icons/48x48/menu/_generic_admin/component icon.
Funded? No
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".

Rating

Unrated