Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24848

Content Type removal does not take into account Contents in the trash

    Details

      Description

      Steps to reproduce:

      1. Access PlatformUI;

      2. Go to "Admin Panel -> Content types";

      3. Click on content type group "Content";

      4. At the bottom of the content types list, click on "Create a content type";

      5. Give the proper specs to the content type that you need;

      6. Click "OK" at the bottom;

      7. Go to "Content -> Content structure -> Content Tree";

      8. Click on "Create" on the rightside menu;

      9. Choose the content type you just created;

      10. Name it and publish it;

      11. Delete the content you just created;

      12. Go back to "Admin Panel -> Content types" and into content type group "Content";

      13. Verify that the "Delete" button affected to the content type you just created is NOT greyed out and IS clickable;
      open firebug or similar tool and go to Console;

      14. Click on "Delete" to remove the content type.
      You'll see the error notification:

      Argument '$contentTypeId' has a bad state: ContentType with given id still has content instances and therefore can't be deleted 
      

      and on the Console:

      POST http://ezp5.rui/pjax/contenttype/delete/43           403 Forbidden  		246ms                 io-base-min.js (line 8)
      "NetworkError: 403 Forbidden - http://ezp5.rui/pjax/contenttype/delete/43"                                                      43
      

      This happens because the removal of the Content Type doesn't take into account that the Content you deleted is in trash state, and so far, in PlatformUI, removed items sent into Trash cannot be expunged from the trash, and they are so far, by default, always sent to Trash when removed from PlatformUI.

        Issue Links

          Activity

          Hide
          André Rømcke added a comment -

          > show a list of (links to) drafts, trash items and content of that content type (since we're gonna check for them).

          I don't think we have api's to iterate drafts of a type, but besides missing drafts, we need to make sure SPI has the needed methods for us to detect use and throw exception on delete.

          Besides that I also realize the same thing GL does here, instead of counting up front, it would be more useful to start to build up that page showing use. However the best would be ti aim for : Expose API to detect use (using the SPI calls mentioned above, like in SectionService), provide a link to page explaining where it is used.

          But for short term (1.0.x), just a disabled button with alternative text mentioning the content type is being used should be ok, so SPI and use API like in SectionService please.

          Show
          André Rømcke added a comment - > show a list of (links to) drafts, trash items and content of that content type (since we're gonna check for them). I don't think we have api's to iterate drafts of a type, but besides missing drafts, we need to make sure SPI has the needed methods for us to detect use and throw exception on delete. Besides that I also realize the same thing GL does here, instead of counting up front, it would be more useful to start to build up that page showing use. However the best would be ti aim for : Expose API to detect use (using the SPI calls mentioned above, like in SectionService) , provide a link to page explaining where it is used. But for short term (1.0.x), just a disabled button with alternative text mentioning the content type is being used should be ok, so SPI and use API like in SectionService please.
          Hide
          Gunnstein Lye added a comment - - edited

          Thanks. Only doubt now is which API/SPI it should go in. Now I'm leaning more towards ContentTypeService::isContentTypeUsed(ContentType) than ContentService::countByContentTypeAndStatus(ContentType, status). This is more in line with SectionService.

          Show
          Gunnstein Lye added a comment - - edited Thanks. Only doubt now is which API/SPI it should go in. Now I'm leaning more towards ContentTypeService::isContentTypeUsed(ContentType) than ContentService::countByContentTypeAndStatus(ContentType, status) . This is more in line with SectionService.
          Hide
          Gunnstein Lye added a comment - - edited

          I put it in ContentService, it was the least intrusive way of doing it.
          Edit: Moved to ContentTypeService now.

          PR:
          https://github.com/ezsystems/ezpublish-kernel/pull/1539
          https://github.com/ezsystems/PlatformUIBundle/pull/479

          Show
          Gunnstein Lye added a comment - - edited I put it in ContentService , it was the least intrusive way of doing it. Edit: Moved to ContentTypeService now. PR: https://github.com/ezsystems/ezpublish-kernel/pull/1539 https://github.com/ezsystems/PlatformUIBundle/pull/479
          Show
          Gunnstein Lye added a comment - Merged in master: https://github.com/ezsystems/ezpublish-kernel/commit/97fd8f970eb355c44ac8d4d878aaf08fa0986010 https://github.com/ezsystems/PlatformUIBundle/commit/0f13c7c609bc8ce59075a8d20deeba84534a26d5
          Hide
          Paulo Nunes (Inactive) added a comment -

          Tested and approved by QA for master.

          Show
          Paulo Nunes (Inactive) added a comment - Tested and approved by QA for master.

            People

            • Assignee:
              Unassigned
              Reporter:
              Rui Silva (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 6 hours, 45 minutes
                1d 6h 45m