Problem/Motivation

The method ModerationInformation::getLatestRevisionId (and possibly ModerationInformation::getDefaultRevisionId) has varying results if modules with node access grants are enabled. This particularly reveals itself if the content in question has not yet been published. For non-admins that don't have access granted in the query alter (but may otherwise be granted access) this method returns NULL.

Proposed resolution

Since both of these are API methods, they shouldn't return different results depending on which user is logged in. As such, the accessCheck(FALSE) method should be called on the entity query.

Remaining tasks

Determine the best way to demonstrate this issue in a test.

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhedstrom created an issue. See original summary.

jhedstrom’s picture

Status: Active » Needs review
FileSize
1.3 KB
jhedstrom’s picture

Here's 2 tests that demonstrate the issue. The functional one is a change to an existing test, but instead of using the node_access_test_empty module, it uses the one that actually provides some node grants. The second is a kernel test that demonstrates the issue at the API level.

Status: Needs review » Needs work

The last submitted patch, 3: 2932154-03.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

timmillwood’s picture

@jhedstrom - Good find! The patch in #2 looks perfect. Once tests pass I'll give a proper review.

jhedstrom’s picture

Those 2 fails were caused by the new logic in node_access_test_node_access() inadvertently granting the anonymous user access. Resolved by using a === operator. This also removes what was an unnessesary change to node_access_test_node_grants.

The last submitted patch, 6: 2932154-06-TEST-ONLY.patch, failed testing. View results

The last submitted patch, 6: 2932154-06-TEST-ONLY.patch, failed testing. View results

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Nice, looks good to me, thanks @jhedstrom!

  • larowlan committed f3b60ed on 8.5.x
    Issue #2932154 by jhedstrom: ModerationInformation::getLatestRevisionId...

  • larowlan committed e5f7cc8 on 8.4.x
    Issue #2932154 by jhedstrom: ModerationInformation::getLatestRevisionId...
larowlan’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed as f3b60ed and pushed to 8.5.x

Cherry-picked as e5f7cc8 and pushed to 8.4.x

Thanks

Status: Fixed » Closed (fixed)

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