Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: BaseConnection::getConnectDuration() number_format(): Passing null to parameter #5535

Closed
jesusferm opened this issue Jan 4, 2022 · 3 comments · Fixed by #5536
Closed
Assignees
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@jesusferm
Copy link

PHP Version

8.1

CodeIgniter4 Version

4.1.6

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

MariaDB 10.4.22

What happened?

number_format(): Passing null to parameter #1 ($num) of type float is deprecated

SYSTEMPATH/Database/BaseConnection.php at line 933

926 * Returns the number of seconds with microseconds that it took
927 * to connect to the database.
928 *
929 * Used by the Debug Toolbar's timeline.
930 /
931 public function getConnectDuration(int $decimals = 6): string
932 {
933 return number_format($this->connectDuration, $decimals);
934 }
935
936 /
*
937 * Protect Identifiers
938 *
939 * This function is used extensively by the Query Builder class, and by
940 * a couple functions in this class.

{PHP internal code} — CodeIgniter\Debug\Exceptions->errorHandler ( arguments )

SYSTEMPATH/Database/BaseConnection.php : 933 — number_format()

SYSTEMPATH/Debug/Toolbar/Collectors/Database.php : 112 — CodeIgniter\Database\BaseConnection->getConnectDuration ()

Steps to Reproduce

I installed codeigniter 4.1.5 with composer in XAMPP 8.0.13 in this versión it's works, but I update XAMPP TO php 8.1.1, then, i update codeigniter via composer, and when setup my project, not working, directly throws this error

Expected Output

Start login view for my project, before that only pre configure the database

Anything else?

No response

@jesusferm jesusferm added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 4, 2022
@kenjis kenjis self-assigned this Jan 4, 2022
@kenjis kenjis changed the title number_format(): Passing null to parameter Bug: BaseConnection::getConnectDuration() number_format(): Passing null to parameter Jan 4, 2022
kenjis added a commit to kenjis/CodeIgniter4 that referenced this issue Jan 4, 2022
@kenjis
Copy link
Member

kenjis commented Jan 4, 2022

@jesusferm Thank you for reporting.
I've confirmed this error when only connecting db but not running any queries.

I sent a PR to fix.
Can you check the fix of system/Database/BaseConnection.php?
https://github.com/codeigniter4/CodeIgniter4/pull/5536/files#diff-a0dd1b2b2b4cedd9717224db1b29e49a84991d770ef1b4a70c97721b1293e9a5

@jesusferm
Copy link
Author

It's work.

I have a question, i modified directly file inside package was installed from composer, this modified not affected for new updates from composer?

@kenjis thanks

@kenjis
Copy link
Member

kenjis commented Jan 4, 2022

@jesusferm Thanks!

i modified directly file inside package was installed from composer, this modified not affected for new updates from composer?

Not affected. The modification would just be removed when updating CI4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
2 participants