Problem/Motivation

When site is in read only mode no entities can be created or updated. But it is still possible to delete entities from web UI. I believe read only mode should also restrict "Delete" operation.

Steps to reproduce

  1. Switch on "Read only" mode here '/admin/config/development/maintenance'.
  2. Try to create a node - observe that validation fails and it is not possible.
  3. Try to update a node - observe that validation fails and it is not possible.
  4. Try to delete a node - observe the successful delete operation.

Proposed resolution

The "Delete" operation should be not possible while Read Only mode is on. Maybe it should be optional with configuration setting to force it.

Remaining tasks

Create MR

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#8 3545904-8.patch10.93 KBabarrio
#4 Patch Error.png371.25 KBsandeep_k
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

a.dmitriiev created an issue. See original summary.

a.dmitriiev’s picture

Status: Active » Needs review
sandeep_k’s picture

Status: Needs review » Needs work
StatusFileSize
new371.25 KB

@a.dmitriiev, I tested this on my Drupal version 11.2 and was able to successfully reproduce the error by following the given steps. The MR “MR !8 mergeable” applied successfully; however, after revisiting the site post-merge, the site broke. I’ve attached the error here.

a.dmitriiev’s picture

Status: Needs work » Needs review

@sandeep_k you need to clear the caches, as one more argument was added to service definition.

abarrio’s picture

Status: Needs review » Needs work

Reviewed unsing simplytest.me and local env with Drupal version 10.5.4 and still able to delete entities.

abarrio’s picture

Status: Needs work » Needs review

After digging into the problem, I discovered that the affected roles that are allowed to continue deleting content with the old approach are those that are admins.
I created a new approach to overwrite the default entity access control to check if the site is in read-only mode and, if not, call the original handler.

abarrio’s picture

StatusFileSize
new10.93 KB

Patch upload to use in a project.

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs review » Reviewed & tested by the community

works for me. tested with different entity types including users, nodes, eck.
Also, configured gitlab ci, fixed di, and updated tests.

sharique’s picture

There is a merge conflict, please rebase and resolve conflict.

sharique’s picture

Status: Reviewed & tested by the community » Needs work

astonvictor’s picture

Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.