Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot reinstall module - addReturnTab function error #32

Open
damiweb opened this issue Jul 18, 2019 · 0 comments
Open

Cannot reinstall module - addReturnTab function error #32

damiweb opened this issue Jul 18, 2019 · 0 comments

Comments

@damiweb
Copy link

damiweb commented Jul 18, 2019

This function doesn't check if Tab already exists. It causes that in next installation attempt Prestashop throws Exception - module cannot be installed properly again.

PrestaShop-1.7/dotpay.php

Lines 1235 to 1248 in bf7401c

private function addReturnTab()
{
// Prepare tab
$tab = new Tab();
$tab->active = 1;
$tab->class_name = 'AdminDotpayRefund';
$tab->name = array();
foreach (Language::getLanguages(true) as $lang) {
$tab->name[$lang['id_lang']] = 'Dotpay Refunds';
}
$tab->id_parent = -1;
$tab->module = $this->name;
return $tab->add();
}

Workaround for this issue could be something like this:

// ...
// Prepare tab 
$tabClass = 'AdminDotpayRefund';
$existingAdminTab = Db::getInstance()->getValue('SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name LIKE "' . $tabClass . '";');
if ($existingAdminTab) {
	return true;
}
// ...

But it would be better to uninstall tab together with module, to avoid issues like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant