See {T320675} for background info. The concern is that Phonos could generate many orphaned files, especially during preview, that are forever lost in the abyss of Swift. During our initial rollout, we want to monitor how many orphaned files there are. The technical plan to accomplish this includes:
# Have Phonos store a page property for file usage (T326163)
# Loop through to collect which files are in-use
# Loop through directories under /phonos-render and surface files that aren't being used on the wiki
**Acceptance criteria**
* Running the maintenance script should count the files that aren't being used.
* A `--delete` flag should be available allowing you to delete these files, in addition to simply counting them.
* A `--with-setting` flag should be available to limit the script to run only against wikis with the given config setting (this only applies to production, where the value would be `wmgUsePhonos`)
* Go by the `sites` table to iterate through all wikis (or only those with the aforementioned setting)
* For single-wiki installations or those without a populated `sites` table, the script just runs on the current wiki
**QA notes**
* Run the script with `php extensions/Phonos/maintenance/countOrphanFiles.php`
* You can create orphaned files by simply using Phonos, observing that a file was generated (you can do this using only preview, if you want), then removing the <phonos> tag or changing the parameters to it so that a new file is created.
* If you're testing on your local, you may wish to first run the [[ https://www.mediawiki.org/wiki/Manual:AddSite.php | addSite.php ]] script so that the code goes off of that like it would in production. The command would be something like: `php maintenance/addSite.php --language=en --pagepath='http://localhost:8080/wiki/$1' my_wiki wikipedia`, replacing the wiki path and `my_wiki` accordingly (with the former being the database name). `wikipedia` here is a wiki "family" name and shouldn't matter on your local.