semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

PDO::exec returns a false equivalent #156

Closed dev-quentin closed 2 months ago

dev-quentin commented 2 months ago

Hello,

There is an incorrect comparison in the ARC2_StoreSelectQueryHandler.php file. The PDO::exec function returns false on error, and to check this strictly, === should be used instead of ==.

Details

Affected file https://github.com/semsol/arc2/blob/3e08bc2af723496967bcdedff663e8094f6e5e66/store/ARC2_StoreSelectQueryHandler.php#L183

Issue

The current comparison uses ==., which can lead to unexpected results since PDO::exec also returns the number of affected rows on success. To properly check if the method failed, a strict comparison === should be used. Proposed solution

Modify the affected line to use === instead of ==.

Reference

For more information, you can refer to the official PHP documentation on PDO::exec: PDO::exec - Manual

k00ni commented 2 months ago

Would you mind making a pull request with the proposed changes? At first glance I agree with these.

dev-quentin commented 2 months ago

Hello @k00ni,

I've just created a pull request 😀.

Thanks!