| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/prosvasi/wp-content/plugins/wp-statistics/src/Service/Database/Operations/ |
Upload File : |
<?php
namespace WP_Statistics\Service\Database\Operations;
/**
* Handles the dropping of database tables.
*
* This class provides methods to safely execute table drop operations
* while ensuring transactional integrity.
*/
class Drop extends AbstractTableOperation
{
/**
* Execute the table drop operation.
*
* @return self
* @throws \RuntimeException
*/
public function execute()
{
try {
$this->ensureConnection();
$this->validateTableName();
$this->setFullTableName();
return $this->transactionHandler->executeInTransaction([$this, 'dropTable']);
} catch (\Exception $e) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- internal exception, message is not rendered to HTML
throw new \RuntimeException(
sprintf("Failed to drop table `%s`: %s", $this->tableName, $e->getMessage())
);
}
}
/**
* Drop table operation to be executed in transaction.
*
* @return self
* @throws \RuntimeException
*/
public function dropTable()
{
$sql = sprintf("DROP TABLE IF EXISTS `%s`", $this->fullName);
if ($this->wpdb->query($sql) === false) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- internal exception, message is not rendered to HTML
throw new \RuntimeException(
sprintf('MySQL Error: %s', $this->wpdb->last_error)
);
}
return $this;
}
}