# What Does the Reset Action Do in OpenMage Image Cleaner? Does It Truncate the fb_imagecleaner_image Table?

> Understand the OpenMage Image Cleaner reset action. This guide clarifies if the reset truncates the fb_imagecleaner_image table, ensuring you know its impact on your data.

- Repository: [Fabrizio Balliano/openmage-image-cleaner](https://github.com/fballiano/openmage-image-cleaner)
- Tags: deep-dive
- Published: 2026-03-01

---

**Yes, the Reset action permanently truncates the `fb_imagecleaner_image` table, deleting all records of unused images tracked by the module while preserving the table structure.**

The [fballiano/openmage-image-cleaner](https://github.com/fballiano/openmage-image-cleaner) module provides administrative tools for managing unused images in OpenMage (Magento 1). When administrators need to clear the module's scan history, understanding the Reset action's effect on the database is critical for data management.

## How the Reset Action Works in FbimagecleanerController

The Reset action is implemented in `FbimagecleanerController::resetAction` within the admin controller. Located at [`app/code/community/Fballiano/ImageCleaner/controllers/Adminhtml/FbimagecleanerController.php`](https://github.com/fballiano/openmage-image-cleaner/blob/main/app/code/community/Fballiano/ImageCleaner/controllers/Adminhtml/FbimagecleanerController.php) (lines 87-94), this method handles the complete removal of tracked image records.

### Database Truncation Process

When invoked, the controller executes the following operations:

1. Retrieves the Magento core resource to establish a database connection.
2. Resolves the full table name via `$resource->getTableName('fb_imagecleaner_image')`.
3. Executes a raw SQL `TRUNCATE TABLE` statement on the resolved table name.

```php
$resource = Mage::getSingleton('core/resource');
$db = $resource->getConnection('core_read');
$cleaner_table = $resource->getTableName('fb_imagecleaner_image');

// Line 91 in FbimagecleanerController.php
$db->query("TRUNCATE TABLE {$cleaner_table}");

```

The `TRUNCATE TABLE` operation removes all rows from `fb_imagecleaner_image` and resets auto-increment counters to zero. Unlike `DELETE`, this operation cannot be rolled back and does not fire triggers, making it an instantaneous structural reset.

### Post-Execution Behavior

After truncating the table, the controller redirects the administrator back to the index page using `$this->_redirect('*/*/')`, completing the workflow without displaying a confirmation message in the standard implementation.

## Security and Access Control

The Reset action respects Magento's admin permissions through the `_isAllowed()` method. Requests must originate from authenticated admin sessions with appropriate ACL permissions; otherwise, the action returns a 403 forbidden response.

```php
protected function _isAllowed()
{
    return Mage::getSingleton('admin/session')->isAllowed('system/fbimagecleaner');
}

```

## Triggering the Reset Action

Administrators can initiate the Reset action through multiple interfaces.

### Via Admin UI

The Reset button appears in the Image Cleaner administrative interface, configured through [`system.xml`](https://github.com/fballiano/openmage-image-cleaner/blob/main/system.xml). Clicking this button submits a request to the route:

```

adminhtml/fbimagecleaner/reset

```

### Programmatic Access

Developers can generate the Reset URL programmatically:

```php
$resetUrl = Mage::helper('adminhtml')->getUrl('adminhtml/fbimagecleaner/reset');
$this->_redirectUrl($resetUrl);

```

### HTTP Request Example

For automation or testing, authenticated cURL requests can trigger the action:

```bash
curl -X GET "https://example.com/index.php/admin/fbimagecleaner/reset" \
     -b "admin_session=YOUR_ADMIN_COOKIE"

```

## Verifying the Truncate Operation

To confirm the Reset action succeeded, query the database directly:

```sql
SELECT COUNT(*) FROM fb_imagecleaner_image;

```

A return value of `0` confirms the table has been emptied, indicating all previously tracked unused image records have been purged.

## Summary

- **The Reset action permanently truncates** the `fb_imagecleaner_image` table, removing every record of tracked unused images.
- **Implementation location:** `FbimagecleanerController::resetAction` in [`app/code/community/Fballiano/ImageCleaner/controllers/Adminhtml/FbimagecleanerController.php`](https://github.com/fballiano/openmage-image-cleaner/blob/main/app/code/community/Fballiano/ImageCleaner/controllers/Adminhtml/FbimagecleanerController.php) (lines 87-94).
- **Security:** Requires authenticated admin privileges via `_isAllowed()` ACL checks.
- **Database impact:** Resets auto-increment counters and releases storage space immediately, unlike row-by-row deletion.
- **Recovery:** Truncated data cannot be recovered without a database backup taken prior to the operation.

## Frequently Asked Questions

### Does the Reset action delete actual image files from the server?

No. The Reset action only truncates the `fb_imagecleaner_image` database table, which stores metadata about unused images. Physical files in `media/` directories remain untouched. To delete files, use the module's separate deletion functionality.

### What is the difference between TRUNCATE and DELETE in the Reset action?

The Reset action uses `TRUNCATE TABLE`, which is a DDL operation that drops and recreates the table structure instantly, resetting auto-increment values and releasing storage allocation. A `DELETE` statement would remove rows iteratively, preserving auto-increment counters and potentially firing database triggers, resulting in slower execution with logged transactions.

### Can the Reset action be undone or rolled back?

No. Because the Reset action executes `TRUNCATE TABLE` as an implicit commit operation, it cannot be rolled back within a transaction. Administrators must restore from a database backup to recover the previous state of the `fb_imagecleaner_image` table.

### Is there a confirmation dialog before the Reset action executes?

According to the source code in [`FbimagecleanerController.php`](https://github.com/fballiano/openmage-image-cleaner/blob/main/FbimagecleanerController.php), the standard implementation does not include a JavaScript confirmation dialog before executing the truncate operation. The action processes immediately upon receiving the GET request, though browser-based confirmations may vary depending on frontend customizations in [`system.xml`](https://github.com/fballiano/openmage-image-cleaner/blob/main/system.xml) or admin theme overrides.