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