plugin uninstall function drop the tables, but shows errors on admin

I'm new in Wordpress and I have a function that drop the tables of my plugin on DB.

?php

if (! defined('WP_UNINSTALL_PLUGIN')) {
exit;
}

// Uninstallation actions here

global $wpdb;

$table_names = [
    $wpdb-prefix . "questions",
    $wpdb-prefix . "difficulties",
    $wpdb-prefix . "modalities",
    $wpdb-prefix . "fields",
    $wpdb-prefix . "themes",
    $wpdb-prefix . "subjects",
    $wpdb-prefix . "disciplines",
    $wpdb-prefix . "training_areas",
    $wpdb-prefix . "levels",
    $wpdb-prefix . "roles",
    $wpdb-prefix . "banks",
];

foreach ($table_names as $table_name) {
    $wpdb-query("DROP TABLE IF EXISTS $table_name");
}

But when I delete the plugin on admin, it shows this error:

It does drop all the tables, but how I make to stop this error?

Topic uninstallation plugin-development plugins Wordpress

Category Web


Plugin - it is not only tables in database, but also files. Such an error usually occurs when rights in the filesystem are not properly set. Rights must be 644 for files and 755 for directories, and owner must be the same user, under which php is running.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.