PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Logging » Log » Bug #4948

mode-as-string conversion problem

Details

Request #4948mode-as-string conversion problem
Submitted2005-07-29 17:50 UTC
Fromapinstein at mac dot com
Assignedjon
StatusClosed
PackageLog
PHP Version5.1.0
OSmac os x / 10.3.4
Roadmaps(Not assigned)

Comments

[2005-07-29 17:50 UTC] apinstein at mac dot com

Description:
------------
HI. I was having trouble getting the mode to work right with
PEAR::Log. After looking into it I realized it was due
passing the mode as a STRING, which doesn't get converted by
PHP as OCTAL.

So, looking at the code of file.php, I made a quick mod:

107 if (!empty($conf['mode'])) {
108 if (gettype($conf['mode']) == 'string')
{
109 $this->_mode = octdec($conf
['mode']);
110 } else {
111 $this->_mode = $conf['mode'];
112 }
113 }

to treat all strings as OCTAL data... any numeric types are
processed the current way.

This allows more fail-safe configuration of the MODE I
think. In my case the mode data is passed through many
layers via PHING and shows up as a string, which makes the
chmod do very unexpected things.

Thoughts?

[2005-08-01 14:55 UTC] apinstein at mac dot com

Hmmm... I see from the commit logs that you used this fix
exactly as I proposed. But I didn't mean to suggest that my
proposal was battle-tested. I was just wondering if this was
the desired behavior or was something that should be
corrected.

The proposed code, as is, would have the unfortunate effect
of introducing bugs for people that had worked around the
current bug, like I did subsequently.

For instance, once I figured out that my strings would
interpreted as decimal, I started passing "438" instead of
"666". But now I think if I upgrade my PEAR::Log package,
the behavior would change again since the 438 would be
passed through octdec().

So, maybe this needs to be further qualified? A little
research on specifying integers in PHP:

http://us3.php.net/types.integer

So, maybe the code should also check the string to be sure
that it's in 0[0-7]+ format? Would a preg_match take took
much time? Would it be better to just check the first 2
chars to make sure that it's 0[0-7] and not 0x as in hex?

[2005-08-07 05:15 UTC] apinstein at mac dot com

Ah yes. I see now reading the docs that the "mode" is
documented as the OCTAL mode, so I think PEAR::Log is now
doing what it says and saying what it does.

Fair enough! Thanks.... and glad I could help!