{
  "id": "php/stream-wrapper-already-registered",
  "signature": "Warning: stream_wrapper_register(): Protocol 's3' is already defined in /var/www/app/src/Storage/S3Wrapper.php on line 25",
  "signature_zh": "警告：stream_wrapper_register()：协议 's3' 已被定义，位于 /var/www/app/src/Storage/S3Wrapper.php 第 25 行",
  "regex": "/stream_wrapper_register\\(\\): Protocol '.+' is already defined/",
  "domain": "php",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A custom stream wrapper for the 's3' protocol is registered twice, often due to duplicate autoloading or multiple includes of the same registration code.",
  "root_cause_type": "generic",
  "root_cause_zh": "自定义流包装器 's3' 协议被注册两次，通常是由重复的自动加载或多次包含相同的注册代码引起的。",
  "versions": [
    {
      "version": "8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only masks the underlying duplicate registration issue and may break other code expecting the 's3' protocol.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Removing the guard will cause a fatal error when the wrapper is registered twice instead of a warning.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add a guard clause before registration: if (!in_array('s3', stream_get_wrappers())) { stream_wrapper_register('s3', 'S3StreamWrapper'); }",
      "success_rate": 0.95,
      "how": "Add a guard clause before registration: if (!in_array('s3', stream_get_wrappers())) { stream_wrapper_register('s3', 'S3StreamWrapper'); }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the registration code runs only once by moving it to a service provider or bootstrap file with a singleton pattern.",
      "success_rate": 0.9,
      "how": "Ensure the registration code runs only once by moving it to a service provider or bootstrap file with a singleton pattern.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add a guard clause before registration: if (!in_array('s3', stream_get_wrappers())) { stream_wrapper_register('s3', 'S3StreamWrapper'); }",
    "Ensure the registration code runs only once by moving it to a service provider or bootstrap file with a singleton pattern."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.php.net/manual/en/function.stream-wrapper-register.php",
  "official_doc_section": null,
  "error_code": "E_WARNING",
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-07-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}