Skip to content

Make PDO_MYSQL_ATTR_DIRECT_QUERY a proper alias #16935

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

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ext/pdo_mysql/mysql_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ static bool pdo_mysql_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val)
((pdo_mysql_db_handle *)dbh->driver_data)->buffered = bval;
PDO_DBG_RETURN(true);

case PDO_MYSQL_ATTR_DIRECT_QUERY:
case PDO_ATTR_EMULATE_PREPARES:
if (!pdo_get_bool_param(&bval, val)) {
PDO_DBG_RETURN(false);
Expand Down Expand Up @@ -555,7 +554,6 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_
break;

case PDO_ATTR_EMULATE_PREPARES:
case PDO_MYSQL_ATTR_DIRECT_QUERY:
ZVAL_BOOL(return_value, H->emulate_prepare);
break;

Expand Down Expand Up @@ -761,8 +759,6 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
zend_string *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1);

H->emulate_prepare = pdo_attr_lval(driver_options,
PDO_MYSQL_ATTR_DIRECT_QUERY, H->emulate_prepare);
H->emulate_prepare = pdo_attr_lval(driver_options,
PDO_ATTR_EMULATE_PREPARES, H->emulate_prepare);

Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_mysql/pdo_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
#endif
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (zend_long)PDO_MYSQL_ATTR_COMPRESS);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", (zend_long)PDO_MYSQL_ATTR_DIRECT_QUERY);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", (zend_long)PDO_ATTR_EMULATE_PREPARES);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", (zend_long)PDO_MYSQL_ATTR_FOUND_ROWS);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", (zend_long)PDO_MYSQL_ATTR_IGNORE_SPACE);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", (zend_long)PDO_MYSQL_ATTR_SSL_KEY);
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_mysql/pdo_mysql.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Mysql extends \PDO
/** @cvalue PDO_MYSQL_ATTR_COMPRESS */
public const int ATTR_COMPRESS = UNKNOWN;

/** @cvalue PDO_MYSQL_ATTR_DIRECT_QUERY */
/** @cvalue PDO_ATTR_EMULATE_PREPARES */
public const int ATTR_DIRECT_QUERY = UNKNOWN;

/** @cvalue PDO_MYSQL_ATTR_FOUND_ROWS */
Comment on lines 33 to 39
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should remove this from 8.4 as it is a new class and barely out? @php/release-managers-84 what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

PHP 8.4 is out already. Maybe it would be better to drop in 8.5?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but I would consider this a "fix" to remove this useless constant, and considering it would be early in the release of it I'm not sure that it is that problematic, we fixed various named parameters up until PHP 8.0.3 to make them consistent.

Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_mysql/pdo_mysql_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ext/pdo_mysql/php_pdo_mysql_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ enum {
PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,
#endif
PDO_MYSQL_ATTR_COMPRESS,
PDO_MYSQL_ATTR_DIRECT_QUERY,
PDO_MYSQL_ATTR_FOUND_ROWS,
PDO_MYSQL_ATTR_IGNORE_SPACE,
PDO_MYSQL_ATTR_SSL_KEY,
Expand Down
6 changes: 1 addition & 5 deletions ext/pdo_mysql/tests/bug68371.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
PDO MySQL Bug #38671 (PDO#getAttribute() cannot be called with platform-specific attribute names)
PDO MySQL Bug #68371 (PDO#getAttribute() cannot be called with platform-specific attribute names)
--EXTENSIONS--
pdo_mysql
--SKIPIF--
Expand All @@ -16,7 +16,6 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$attrs = [
// Extensive test: default value and set+get values
PDO::ATTR_EMULATE_PREPARES => array(null, true, false),
PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, false, true),
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, false, true),

// Just test the default
Expand Down Expand Up @@ -70,9 +69,6 @@ foreach ($attrs as $a => $vals) {
bool(true)
OK
OK
bool(false)
OK
OK
bool(true)
OK
OK
Expand Down