php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80575 Type casting of mysqli object to array produces null on every field
Submitted: 2021-01-02 16:43 UTC Modified: 2021-02-23 16:46 UTC
From: sapphirerx5700xt at gmail dot com Assigned: cmb (profile)
Status: Suspended Package: MySQLi related
PHP Version: 7.4 OS: Windwos 10 pro x 64bit 20H2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sapphirerx5700xt at gmail dot com
New email:
PHP Version: OS:

 

 [2021-01-02 16:43 UTC] sapphirerx5700xt at gmail dot com
Description:
------------
My php version is 8.0.0 ,mysql version is 8.0.22, apache version is 2.4.46

Output is as follows  
object(mysqli)#8 (18) {
  ["affected_rows"]=>
  int(0)
  ["client_info"]=>
  string(13) "mysqlnd 8.0.0"
  ["client_version"]=>
  int(80000)
  ["connect_errno"]=>
  int(0)
  ["connect_error"]=>
  NULL
  ["errno"]=>
  int(0)
  ["error"]=>
  string(0) ""
  ["error_list"]=>
  array(0) {
  }
etc
.......

after type casting everything returns null 

array(18) {
  ["affected_rows"]=>
  NULL
  ["client_info"]=>
  NULL
  ["client_version"]=>
  NULL
  ["connect_errno"]=>
  NULL
  ["connect_error"]=>
  NULL
  ["errno"]=>
  NULL
  ["error"]=>
  NULL
  ["error_list"]=>
  NULL
etc
....

Test script:
---------------
//Type casting of mysqli object to array produces null on every field on var_dump() and print_r()

$db = mysqli_connect(hostname:'localhost',username:'root',password:'',database:'tables',port:3306);

echo "<pre>";    // We get output in this case even with var_dump
print_r($db);
echo "</pre>";

echo "<pre>";
print_r((array) $db);  // All fields show null even with var_dump
echo "</pre>";


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-02 18:21 UTC] dharman@php.net
-Summary: //Type casting of mysqli object to array produces null on every field +Summary: Type casting of mysqli object to array produces null on every field -Status: Open +Status: Verified -Package: Scripting Engine problem +Package: MySQLi related
 [2021-01-08 13:53 UTC] cmb@php.net
-PHP Version: 8.0.0 +PHP Version: 7.4 -Assigned To: +Assigned To: cmb
 [2021-01-08 13:53 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #80575: Casting mysqli to array produces null on every field
On GitHub:  https://github.com/php/php-src/pull/6587
Patch:      https://github.com/php/php-src/pull/6587.patch
 [2021-02-23 16:46 UTC] cmb@php.net
-Status: Verified +Status: Suspended
 [2021-02-23 16:46 UTC] cmb@php.net
I'm still waiting on feedback on the PR, so I'm suspending this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 14:01:29 2024 UTC