FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=17027&edit=1

ID: 17027
Updated by: daniel.oconnor@gmail.com
Reported By: jkeller at berkeley dot edu
Summary: error_log() expects parameter 2 to be long, string
given
-Status: Open
+Status: Verified
Type: Bug
Package: Log
Operating System: irrelevant
Package Version: 1.11.6
PHP Version: 5.3.0
Roadmap Versions:
New Comment:

-Status: Open
+Status: Verified
http://svn.php.net/viewvc/pear/packages/Log/trunk/Log/error_log.php?revision=266582&view=markup

Eww :(

Nice find Jake


Previous Comments:
------------------------------------------------------------------------

[2010-01-22 18:01:39] jkeller841

Description:
------------
call to PHP error_log() function in Log/error_log.php (line 152) passes
a string instead of a long as parameter 2, causing a PHP Warning message
to be emitted. parameter 2 is $this->_type, which is set to a string in
the constructor (line 72): "$this->_type = $name". I think that
removing line 72 would fix the problem, with no apparent side-effects.

Test script:
---------------
error_reporting(E_ALL);

require_once('Log.php');
$logger = &Log::factory('error_log', '', 'TEST');

$logger->log("test message");

Expected result:
----------------
nothing; no PHP Warning should be emitted

Actual result:
--------------
Warning: error_log() expects parameter 2 to be long, string given in
/opt/php-5.3.0/lib/php/Log/error_log.php on line 152

------------------------------------------------------------------------

Search Discussions

  • Daniel Oconnor at Jan 23, 2010 at 3:28 am
    Edit report at http://pear.php.net/bugs/bug.php?id=17027&edit=1

    ID: 17027
    Updated by: daniel.oconnor@gmail.com
    Reported By: jkeller at berkeley dot edu
    Summary: error_log() expects parameter 2 to be long, string
    given
    Status: Verified
    Type: Bug
    Package: Log
    Operating System: irrelevant
    Package Version: 1.11.6
    PHP Version: 5.3.0
    -Assigned To:
    +Assigned To: jon
    Roadmap Versions:
    New Comment:

    -Assigned To:
    +Assigned To: jon



    Previous Comments:
    ------------------------------------------------------------------------

    [2010-01-23 03:26:43] doconnor

    -Status: Open
    +Status: Verified
    http://svn.php.net/viewvc/pear/packages/Log/trunk/Log/error_log.php?revision=266582&view=markup

    Eww :(

    Nice find Jake

    ------------------------------------------------------------------------

    [2010-01-22 18:01:39] jkeller841

    Description:
    ------------
    call to PHP error_log() function in Log/error_log.php (line 152) passes
    a string instead of a long as parameter 2, causing a PHP Warning message
    to be emitted. parameter 2 is $this->_type, which is set to a string in
    the constructor (line 72): "$this->_type = $name". I think that
    removing line 72 would fix the problem, with no apparent side-effects.

    Test script:
    ---------------
    error_reporting(E_ALL);

    require_once('Log.php');
    $logger = &Log::factory('error_log', '', 'TEST');

    $logger->log("test message");

    Expected result:
    ----------------
    nothing; no PHP Warning should be emitted

    Actual result:
    --------------
    Warning: error_log() expects parameter 2 to be long, string given in
    /opt/php-5.3.0/lib/php/Log/error_log.php on line 152

    ------------------------------------------------------------------------
  • Jon at Jan 24, 2010 at 7:10 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=17027&edit=1

    ID: 17027
    Updated by: jon@php.net
    Reported By: jkeller at berkeley dot edu
    Summary: error_log() expects parameter 2 to be long, string
    given
    -Status: Verified
    +Status: Bogus
    Type: Bug
    Package: Log
    Operating System: irrelevant
    Package Version: 1.11.6
    PHP Version: 5.3.0
    Assigned To: jon
    Roadmap Versions:
    New Comment:

    -Status: Verified
    +Status: Bogus
    Sorry, but your problem does not imply a bug in PEAR itself. For a
    list of more appropriate places to ask for help using PEAR, please
    visit http://pear.php.net/support/ as this bug system is not the
    appropriate forum for asking support questions.

    Thank you for your interest in PEAR.

    Sorry, but your example code isn't correct. Per the Log package's
    documentation[1], the error_log handler's $name parameter must be one of
    the supported PEAR_LOG_TYPE_* constants. Passing a string (empty or
    otherwise) is unsupported.

    [1] http://www.indelible.org/php/Log/guide.html#the-error-log-handler


    Previous Comments:
    ------------------------------------------------------------------------

    [2010-01-23 03:27:08] doconnor

    -Assigned To:
    +Assigned To: jon


    ------------------------------------------------------------------------

    [2010-01-23 03:26:43] doconnor

    -Status: Open
    +Status: Verified
    http://svn.php.net/viewvc/pear/packages/Log/trunk/Log/error_log.php?revision=266582&view=markup

    Eww :(

    Nice find Jake

    ------------------------------------------------------------------------

    [2010-01-22 18:01:39] jkeller841

    Description:
    ------------
    call to PHP error_log() function in Log/error_log.php (line 152) passes
    a string instead of a long as parameter 2, causing a PHP Warning message
    to be emitted. parameter 2 is $this->_type, which is set to a string in
    the constructor (line 72): "$this->_type = $name". I think that
    removing line 72 would fix the problem, with no apparent side-effects.

    Test script:
    ---------------
    error_reporting(E_ALL);

    require_once('Log.php');
    $logger = &Log::factory('error_log', '', 'TEST');

    $logger->log("test message");

    Expected result:
    ----------------
    nothing; no PHP Warning should be emitted

    Actual result:
    --------------
    Warning: error_log() expects parameter 2 to be long, string given in
    /opt/php-5.3.0/lib/php/Log/error_log.php on line 152

    ------------------------------------------------------------------------
  • Jkeller at Jan 24, 2010 at 8:51 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=17027&edit=1

    ID: 17027
    Updated by: jkeller@berkeley.edu
    Reported By: jkeller at berkeley dot edu
    Summary: error_log() expects parameter 2 to be long, string
    given
    Status: Bogus
    Type: Bug
    Package: Log
    Operating System: irrelevant
    Package Version: 1.11.6
    PHP Version: 5.3.0
    Assigned To: jon
    Roadmap Versions:
    New Comment:

    If this bug is bogus because the $name parameter is intended to be used
    to set the $_type field in Log/error_log.php, then the documentation is
    wrong. Section 2.3 says that the "destination" parameter is the
    "Optional destination value for error_log()." However, this parameter
    is not optional, since it is always used to set the $_type field, and
    must be one of the acceptable error_log_types, never an empty string.

    Additionally, Log/error.php initializes the $_type field to
    PEAR_LOG_TYPE_SYSTEM, but there is no point to doing so if this value is
    always overridden in the constructor. A more sensible approach would be
    to change line 72 to read "if (strlen($name) > 0) $this->_type =
    $name;". If this line were changed, then the $name ($destination)
    parameter would be optional, and passing in an empty string would result
    in it defaulting to PEAR_LOG_TYPE_SYSTEM.

    I don't need support; I'm just trying to be helpful to you in improving
    your code base. Thanks.


    Previous Comments:
    ------------------------------------------------------------------------

    [2010-01-24 19:08:42] jon

    -Status: Verified
    +Status: Bogus
    Sorry, but your problem does not imply a bug in PEAR itself. For a
    list of more appropriate places to ask for help using PEAR, please
    visit http://pear.php.net/support/ as this bug system is not the
    appropriate forum for asking support questions.

    Thank you for your interest in PEAR.

    Sorry, but your example code isn't correct. Per the Log package's
    documentation[1], the error_log handler's $name parameter must be one of
    the supported PEAR_LOG_TYPE_* constants. Passing a string (empty or
    otherwise) is unsupported.

    [1] http://www.indelible.org/php/Log/guide.html#the-error-log-handler

    ------------------------------------------------------------------------

    [2010-01-23 03:27:08] doconnor

    -Assigned To:
    +Assigned To: jon


    ------------------------------------------------------------------------

    [2010-01-23 03:26:43] doconnor

    -Status: Open
    +Status: Verified
    http://svn.php.net/viewvc/pear/packages/Log/trunk/Log/error_log.php?revision=266582&view=markup

    Eww :(

    Nice find Jake

    ------------------------------------------------------------------------

    [2010-01-22 18:01:39] jkeller841

    Description:
    ------------
    call to PHP error_log() function in Log/error_log.php (line 152) passes
    a string instead of a long as parameter 2, causing a PHP Warning message
    to be emitted. parameter 2 is $this->_type, which is set to a string in
    the constructor (line 72): "$this->_type = $name". I think that
    removing line 72 would fix the problem, with no apparent side-effects.

    Test script:
    ---------------
    error_reporting(E_ALL);

    require_once('Log.php');
    $logger = &Log::factory('error_log', '', 'TEST');

    $logger->log("test message");

    Expected result:
    ----------------
    nothing; no PHP Warning should be emitted

    Actual result:
    --------------
    Warning: error_log() expects parameter 2 to be long, string given in
    /opt/php-5.3.0/lib/php/Log/error_log.php on line 152

    ------------------------------------------------------------------------
  • Jon at Jan 24, 2010 at 8:58 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=17027&edit=1

    ID: 17027
    Updated by: jon@php.net
    Reported By: jkeller at berkeley dot edu
    Summary: error_log() expects parameter 2 to be long, string
    given
    Status: Bogus
    Type: Bug
    Package: Log
    Operating System: irrelevant
    Package Version: 1.11.6
    PHP Version: 5.3.0
    Assigned To: jon
    Roadmap Versions:
    New Comment:

    The "destination" parameter mentioned in the documentation is not the
    same as the $name parameter. The "destination" parameter refers to the
    optional $conf['destination'] value in the configuration array.

    It would be possible to test the the value and/or type of the $name
    parameter before setting the $this->_type value, but then the failure
    would be silent.


    Previous Comments:
    ------------------------------------------------------------------------

    [2010-01-24 20:49:22] jkeller841

    If this bug is bogus because the $name parameter is intended to be used
    to set the $_type field in Log/error_log.php, then the documentation is
    wrong. Section 2.3 says that the "destination" parameter is the
    "Optional destination value for error_log()." However, this parameter
    is not optional, since it is always used to set the $_type field, and
    must be one of the acceptable error_log_types, never an empty string.

    Additionally, Log/error.php initializes the $_type field to
    PEAR_LOG_TYPE_SYSTEM, but there is no point to doing so if this value is
    always overridden in the constructor. A more sensible approach would be
    to change line 72 to read "if (strlen($name) > 0) $this->_type =
    $name;". If this line were changed, then the $name ($destination)
    parameter would be optional, and passing in an empty string would result
    in it defaulting to PEAR_LOG_TYPE_SYSTEM.

    I don't need support; I'm just trying to be helpful to you in improving
    your code base. Thanks.

    ------------------------------------------------------------------------

    [2010-01-24 19:08:42] jon

    -Status: Verified
    +Status: Bogus
    Sorry, but your problem does not imply a bug in PEAR itself. For a
    list of more appropriate places to ask for help using PEAR, please
    visit http://pear.php.net/support/ as this bug system is not the
    appropriate forum for asking support questions.

    Thank you for your interest in PEAR.

    Sorry, but your example code isn't correct. Per the Log package's
    documentation[1], the error_log handler's $name parameter must be one of
    the supported PEAR_LOG_TYPE_* constants. Passing a string (empty or
    otherwise) is unsupported.

    [1] http://www.indelible.org/php/Log/guide.html#the-error-log-handler

    ------------------------------------------------------------------------

    [2010-01-23 03:27:08] doconnor

    -Assigned To:
    +Assigned To: jon


    ------------------------------------------------------------------------

    [2010-01-23 03:26:43] doconnor

    -Status: Open
    +Status: Verified
    http://svn.php.net/viewvc/pear/packages/Log/trunk/Log/error_log.php?revision=266582&view=markup

    Eww :(

    Nice find Jake

    ------------------------------------------------------------------------

    [2010-01-22 18:01:39] jkeller841

    Description:
    ------------
    call to PHP error_log() function in Log/error_log.php (line 152) passes
    a string instead of a long as parameter 2, causing a PHP Warning message
    to be emitted. parameter 2 is $this->_type, which is set to a string in
    the constructor (line 72): "$this->_type = $name". I think that
    removing line 72 would fix the problem, with no apparent side-effects.

    Test script:
    ---------------
    error_reporting(E_ALL);

    require_once('Log.php');
    $logger = &Log::factory('error_log', '', 'TEST');

    $logger->log("test message");

    Expected result:
    ----------------
    nothing; no PHP Warning should be emitted

    Actual result:
    --------------
    Warning: error_log() expects parameter 2 to be long, string given in
    /opt/php-5.3.0/lib/php/Log/error_log.php on line 152

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 23, '10 at 3:28a
activeJan 24, '10 at 8:58p
posts5
users3
websitepear.php.net

3 users in discussion

Daniel Oconnor: 2 posts Jon: 2 posts Jkeller: 1 post

People

Translate

site design / logo © 2022 Grokbase