# Warning: Opcache: Cannot revalidate file '/var/www/app/index.php' - stat failed in Unknown on line 0

- **ID:** `php/opcache-invalid-file`
- **Domain:** php
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

OPcache cannot stat a cached PHP file because the file was deleted, moved, or its permissions changed after being cached, causing a stale cache entry.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| PHP 8.1 | active | — | — |
| PHP 8.2 | active | — | — |
| PHP 8.3 | active | — | — |

## Workarounds

1. **Clear the OPcache by restarting the web server (e.g., 'sudo systemctl restart php8.2-fpm') or using a function like opcache_reset() in a script.** (90% success)
   ```
   Clear the OPcache by restarting the web server (e.g., 'sudo systemctl restart php8.2-fpm') or using a function like opcache_reset() in a script.
   ```
2. **Set opcache.validate_timestamps=1 and opcache.revalidate_freq=0 in php.ini to check file changes on every request, preventing stale entries.** (85% success)
   ```
   Set opcache.validate_timestamps=1 and opcache.revalidate_freq=0 in php.ini to check file changes on every request, preventing stale entries.
   ```
3. **Ensure the file exists and has correct permissions: run 'ls -la /var/www/app/index.php' and 'chmod 644 /var/www/app/index.php' if needed.** (95% success)
   ```
   Ensure the file exists and has correct permissions: run 'ls -la /var/www/app/index.php' and 'chmod 644 /var/www/app/index.php' if needed.
   ```

## Dead Ends

- **** — Disabling OPcache entirely (opcache.enable=0) fixes the warning but causes significant performance loss; it's an overreaction for a file management issue. (80% fail)
- **** — Simply restarting PHP-FPM without clearing the cache may not help if the file is still missing; the cache entry persists in shared memory. (65% fail)
