[6.2] [AI] Web Services: don't return 204 when the delete was refused by tecpromotion · Pull Request #48648 · joomla/joomla-cms · GitHub
Skip to content

[6.2] [AI] Web Services: don't return 204 when the delete was refused - #48648

Open
tecpromotion wants to merge 1 commit into
joomla:6.2-devfrom
tecpromotion:fix/48647-api-delete-204
Open

tecpromotion wants to merge 1 commit into
joomla:6.2-devfrom
tecpromotion:fix/48647-api-delete-204

Conversation

@tecpromotion

Copy link
Copy Markdown
Contributor

Pull Request resolves #48647 .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

ApiController::delete() fell through to 204 No Content whenever $model->delete() returned false without a model error and without the 409 session flag. The client was told the item was deleted, but it was still there. This happens for example when:

  • a content plugin vetoes the delete: plg_content_joomla refuses a trashed category that still has items and only enqueues a message;
  • the asset row is missing: Table\Nested::delete() returns false without an error.

Such a refused delete now returns 409 Conflict with "message": "There was an error deleting the item." (existing string JLIB_APPLICATION_ERROR_DELETE). The reason enqueued by the plugin is included in messages.error of the JSON response.

Unchanged: successful deletes (204), not trashed (409), not found (404), model errors (500).

A system test was added to tests/System/integration/api/com_content/Categories.cy.js: deleting a trashed category that still has an article returns 409, and the category is still in the database.

Note: the test proposed in #48643 creates the category with db_createCategory (no asset row). With this fix its delete returns 409 instead of a false 204, so that test needs to create the category via the API.

Testing Instructions

  1. In the backend, create a content category, e.g. API delete test, and add one article to it.
  2. Trash the category (Content → Categories → Trash).
  3. Send a DELETE request with a Super User API token:
    curl -i -X DELETE \
      -H "Authorization: Bearer <api-token>" \
      https://example.test/api/index.php/v1/content/categories/<id>
  4. Check Content → Categories with the filter Trashed.
  5. Regression: delete the article (and empty the article trash), then repeat step 3. The category must now be deleted with 204.

System test: npx cypress run --spec tests/System/integration/api/com_content/Categories.cy.js

Actual result BEFORE applying this Pull Request

HTTP/1.1 204 No Content

The category is still in the trash.

Expected result AFTER applying this Pull Request

HTTP/1.1 409 Conflict

{"success":true,"message":null,"messages":{"error":["Delete not allowed for category API delete test. One item is assigned to this category."]},"data":{"status":"Conflict","code":409,"message":"There was an error deleting the item."}}

The category is still in the trash. Step 5 returns 204 and the category is deleted.

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

ApiController::delete() fell through to "204 No Content" whenever
$model->delete() returned false without a model error and without the
409 session flag, e.g. when a content plugin vetoed the delete (trashed
category that still has items) or when the asset row is missing.

Respond with 409 Conflict in that case. The reason enqueued by the
plugin is returned in "messages" of the JSON response.

Adds a system test for deleting a trashed category that still has
articles.

Fixes joomla#48647

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alikon

alikon commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[6.2] Web Services: DELETE returns 204 No Content although the item was not deleted

3 participants