Fix restoring state of external entity loader

Commit e3f46e0ecf83 introduces a fix for an XXE security issue on older PHP versions but in case of one of the affected files the patch fails to restore the state of the external entity loader, see comment by @staabm in the commit comments. Commit 22ce7965 was obviously intended to fix this issue, but fails to do so.