[[ https://phabricator.wikimedia.org/T229244 | This ticket ]] identified a bug that made it impossible to edit captions for many files on Beta Commons. That problem seems to have been fixed for most existing files as of [[ https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/526195 | this patch ]].
Unfortunately, newly-created files are still not properly initializing the CaptionsPanel class, and edit functionality is still broken. This is because the WikibaseMediaInfo extension is relying on the `wikibase.entityPage.entityLoaded` hook to for initialization: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikibaseMediaInfo/+/refs/heads/master/resources/filepage/init.js#43
This hook is only run if there structured caption info already exists for a given file. Newly-created files generally lack this data, and therefor the captions panel UI is broken on these pages.
It seems like there are two possible solutions here: either 1) ensure that the `wikibase.entityPage.entityLoaded` always fires (a Wikibase change), or 2) changing the way that CaptionsPanel gets initialized (a MediaInfo change).
If we go down the latter route, some refactoring may be necessary in the CaptionsPanel class to allow for a widget to be created with no data and then (optionally) have that data provided at a later time based on whether or not the relevant hook gets called. This class is one of the most complex bits of JS in the extension so it may be a non-trivial change.
Let's use this ticket to discuss how to move forward.
**Steps to Reproduce: **
1. Upload a new file (example: https://commons.wikimedia.beta.wmflabs.org/wiki/File:Permansive_paucidentate.jpg)
2. Navigate to the file page for that file
**Actual Results:**
No "Edit" button appears in the captions panel for the file.
**Expected Results:**
A working "Edit" button should appear regardless of whether or not any captions data exists for the file yet.