Skip to content

Fix bug GH-7746 (mysqli_sql_exception->sqlstate is inaccessible) #7747

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

Closed
wants to merge 1 commit into from

Conversation

kamil-tekiela
Copy link
Member

Fixes #7746

The property should not have been protected ever. It was meant to be public.

@kamil-tekiela kamil-tekiela changed the title Fix bug GH-1 (mysqli_sql_exception->sqlstate is inaccessible) Fix bug GH-7746 (mysqli_sql_exception->sqlstate is inaccessible) Dec 10, 2021
@damianwadley
Copy link
Member

Like I just commented on 7746, PHP's own exceptions typically use private/protected variables and provide getter methods instead. This way the exception can be immutable.

@kamil-tekiela
Copy link
Member Author

I can write a getter method for this, but I would need help. How do I read a property? Is there a helper macro for this?

@kocsismate
Copy link
Member

How do I read a property?

You have to use zend_read_property(). Some context about this function: #6759 (Nikita's comments)

@kamil-tekiela kamil-tekiela force-pushed the GH-1 branch 2 times, most recently from 593540f to d9529fb Compare December 10, 2021 10:23
@cmb69
Copy link
Member

cmb69 commented Dec 10, 2021

Regarding the name of the accompanying regression test (bugGH7746.phpt): I'm fine with this naming convention. Should we document that on http://qa.php.net/write-test.php#naming-conventions?

@nikic
Copy link
Member

nikic commented Dec 11, 2021

I'd target this at PHP-8.1, don't think adding a new method this late in the 8.0 release cycle is a good idea in terms of version constraints.

Regarding the name of the accompanying regression test (bugGH7746.phpt): I'm fine with this naming convention. Should we document that on http://qa.php.net/write-test.php#naming-conventions?

I'd go for either just gh7756.phpt or issue7756.phpt.

@cmb69
Copy link
Member

cmb69 commented Dec 11, 2021

I'd go for either just gh7756.phpt or issue7756.phpt.

I suggested the former but @Danack made a good point that having "bug" in the filename makes it more explicit that it's a regression test. I have no strong opinion either way.

@kamil-tekiela kamil-tekiela force-pushed the GH-1 branch 2 times, most recently from 9b7d80c to 4c4ce97 Compare December 11, 2021 23:38
@kamil-tekiela kamil-tekiela changed the base branch from PHP-8.0 to PHP-8.1 December 11, 2021 23:38
Create getter instead of making the property public
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you! This looks good to me.

@cmb69 cmb69 linked an issue Dec 28, 2021 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

mysqli_sql_exception->getSqlState()
5 participants