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

Return value of CodeIgniter\Database\BaseConnection::getConnectStart() must be of the type float, null returned #2158

Closed
Martin-4Spaces opened this issue Aug 21, 2019 · 4 comments

Comments

@Martin-4Spaces
Copy link

This error occurs if I connect to a database group but never use it.

Ex.

$routes->get('issue', function() {
    $db = Database::connect('default');
    echo 'Nah, I dont need the connection anyway';
});

TypeError

connectTime in BaseConnection is set when the first query is run. But Database::formatTimelineData will always call getConnectStart.

Martin-4Spaces added a commit to 4spacesdk/CI4RESTExtension that referenced this issue Aug 21, 2019
@jim-parry jim-parry added this to the 4.0.0-rc.2 milestone Sep 8, 2019
@michalsn
Copy link
Member

I'm not able to reproduce this error using either develop branch or RC.1

@MGatner
Copy link
Member

MGatner commented Sep 19, 2019

Me neither, tested with default and an additional DB connection with the debug toolbar collector on.

@Martin-4Spaces
Copy link
Author

Me neither. Ty!

@Martin-4Spaces
Copy link
Author

Aha!
I finally reproduced this issue using develop branch and RC.3.

If you connect to the database in a pre_system event, then toolbar will initialise with 1 database connection. And fail if the connection is never used.

app/Config/Events.php:

Events::on('pre_system', function() {
	Database::connect();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants