The contents of Wikibase entity pages can be retrieved through the `Special:EntityData` special page, whose contents are cached by default (for one hour, in production – `$wgWBRepoSettings['dataCdnMaxAge']`). When a revision is deleted, the contents of `Special:EntityData` are not purged from the cache, allowing others to still access this information.
For example, on Test Wikidata I added the information that the [rebel base](https://test.wikidata.org/wiki/Q212688)’s [location](https://test.wikidata.org/wiki/Property:P286) is [Dantooine](https://test.wikidata.org/wiki/Q212689), and then removed it again and deleted that revision. But because the Wikibase editing UI loads `Special:EntityData` by default (since T85499), the data is already in the cache, and can be retrieved from there:
```lang=console
$ curl -v https://test.wikidata.org/wiki/Special:EntityData/Q212688.json?revision=530580 | jq -r .entities.Q212688.claims.P286[0].mainsnak.datavalue.value.id
…
> GET /wiki/Special:EntityData/Q212688.json?revision=530580 HTTP/2
> Host: test.wikidata.org
> user-agent: curl/7.68.0
> accept: */*
>
…
< HTTP/2 200
< date: Thu, 13 Aug 2020 12:42:52 GMT
…
< last-modified: Thu, 13 Aug 2020 12:42:45 GMT
< content-type: application/json; charset=UTF-8
< age: 187
< x-cache: cp3050 miss, cp3058 hit/11
< x-cache-status: hit-front
< server-timing: cache;desc="hit-front"
…
< cache-control: private, s-maxage=0, max-age=0, must-revalidate
…
Q212689
```
I think we also don’t purge cached entity data when a whole page is deleted, but I haven’t tested that yet.
**Acceptance Criteria**
[] Pages are purged when entity deletion happens (might already be done not checked)
[] Pages are purged when revision deletion of specific revisions happens
**Inspection notes**
- Some of the mechanisms/code that were written (and are merged) from T242164 could be used.
- No extra extensions are needed for reproducing this (it is core wikibase)
- This can't easily be tested with a full cache setup, but could be tested with unit tests etc to make sure the purging code is called correctly.
#patch-for-review:
- [x] [More consistent handling of cached URLs](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/621757)
- [x] [Move caching responsibilities into EntityDataUriManager](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/622370)
- [x] [Add EntityDataFormatProvider to WikibaseRepo](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/622371)
- [x] [Add EntityDataUriManager to WikibaseRepo](https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/622372)
- [ ] [SECURITY: Add EntityDataPurger](https://phabricator.wikimedia.org/F32366440)
- [x] [Configure entityDataCachePaths for Wikibase](https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/629133)