The plg_task_deltrash plugin is a specialized extension for Joomla 4 and 5 that integrates with the Scheduled Tasks (Scheduler) core component. Its purpose is to automate the "permanent deletion" of items that have already been moved to the trash, helping you keep your database lean without manual intervention.


What this Plugin Does

In Joomla, when you "Delete" an article or category, it isn't actually gone; it's given a status of -2 (Trashed). Normally, an administrator must go to the trash view and click "Empty Trash."

This plugin automates that "Empty Trash" click. It can target:

  • Articles (com_content)

  • Categories (com_categories)

  • Menu Items (com_menus)

  • Contact Details (com_contact)

  • Banners (com_banners)

  • Tags (com_tags)

  • News Feeds (com_newsfeeds)


How to Install and Enable It

Since the source is in your testcom repository, you would typically:

  1. Zip the contents of src/plugins/task/deltrash.

  2. Upload it via Joomla's Extension Manager.

  3. Enable the Plugin: Go to System > Manage > Plugins, search for "Task - Delete trashed items," and ensure the status is "Enabled."


How to Use (Configuration)

Once enabled, you don't "run" the plugin directly from the Plugin Manager. Instead, you create a Task:

  1. Navigate to the Scheduler: Go to System > Manage > Scheduled Tasks.

  2. Create New Task: Click New and select Delete trashed items from the list.

  3. General Settings:

    • Title: Give it a name (e.g., "Weekly Database Cleanup").

    • Execution Rules: Choose how often it runs (e.g., every Sunday at 3 AM using a Cron expression).

  4. Task Parameters: This is where you configure the specific logic for deltrash:

    • Components: Select which specific components should have their trash emptied (e.g., only Articles and Categories).

    • Delete older than (Days): You can set a safety buffer (e.g., only delete items that have been in the trash for more than 30 days).

  5. Notifications: (As seen in your Cypress test) You can enable email notifications to receive a report every time the cleanup finishes.


How it Works Internally

The plugin implements the onExecute event. When the Joomla Scheduler triggers the task:

  1. It checks the Parameters you saved.

  2. It builds a database query for each selected component.

  3. It looks for records where state = -2 (or the component's equivalent for trashed).

  4. It executes the delete() method on those records.

  5. It returns a Task Result to Joomla, which logs the number of items successfully removed.

Benefits

  • Database Performance: Keeps tables smaller, making backups and searches faster.

  • Compliance: Helps with GDPR "Right to be Forgotten" by ensuring trashed personal data is actually deleted on a schedule.

  • Automation: Removes the human element—you don't have to remember to "empty the trash" ever again.