check if database table exists before drop it

This commit is contained in:
Jean-Christian Paul Denis 2023-04-19 23:34:49 +02:00
parent e614e53f04
commit 69cb2d8e9d
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Dotclear\Plugin\Uninstaller\Cleaner;
use dbSchema;
use dbStruct;
use dcCore;
use Dotclear\Database\Statement\{
DeleteStatement,
@ -120,9 +121,12 @@ class Tables extends AbstractCleaner
return true;
}
if ($action == 'delete') {
$sql = new DropStatement();
$sql->from(dcCore::app()->prefix . $ns)
->drop();
$struct = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
if ($struct->tableExists($ns)) {
$sql = new DropStatement();
$sql->from(dcCore::app()->prefix . $ns)
->drop();
}
return true;
}