top-think / top-think/think-orm
PHP8.1中连接使用pgsql报strpos(): Passing null to parameter #1 ($haystack) of type string is deprecate错
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
报错信息

原因
$val['extra']可能为null,导致报错,strpos的第一个参数不能为null(php8.1以前可以为null)
解决办法
将vendor/topthink/think-orm/src/db/connector/Pgsql.php的76行改为:
'autoinc' => (empty($val['extra'])?0:(0 === strpos($val['extra'], 'nextval('))),
修改后如下图:

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The affected entry point is vendor/topthink/think-orm/src/db/connector/Pgsql.php at line 76; start by checking how $val['extra'] is handled for PostgreSQL connections on PHP 8.1. Confirm the fix prevents the strpos() null deprecation, then verify the relevant ORM/database tests or a PostgreSQL connection path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100