{
  "id": "php/opcache-invalidate-failure",
  "signature": "Warning: opcache_invalidate(): No such file or directory in /var/www/app/src/Cache/OpcacheManager.php:15",
  "signature_zh": "警告：opcache_invalidate()：在 /var/www/app/src/Cache/OpcacheManager.php:15 中没有该文件或目录",
  "regex": "Warning: opcache_invalidate\\(\\): No such file or directory",
  "domain": "php",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The opcache_invalidate() function is called with a file path that does not exist on the filesystem, often due to a stale cache key or a file that was deleted between the time the cache was built and the invalidation attempt.",
  "root_cause_type": "generic",
  "root_cause_zh": "opcache_invalidate() 函数被调用时使用了文件系统中不存在的文件路径，通常是由于缓存键过期，或在构建缓存与尝试失效之间文件被删除。",
  "versions": [
    {
      "version": "php:8.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "php:8.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "php:8.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Ignoring the warning and continuing to call opcache_invalidate() with non-existent paths leads to OPcache never being properly invalidated, which can cause stale code to be served indefinitely.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Increasing OPcache memory limits (opcache.memory_consumption) does not address the root cause of invalid file paths, as the warning is about file existence, not memory.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling OPcache entirely (opcache.enable=0) eliminates the warning but also removes all caching benefits, significantly degrading application performance.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Before calling opcache_invalidate(), check if the file exists using file_exists(): if (file_exists($filePath)) { opcache_invalidate($filePath); } else { // log or handle gracefully }",
      "success_rate": 0.9,
      "how": "Before calling opcache_invalidate(), check if the file exists using file_exists(): if (file_exists($filePath)) { opcache_invalidate($filePath); } else { // log or handle gracefully }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use opcache_get_status() to list cached files and ensure the file is actually cached before attempting invalidation: $status = opcache_get_status(false); if (isset($status['scripts'][$filePath])) { opcache_invalidate($filePath); }",
      "success_rate": 0.85,
      "how": "Use opcache_get_status() to list cached files and ensure the file is actually cached before attempting invalidation: $status = opcache_get_status(false); if (isset($status['scripts'][$filePath])) { opcache_invalidate($filePath); }",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the file path is dynamic, normalize it with realpath() to resolve symlinks and relative paths before invalidation: $realPath = realpath($filePath); if ($realPath !== false) { opcache_invalidate($realPath); }",
      "success_rate": 0.8,
      "how": "If the file path is dynamic, normalize it with realpath() to resolve symlinks and relative paths before invalidation: $realPath = realpath($filePath); if ($realPath !== false) { opcache_invalidate($realPath); }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在调用 opcache_invalidate() 之前，使用 file_exists() 检查文件是否存在：if (file_exists($filePath)) { opcache_invalidate($filePath); } else { // 记录日志或优雅处理 }",
    "使用 opcache_get_status() 列出缓存的文件，确保在尝试失效之前文件已被缓存：$status = opcache_get_status(false); if (isset($status['scripts'][$filePath])) { opcache_invalidate($filePath); }",
    "如果文件路径是动态的，使用 realpath() 规范化路径以解析符号链接和相对路径：$realPath = realpath($filePath); if ($realPath !== false) { opcache_invalidate($realPath); }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.php.net/manual/en/function.opcache-invalidate.php",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.75,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}