top-think / top-think/think-orm

PHP8.1中连接使用pgsql报strpos(): Passing null to parameter #1 ($haystack) of type string is deprecate错

Open
#375 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
437
Forks
188
PR merge metrics
No merged PRs in 30d

Description

报错信息

截图_选择区域_20220817223147

原因

$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('))),

修改后如下图:

截图_选择区域_20220817224322

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.