Fix PHP warning on locking without file handle