Problem/Motivation

In order to simplify the filter-administration-tests, the method CacheBackendInterface::isEmpty() was introduced in #575360: API function to check if a cache bin is empty. It was already stated in the aforementioned issue that the method will be difficult/impossible to implement for some third-party cache-backends. Nevertheless the patch was included and third-party cache-backends are expected to simply always return non-empty. It was stated that the worst can happen is a test fail.

Regrettably from reading the documentation it is not clear at all, that this method is only intended for test-purposes. In fact it is used in non-test code (e.g. toolbar.module) resulting in bugs like #2254903: PostgreSQL install broken again in HEAD by toolbar module.

Also the invocation in FilterAdminTest::testFilterAdmin is bogus (the reason why this function was introduced in the first place). In fact the assertion there is useless, because the filter-cache will only ever be used when rendering filtered text (i.e. something calls check_markup). However that function is never invoked and nothing is written to the filter cache before the assertion of \Drupal::cache('filter')->isEmpty(). Therefore this assertion should be removed entirely (as demonstrated by the test-results of demonstrate-filter-test-admin-is-empty-assert-defect.patch).

Proposed resolution

Remove CacheBackendInterface::isEmpty() and reimplement the tests depending on it in a proper way.

Remaining tasks

User interface changes

API changes

Comments

znerol’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.3 KB

This actually should fail if the FilterAdminTest::testFilterAdmin() was implemented properly.

znerol’s picture

StatusFileSize
new11.91 KB

In this patch:

  • Remove CacheBackendInterface::isEmpty() and also implementations thereof
  • Add a new test-case FilterAdminTest::testFilterAdminClearsFilterCache() properly testing cache-clearing upon filter administration.
  • Improve GenericCacheBackendUnitTestBase::testDeleteAll() and GenericCacheBackendUnitTestBase::testInvalidateAll(): Ensure that only the specified bin is affected instead of using isEmpty()
  • Remove the cache-clear optimization in toolbar.module.

Let's see if this is already enough.

Status: Needs review » Needs work

The last submitted patch, 2: 8738933-remove-cache-backend-isempty.patch, failed testing.

znerol’s picture

Status: Needs work » Needs review
StatusFileSize
new14.34 KB

Add missing use statement to FilterAdminTest and also fix BackendChainImplementationUnitTest.

Status: Needs review » Needs work

The last submitted patch, 4: 8738933-remove-cache-backend-isempty-4.patch, failed testing.

znerol’s picture

StatusFileSize
new1.95 KB
new1.95 KB

Fixes check_markup in FilterAdminTest::testFilterAdminClearsFilterCache() such that it actually uses the filter cache.

znerol’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: 8738933-remove-cache-backend-isempty-6.patch, failed testing.

znerol’s picture

Status: Needs work » Needs review
StatusFileSize
new14.39 KB

Upload the actual patch (both in #6 were interdiffs...)

bzrudi71’s picture

FYI the isEmpty() stuff currently breaks PostgreSQL installation as identified in #2254903: PostgreSQL install broken again in HEAD by toolbar module so adding as related. Removing isEmpty() and doing the deleteAll() the way like in this patch makes PostgreSQL install again. So please let get this in ASAP.

znerol’s picture

Issue summary: View changes
steinmb’s picture

Priority: Normal » Critical

Changing to critical since this blocks the pg installation, #10.

catch’s picture

Status: Needs review » Reviewed & tested by the community

This should never have gone in (and yes I posted on the original issue without blocking it, shame on me). Nice to see it go out again. RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit fd0dcf9 on 8.x by catch:
    Issue #2256877 by znerol: Remove the API function to check if a cache...
mradcliffe’s picture

Priority: Critical » Normal
Status: Fixed » Needs review
Issue tags: +Needs change record

Because this technically is an API change, I wrote a draft change notice: https://drupal.org/node/2263009.

Please review and publish.

berdir’s picture

I think this only existed in 8.x? We can still do the change record but should mention that.

catch’s picture

Yes I left the change record because this was only an 8.x-8.x change (and should never have been used outside tests).

znerol’s picture

There is cache_is_empty in Drupal 7. Let's update the New cache API change record instead of publishing a new one.

mradcliffe’s picture

Status: Needs review » Fixed

I updated https://drupal.org/node/1272696 to mention the removal of isEmpty() and removed it as part of the cache implementation section.

xjm’s picture

Issue tags: -Needs change record

Thanks @mradcliffe and @znerol!

Status: Fixed » Closed (fixed)

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