Doc #54572 [NEW]: default ini values are not used when constructing new mysqli()
| From: | marcos at generic dot cx | Date: | Tue, 19 Apr 2011 23:22:02 +0000 |
| Subject: | Doc #54572 [NEW]: default ini values are not used when constructing new mysqli() | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-6262@lists.php.net to get a copy of this message | ||
From:
Operating system: MacOS
PHP version: 5.3.6
Package: MySQLi related
Bug Type: Documentation Problem
Bug description:default ini values are not used when constructing new mysqli()
Description:
------------
---
From manual page: http://www.php.net/mysqli.connect#Description
---
The documentation says:
mysqli::__construct() ([ string $host = ini_get("mysqli.default_host") [,
string
$username = ini_get("mysqli.default_user") [, string $passwd =
ini_get("mysqli.default_pw") [, string $dbname = "" [, int $port =
ini_get("mysqli.default_port") [, string $socket =
ini_get("mysqli.default_socket") ]]]]]] )
this implies that you can set these values via ini_set() and instantiate a
new
mysqli() with no arguments, but this does not actually work.
This is similar to http://bugs.php.net/bug.php?id=38998&edit=2
except that
case
revolved around passing null to the constructor.
The documentation says: "If not provided or NULL, the MySQL server will
attempt
to authenticate the user against those user records which have no password
only.
This allows one username to be used with different permissions (depending
on if
a password as provided or not)." but this is inconsistent with the
constructor
signature which implies that these values are auto-populated from the ini
values.
If the ini parameters serve no purpose in an empty constructor invocation,
then
the documentation signature should be updated to reflect that the
mysql.default_* ini values have no effect (or are overridden by the
behavior
that follows). i.e. the signature should read
mysqli::__construct() ([ string $host = "localhost" [, string
$username = ini_get("mysqli.default_user") [, string $passwd =
"" [, string $dbname = "" [, int $port =
ini_get("mysqli.default_port") [, string $socket =
ini_get("mysqli.default_socket") ]]]]]] )
which implies a very different behavior.
Test script:
---------------
ini_set("mysqli.default_host", "localhost");
ini_set("mysqli.default_user", "jack");
ini_set("mysqli.default_pw", "florey");
$sadmysqli = new mysqli();
$happymysqli = new mysqli(ini_get("mysqli.default_host"),
ini_get("mysqli.default_user"), ini_get("mysqli.default_pw"));
print_r($sadmysqli->host_info);
// ERROR: DB::__construct() [<a href='db.--construct'>db.--construct</a>]:
Property access is not allowed yet
print_r($happymysqli->host_info);
// Localhost via UNIX socket
Expected result:
----------------
the result for both print_r statements should be equivalent. this makes it
seem as
if the default ini values for the constructor are not actually being used
when
calling the constructor
Actual result:
--------------
see above, namely DB::__construct() [<a
href='db.--construct'>db.--construct</a>]:
Property access is not allowed yet
--
Edit bug report at http://bugs.php.net/bug.php?id=54572&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54572&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54572&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54572&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54572&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54572&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54572&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54572&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54572&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54572&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54572&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54572&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54572&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54572&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54572&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54572&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54572&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54572&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54572&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54572&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54572&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54572&r=mysqlcfg