Skip to content

odbc back-end resource handling broken on PHP 8.4 #45

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

Open
MarkMaldaba opened this issue Apr 29, 2025 · 5 comments
Open

odbc back-end resource handling broken on PHP 8.4 #45

MarkMaldaba opened this issue Apr 29, 2025 · 5 comments

Comments

@MarkMaldaba
Copy link
Contributor

Note: This task is similar to #37 which raised similar issues with the pgsql back-end, on PHP 8.1

Since PHP 8.4, various odbc methods now return a PHP object rather than a resource.

From https://www.php.net/manual/en/migration84.incompatible.php#migration84.incompatible.resource2object.odbc:

Several resources have been migrated to objects. Return value checks using is_resource() should be replaced with checks for false, unless specified otherwise.

  • The ODBC functions now accept and return Odbc\Result objects instead of odbc_result resources.
  • The ODBC functions now accept and return Odbc\Connection objects instead of odbc_connection resources.

In PEAR::DB, the DB_pdbc class is implemented on the assumption that the returned result is a PHP resource reference. In particular, there are various is_resource() checks that will no longer work as expected as this function only returns true for the resource implementation.

The class needs to be updated to handle both implementations, in order to support older PHP versions as well as continuing to run on PHP >= 8.4.

@DanCld
Copy link
Contributor

DanCld commented Apr 29, 2025

It does not feel there is more than copy / pasting from what I have come up with for PgSQL. Unfortunately that pull request is still in the queue, so there may not be that many people affected by these changes to start with.

@schengawegga
Copy link
Collaborator

It does not feel there is more than copy / pasting from what I have come up with for PgSQL. Unfortunately that pull request is still in the queue, so there may not be that many people affected by these changes to start with.

I wrote a change request on your pull request.
After you made the change PHP5 compatible, i will merge your PR.
So maybe this issue will be fixed then, too?

@MarkMaldaba
Copy link
Contributor Author

It does not feel there is more than copy / pasting from what I have come up with for PgSQL. Unfortunately that pull request is still in the queue, so there may not be that many people affected by these changes to start with.

I wrote a change request on your pull request. After you made the change PHP5 compatible, i will merge your PR. So maybe this issue will be fixed then, too?

I couldn't see a change request in PR #43, so I've submitted one of my own.

@DanCld
Copy link
Contributor

DanCld commented Apr 30, 2025

I have updated my PR as per comments. TBH, I only got to modifying this code after I started running into issues when updating some legacy product to make it work with PHP 8.3+, so backwards compatibility was not top of mind for me. But thank you for pointing it out.

@DanCld
Copy link
Contributor

DanCld commented May 2, 2025

I have added a draft PR for this: #47 . I have no means to test it out myself, so please feel free to copy/paste and see if it makes any difference.

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

3 participants