Bug #65397 [Com]: Mysql_* functions hide their warning

2013-08-20 Thread info at markoheijnen dot com
Edit report at https://bugs.php.net/bug.php?id=65397edit=1

 ID: 65397
 Comment by: info at markoheijnen dot com
 Reported by:info at markoheijnen dot com
 Summary:Mysql_* functions hide their warning
 Status: Feedback
 Type:   Bug
 Package:MySQL related
 Operating System:   Debian Wheezy
 PHP Version:5.5.1
 Block user comment: N
 Private report: N

 New Comment:

It was a mistake in my MySQL user data. Not sure how it get there but because 
it 
could connect to the database without username/password. What is the default 
values in php.ini


Previous Comments:

[2013-08-20 03:08:19] requi...@php.net

It isn't fatal in the 5.5.1 I'm executing.

E:\programs\PHP\php-5.5.1-Win32-VC11-x86php -v
PHP 5.5.1 (cli) (built: Jul 18 2013 10:56:37)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies

E:\programs\PHP\php-5.5.1-Win32-VC11-x86php -d extension=ext/php_mysql.dll
?php
error_reporting(-1);
ini_set(display_errors, true);
// replace the query below with one that should actually work
var_dump(mysql_num_rows(mysql_query(SELECT * FROM table LIMIT 1)));
echo still executing;
?
^Z

Deprecated: mysql_query(): The mysql extension is deprecated and will be 
removed 
in the future: use mysqli or PDO instead in - on line 5

Warning: mysql_query(): No connection could be made because the target machine 
actively refused it.
 in - on line 5

Warning: mysql_query(): A link to the server could not be established in - on 
line 5

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in 
- 
on line 5
NULL
still executing
E:\programs\PHP\php-5.5.1-Win32-VC11-x86

Meanwhile at the top of php_mysql.c/php_mysql_do_connect in the source,
https://github.com/php/php-src/blob/master/ext/mysql/php_mysql.c#L734

php_error_docref(NULL TSRMLS_CC,
 E_DEPRECATED,
 The mysql extension is deprecated and will be removed in 
the future: use mysqli or PDO instead);

(after which it continues on its merry way) and E_DEPRECATED is most certainly 
not fatal.


[2013-08-20 01:53:38] william dot a dot bartlett at gmail dot com

I mispoke slightly.  As per: 
http://www.php.net/manual/en/function.mysql-query.php

 If the link identifier is not specified, the last link opened by 
 mysql_connect() is assumed. If no such link is found, it will try to create 
 one as if mysql_connect() was called with no arguments. If no connection is 
 found or established, an E_WARNING level error is generated.

when you call mysql_query, it will call mysql_connect().  mysql_connect() 
returns a fatal error, E_DEPRECATED. The E_WARNING is never generated because 
execution crashes before mysql_query is called.  At the most, a documentation 
error.

For goodness sakes, there is no allowable way to call mysql_query() in php5.5 
because there are no valid mysql connections.


[2013-08-20 01:48:41] william dot a dot bartlett at gmail dot com

 It is just a warning. A notice, even. Not fatal.

No.  As per: http://www.php.net/manual/en/changelog.mysql.php

In PHP5.5, mysql_* functions emit E_DEPRECATED error, not E_DEPRECATED warning. 
It IS fatal.

My example was intended to indicate that the echo statement nevers occurs 
(which is the expected behavior).


[2013-08-20 01:43:46] requi...@php.net

It is just a warning. A notice, even. Not fatal.

@info: It's a silly question but are you sure it didn't connect? What's the 
output of

?php
error_reporting(-1);
ini_set(display_errors, true);
// replace the query below with one that should actually work
var_dump(mysql_num_rows(mysql_query(SELECT * FROM table LIMIT 1)));
echo still executing;
?


[2013-08-20 01:06:14] william dot a dot bartlett at gmail dot com

Not a bug.

mysql_query() is throws a deprecation error, not a deprecation warning.

Try:
---
?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
mysql_query('SELECT 1');
echo 'mysql_query() returns a warning, not an error';




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=65397


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65397edit=1


[PHP-BUG] Bug #65397 [NEW]: Mysql_* functions hide their warning

2013-08-05 Thread info at markoheijnen dot com
From: info at markoheijnen dot com
Operating system: Debian Wheezy
PHP version:  5.5.1
Package:  MySQL related
Bug Type: Bug
Bug description:Mysql_* functions hide their warning

Description:

When I run mysql_query() in PHP 5.4 without having a valid connection I
will get 
the warning about not having a valid connection and access to the user has
been 
denied. But when I now call mysql_query() in PHP 5.5 I only get the
deprecation 
message. I would expect to also see the warnings.

I only tested this with mysql_query() but I guess it will infect other
functions 
that can throw warnings.

Test script:
---
?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
mysql_query('SELECT * FROM table');

Expected result:

Deprecated: mysql_query(): The mysql extension is deprecated and will be
removed 
in the future: use mysqli or PDO instead in test.php on line 4

Warning: mysql_query(): Access denied for user 'www-data'@'localhost'
(using 
password: NO) in test.php on line 4

Warning: mysql_query(): A link to the server could not be established in
test.php 
on line 4

Actual result:
--
Deprecated: mysql_query(): The mysql extension is deprecated and will be
removed 
in the future: use mysqli or PDO instead in test.php on line 4

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65397edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65397r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65397r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=65397r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=65397r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=65397r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65397r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=65397r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=65397r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=65397r=support
Expected behavior:  https://bugs.php.net/fix.php?id=65397r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65397r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65397r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=65397r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65397r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=65397r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=65397r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=65397r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65397r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65397r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65397r=mysqlcfg