Skip to content

Commit

Permalink
Fixed some problems with addons
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgraham committed Jul 27, 2018
1 parent 2687153 commit a53d6c5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions adminzone/pages/modules/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,9 @@ public function search()
$tar = tar_open(get_custom_file_base() . '/imports/addons/' . $f, 'rb');
$directory = tar_get_directory($tar);
$info_file = tar_get_file($tar, 'addon.inf');
if ($info_file === null) {
$info_file = tar_get_file($tar, 'mod.inf'); // LEGACY
}
tar_close($tar);
if (!is_null($info_file)) {
$info = better_parse_ini_file(null, $info_file['data']);
Expand Down
19 changes: 17 additions & 2 deletions sources/addons2.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ function find_available_addons($installed_too = true, $gather_mtimes = true, $al
require_code('tar');
$tar = tar_open($full, 'rb', true);
$info_file = tar_get_file($tar, 'addon.inf', true);
if ($info_file === null) {
$info_file = tar_get_file($tar, 'mod.inf'); // LEGACY
}
tar_close($tar);

if (!is_null($info_file)) {
Expand Down Expand Up @@ -600,7 +603,10 @@ function install_addon($file, $files = null, $do_files = true, $do_db = true)
require_code('tar');
$tar = tar_open($full, 'rb');
$info_file = tar_get_file($tar, 'addon.inf');
if (is_null($info_file)) {
if ($info_file === null) {
$info_file = tar_get_file($tar, 'mod.inf'); // LEGACY
}
if ($info_file === null) {
warn_exit(do_lang_tempcode('NOT_ADDON'));
}
$info = better_parse_ini_file(null, $info_file['data']);
Expand Down Expand Up @@ -710,6 +716,9 @@ function install_addon($file, $files = null, $do_files = true, $do_db = true)
if ($addon_file == 'addon.inf') {
continue;
}
if ($addon_file == 'mod.inf') { // LEGACY
continue;
}
if ($addon_file == 'addon.php') {
continue;
}
Expand Down Expand Up @@ -836,7 +845,7 @@ function uninstall_addon($addon, $clear_caches = true)
if (preg_match('#^sources(_custom)?/hooks/systems/config/([^/]*)\.php#', $filename, $matches) != 0) {
delete_config_option($matches[2]);
}
if (($filename != 'addon.inf') && ($filename != 'addon_install_code.php') && ($filename != '') && (substr($filename, -1) != '/')) {
if (($filename != 'addon.inf') && ($filename != 'mod.inf'/*LEGACY*/) && ($filename != 'addon_install_code.php') && ($filename != '') && (substr($filename, -1) != '/')) {
$last[] = $filename;
}
}
Expand Down Expand Up @@ -919,6 +928,9 @@ function inform_about_addon_install($file, $also_uninstalling = null, $also_inst
$tar = tar_open($full, 'rb');
$directory = tar_get_directory($tar);
$info_file = tar_get_file($tar, 'addon.inf');
if ($info_file === null) {
$info_file = tar_get_file($tar, 'mod.inf'); // LEGACY
}
if (is_null($info_file)) {
warn_exit(do_lang_tempcode('NOT_ADDON'));
}
Expand All @@ -942,6 +954,9 @@ function inform_about_addon_install($file, $also_uninstalling = null, $also_inst
if ($entry['path'] == 'addon.inf') {
continue;
}
if ($entry['path'] == 'mod.inf') { // LEGACY
continue;
}
if ($entry['path'] == 'addon_install_code.php') {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function tar_extract_to_folder(&$resource, $path, $use_afm = false, $files = nul
$directory = $resource['directory'];

foreach ($directory as $file) {
if (($file['path'] != 'addon.inf') && ($file['path'] != 'addon_install_code.php') && ((is_null($files)) || (in_array($file['path'], $files)))) {
if (($file['path'] != 'addon.inf') && ($file['path'] != 'mod.inf'/*LEGACY*/) && ($file['path'] != 'addon_install_code.php') && ((is_null($files)) || (in_array($file['path'], $files)))) {
// Special case for directories. Composr doesn't add directory records, but at least 7-zip does
if (substr($file['path'], -1) == '/') {
if (!$use_afm) {
Expand Down
4 changes: 4 additions & 0 deletions uploads/website_specific/compo.sr/upgrades/make_upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ function make_upgrade_get_path($from_version_dotted, $to_version_dotted, $addons
if ($addons_in_upgrader !== null) {
@mkdir($wip_path . '/exports', 0777);
@mkdir($wip_path . '/exports/addons', 0777);
@mkdir($wip_path . '/imports', 0777);
@mkdir($wip_path . '/imports/addons', 0777);

// Build all addon TARs
global $CACHE_FROM_ADDONS;
Expand All @@ -175,6 +177,8 @@ function make_upgrade_get_path($from_version_dotted, $to_version_dotted, $addons
null,
$new_base_path
);

rename($wip_path . '/exports/addons/' . $addon . '.tar', $wip_path . '/imports/addons/' . $addon . '.tar');
}
}

Expand Down

0 comments on commit a53d6c5

Please sign in to comment.