Skip to content

Convert resources to objects in ext/pgsql - #6791

Closed
kocsismate wants to merge 14 commits into
php:masterfrom
kocsismate:pgsql-resource
Closed

Convert resources to objects in ext/pgsql#6791
kocsismate wants to merge 14 commits into
php:masterfrom
kocsismate:pgsql-resource

Conversation

@kocsismate

@kocsismatekocsismate commented Mar 21, 2021

Copy link
Copy Markdown
Member

No description provided.

Comment threadext/pgsql/pgsql.stub.php Outdated
Comment threadext/pgsql/pgsql.c Outdated

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I removed some of these unnecessary comments because they annoyed me at some point

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does make a lot of noise in the PR sadly :-/

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I agree that it was not a good idea to do this here. I can get rid of these changes If they make code review difficult

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feel free to simply separately land a removal of all folder marks in pgsql (though I don't mind it being part of this change).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'll do it separately!

@GirgiasGirgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks OK from a quick glance if persistent connections still work (as currently there is no plan nor deprecation getting rid of those)

Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
@nikic

Copy link
Copy Markdown
Member

/home/vsts/work/1/s/ext/pgsql/pgsql.c:1515:10: error: unused variable ‘pg_link’ [-Werror=unused-variable]

@kocsismate
kocsismate marked this pull request as draft March 22, 2021 09:17
@kocsismate
kocsismateforce-pushed the pgsql-resource branch 2 times, most recently from 9c9bb86 to 45f55f7CompareMarch 24, 2021 23:51
@kocsismate

Copy link
Copy Markdown
MemberAuthor

Now only ~12 tests fail and I also tried to implement the suggestionss in in c7a86a3 (notices doesn't yet work perfectly).

Comment threadext/pgsql/pgsql.c Outdated
@kocsismate
kocsismate marked this pull request as ready for review March 30, 2021 07:57
@kocsismate

kocsismate commented Apr 2, 2021

Copy link
Copy Markdown
MemberAuthor

My latest commit (6931655) fixes all tests, finally!

@kocsismate
kocsismateforce-pushed the pgsql-resource branch 2 times, most recently from 6931655 to eb22b17CompareApril 2, 2021 19:29
@kocsismate
kocsismateforce-pushed the pgsql-resource branch 2 times, most recently from dbf23ba to 98c2c0dCompareApril 20, 2021 22:38
@nikic

Copy link
Copy Markdown
Member

Comment threadNEWS Outdated
Comment threadext/pgsql/pgsql.stub.php Outdated
Comment threadext/pgsql/tests/80_bug32223b.phpt Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/php_pgsql.h Outdated
Comment threadext/pgsql/pgsql.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feel free to simply separately land a removal of all folder marks in pgsql (though I don't mind it being part of this change).

Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
@kocsismatekocsismate added this to the PHP 8.1 milestone May 8, 2021
@kocsismate

Copy link
Copy Markdown
MemberAuthor

I addressed most of the review comments, however, currently many tests end up with a memory leak. The issue is with the default connection handling, so I'll continue chasing this problem.

@nikic

Copy link
Copy Markdown
Member

I pushed a few changes that should fix the leaks.

@nikic

Copy link
Copy Markdown
Member

Windows build failed with:

========DIFF========
002+ int(%d)
int(%d)
========DONE========
FAIL Bug #72197 pg_lo_create arbitrary read [C:\projects\php-src\ext\pgsql\tests\bug72197.phpt]

Not really obvious to me why ...

Comment threadext/pgsql/pgsql.c Outdated

@nikicnikicMay 10, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
zend_argument_type_error(1, "must be of type PgSql when the connection is provided");
zend_argument_type_error(1, "must be of type PgSql\\Connection when the connection is provided");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one isn't resolved yet.

Comment threadext/pgsql/tests/bug72197.phpt Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/php_pgsql.h Outdated
Comment threadext/pgsql/pgsql.c Outdated
Comment threadext/pgsql/pgsql.c Outdated
@kocsismate

Copy link
Copy Markdown
MemberAuthor

I had to force push because of a conflict in the readme, but only the last commit is new.

Comment threadext/pgsql/pgsql.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one isn't resolved yet.

@kocsismate
kocsismate deleted the pgsql-resource branch May 10, 2021 22:11
@kocsismate

Copy link
Copy Markdown
MemberAuthor

This one isn't resolved yet.

Did it when applying the commit!

flyokai pushed a commit to flyokai/laminas-db that referenced this pull request Apr 25, 2026
Per:
- php/php-src#6791
- https://github.com/php/php-src/blob/a846547ed4bb67f00dc12bbfc529e9c992cbfd07/UPGRADING
The pgsql functions now accept and return **resource objects** and not **resources**.
As such, the return value of `get_resource_type()` varies, and technically, in PHP 8.1, we should not use `is_resource()`, but a typecheck instead.
However, we still need to support pre-8.1 code as well.
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@kocsismate@nikic@Girgias@ramsey