[-] Fix potential race condition leading to file corruption and potential PHP crashes.

Handles concurrency properly, avoiding race condition that leads to PHP parsing errors or PHP crashes.