PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_NNTP » Bug #6618

Undefined variable or offset

Details

Submitted2006-01-29 15:09 UTC
Fromstruchkov at gmail dot com
Assignedheino
StatusClosed
PackageNet_NNTP
PHP Version5.1.2
OSLinux
Roadmaps(Not assigned)

Comments

[2006-01-29 15:09 UTC] struchkov at gmail dot com

Description:
------------
In my test there are many php-messages like this:
1)
PHP Notice: Undefined variable: groups in /usr/share/pear/Net/NNTP/Protocol/Client.php on line 652

and

2)
PHP Notice: Undefined offset: 1 in /usr/share/pear/Net/NNTP/Protocol/Client.php on line 649
PHP Notice: Undefined offset: 2 in /usr/share/pear/Net/NNTP/Protocol/Client.php on line 649

I think that this code decide situation above.
1)
case 215: // RFC2980: 'information follows'
$data = $this->_getTextResponse();
if (PEAR::isError($data)) {
return $data;
}
$groups=array();
foreach($data as $line) {
preg_match("/^(.*?)\s(.*?$)/", trim($line), $matches);
$groups[$matches[1]] = (string) $matches[2];
}

return $groups;
2)

foreach($data as $line)
{
if (preg_match("/^(.*?)\s(.*?$)/", trim($line), $matches))
$groups[$matches[1]] = (string) $matches[2];
}

[2006-02-01 12:30 UTC] heino at php dot net

Which version of Net_NNTP are you using? My guess would be v1.0.1.

1)
The first notice should already be fixed - at least in the current beta release (v1.3.2).

2)
As for the second notice it's rather hard to find a possible bug without some debugging data. A quallified guess would be that your server has problems with the wildcard parameter, or the server simply doesnøt handle the 'LIST NEWSGROUPS' command correctly...

[2006-02-01 15:06 UTC] struchkov at gmail dot com

Hi Heino!

I will try to upgrade packege manual, because command 'pear updgrade-all' do nothing.
After weekend I email you list of strange servers.
There are a lot of servers in my program make this notices.

[2006-02-01 15:30 UTC] heino at php dot net

I believe 'pear upgrade Net_NNTP-beta' should do the trick ;-)

[2006-02-01 15:40 UTC] heino at php dot net

Looking more closely I saw what looks like a minor typo.

Try to replace the line

"if (preg_match("/^(.*?)\s(.*?$)/", trim($line), $matches))"

with

"if (preg_match("/^(.*?)\s(.*?)$/", trim($line), $matches))"

The $ character should of cause be located at the end of the regexp...

[2006-02-05 19:10 UTC] struchkov at gmail dot com

I do that you advise me and upgrade to beta.
But now I have error
Undefined variable: debug in /usr/share/pear/Net/NNTP/Protocol/Client.php on line 343

You must use if (isset($debug) && $debug)

[2006-02-05 19:22 UTC] struchkov at gmail dot com

I found test-case for next notice:

PHP Notice: Undefined offset: 1 in /usr/share/pear/Net/NNTP/Protocol/Client.php on line 1504
PHP Notice: Undefined offset: 2 in /usr/share/pear/Net/NNTP/Protocol/Client.php on line 1504

Try to use 'infa.abo.fi' as nntp-server and do 'getDescriptions' command.

My fix using ' if (preg_match(....' in this case is helped.

[2006-02-05 21:51 UTC] heino at php dot net

The NNTP daemon at 'infa.abo.fi' sends empty fields for groups without descriptions. This is semi-non-standard, and broke the the regexp, since the trim() also removing the whitespace between the fields, because of the missing description...