repo/includes/Content/EntityContent.php calls $output->recordOption( 'editsection' ) to try to fragment the parser cache on whether section edit links are included.
MediaWiki core has not so fragmented the cache since February 2015, and with the recent ParserOptions changes we now have to maintain a hack to keep that varying working just for Wikibase. A new fix for T85252: Edit buttons are getting cached, although their visibility depends on user rights is needed so we can remove that hack.
- Do edit links after the fact somehow instead of fragmenting the cache, like core does.
- Use ParserOptions::addExtraKey() to do the fragmenting.
- Use the new ParserOptionsRegister hook to register your own cache-fragmenting option for use in place of 'editsection'.