Skip to content

Conversation

@michalsn
Copy link
Member

@michalsn michalsn commented Feb 28, 2025

Description
This PR fixes a bug in OCI8 and SQLSRV getVersion() method, which will return an empty string when no connection is established.

Issue discovered in #9469

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 28, 2025

public function testGetVersion(): void
{
if ($this->db->DBDriver === 'MySQLi') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should can use if ($this->db instanceof \CodeIgniter\Database\MySQLi\Connection)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but since this type of comparison is widely used in our tests, I personally find it more readable. However, if others prefer the change, I'm happy to update it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The benefit of instanceof is phpstan will be fixed for no property notice

@michalsn michalsn changed the title fix: getVersion() for OCI8 driver when no connection is established fix: getVersion() for OCI8 and SQLSRV drivers Feb 28, 2025
@michalsn michalsn force-pushed the fix/oci8-getVersion branch from fd01f33 to f4d8a02 Compare March 10, 2025 06:02
@michalsn michalsn merged commit 249b88a into codeigniter4:develop Mar 12, 2025
50 checks passed
@michalsn
Copy link
Member Author

Thank you everyone for the review!

@michalsn michalsn deleted the fix/oci8-getVersion branch April 16, 2025 06:49
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

Development

Successfully merging this pull request may close these issues.

3 participants