Adding a close method or alternatives for persistent objects (i.e. PDO)
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
PHP has been moving towards using objects instead of resources. One change as a result of this is that the resource the object represents gets closed on the destructor, instead of calling extension_providing_resource_close methods. Normally, this is OK, as you can just remove all references to an object and have it clean up. However, with persistent resources, the extension holds a reference onto the object that it provides to you, preventing you from being able to destroy the object. This use case might exist for i.e. cleaning up a persistent database connection that has gotten itself into a wedged state that the extension can't handle (i.e. ODBC liveness checks aren't perfect), or closing something to finalize something done over multiple requests.
The easiest option may be to add a close method to the object, similar to what i.e. SQLite3 does. Some extensions like curl already have close methods, but they might have been converted to nops in the resource to object conversion. However, this adds issues with having an object that represents i.e. a connection in a closed state. (However, since one of the cases is say, closing a database connection, we already might have to deal with live objects that represent a resource that's been closed.)
Another option might be to expose a list of currently used persistent resources. get_resources can be abused for this, but contains massive footguns and only works with legacy resources. Perhaps this can be done for persistent objects in general in a safer manner, or have a persistent object list provided by the extension. Persistent object issues can be hard to debug, so this might be generally useful.
See: https://github.com/php/php-src/pull/15603#issuecomment-2329536824 - there might be other conversations on this
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先阅读 issue 中关于 PDO 持久资源、SQLite3 和 curl 的 close 方法以及所链接 pull request 讨论的内容。比较所提出的 close 方法和持久对象列表这两种替代方案;完成的要求是就如何安全处理持久对象和已关闭资源达成一致的 API 和实现方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php, sqlite
- 领域
- backend, databases
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100