After T223792 got resolved, templates on Commons can access Structured Data on Commons using Lua. As mentioned in T237107, mw.wikibase.getEntity() without the item ID does not work yet, so the code is calling mw.wikibase.getEntity("M"..mw.title.getCurrentTitle().id) to access entity associated with the current page. Strangely, some tiny fraction of the files that execute that line end up in c:Category:Pages_with_script_errors with error message that "M0" is not correct entity ID. Purging files fixes the issue, but files flicker in and out of "Category:Pages_with_script_errors". I had to add this change to patch the issue. Please ensure mw.title.getCurrentTitle().id returns correct page ID.
|mediawiki/extensions/Scribunto : master||Record vary-page-id when ID is accessed via mw.title|
Is it happening only when the page is first created? It's possible that we forgot to have Scribunto set the vary-page-id flag when the page ID is accessed in this way so MediaWiki knows to reparse the page after the page ID gets assigned.
I do not know, I only observed that there was a constant trickle of files into Category:Pages_with_script_errors complaining about entity ID "M0" and all of them would disappear from the category after null edit. I did another tweak to the code and now files with page_id = zero should end up in c:Category:Pages_with_page_ID_set_to_zero. At the moment category is still empty. I will observe it and report if there are any files there.
c:Category:Pages_with_page_ID_set_to_zero is still empty. I will close this as resolved, and revive if I observe this issue again. If I run into it again I will try to get more info about images.