Backported P2 fix from release-248

Merge pull request #5147 from Wikia/MWEB-1066

MWEB-1066 P2 fix: PHP fatal error on production