Uninstall class and <uninstall> block ignored in Nextcloud app removal
Open
@come-nc is already working on this.
Since Nov 27, 2025.
feature: apps management
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
Description
I am developing a Nextcloud app (emailbridge) and trying to remove it completely, including all database tables, when the app is uninstalled.
I have tried multiple approaches:
- Using the
<uninstall>block ininfo.xmlwith a class implementingrun(array $options). - Using the
appinfo/uninstall.phpscript.
However, when I remove the app via CLI or web interface:
sudo -u www-data php occ app:remove emailbridge
- The app is disabled and removed, but database tables remain.
- No log messages from uninstall.php or Uninstall class appear.
Files
info.xml
<info...>
<id>emailbridge</id>
<name>Email Bridge</name>
...
<migrations>
<migration version="20251020">OCA\EmailBridge\Migration\Version20251020</migration>
</migrations>
<uninstall>
<class>OCA\EmailBridge\AppInfo\Uninstall</class>
<step>1</step>
</uninstall>
</info>
appinfo/uninstall.php
<?php
if (!empty($_['keepData']) && $_['keepData'] === true) {
return;
}
$tables = [
'oc_emailbridge_stats',
'oc_emailbridge_envoi',
'oc_emailbridge_inscription',
'oc_emailbridge_sequence',
'oc_emailbridge_form',
'oc_emailbridge_liste',
'oc_emailbridge_parcours'
];
$connection = \OC::$server->getDatabaseConnection();
$logger = \OC::$server->getLogger();
$logger->warning("EmailBridge uninstall.php : suppression des données");
foreach ($tables as $table) {
try {
$connection->executeStatement("DROP TABLE IF EXISTS `$table`");
$logger->warning("EmailBridge : table supprimée → $table");
} catch (\Throwable $e) {
$logger->error("EmailBridge : erreur DROP $table → " . $e->getMessage());
}
}
appinfo/Uninstall.php
<?php
namespace OCA\EmailBridge\AppInfo;
use OCP\IDBConnection;
use Psr\Log\LoggerInterface;
class Uninstall
{
private IDBConnection $db;
private LoggerInterface $logger;
public function __construct(IDBConnection $db, LoggerInterface $logger)
{
$this->db = $db;
$this->logger = $logger;
}
public function run(array $options): void
{
$keepData = $options['keepData'] ?? false;
if ($keepData) {
$this->logger->info("EmailBridge uninstall: keepData=true → aucune suppression");
return;
}
$this->logger->warning("EmailBridge uninstall: déclenché (classe Uninstall)");
}
}
Steps to reproduce
- Install the app either via Nextcloud App Store or manually via tar.gz.
- Execute CLI uninstall:
sudo -u www-data php occ app:remove emailbridge
or remove via the web interface. - Check database tables — they remain.
- No log messages appear in nextcloud.log.
Expected behavior
- Either appinfo/uninstall.php or class should execute.
- Tables should be dropped if keepData=false.
- Logs should appear confirming execution.
Nextcloud version
- 32.x (tested on local instance)
- App version: 1.0.0 béta
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.