Skip to main content
Topic: Undefined offset: 1 (Read 2157 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Undefined offset: 1

In a month a I got about 170 pages of errors in my Error Log.
Code: [Select]
Guest 
Type of error: Not specified
8: Undefined offset: 1
http://www.skodaclub.it/index.php?type=rss;action=.xml
File: /.../sources/QueryString.php
Row: 225

How could I solve this? Thank you.

I am using Elkarte 1.0.4 and PHP 5.6.
sorry for my bad english

Re: Undefined offset: 1

Reply #1

Would you mind do some test? O:-)

In QueryString.php, find:
Code: [Select]
		// Looks like this is an IPv4 address
if (strpos($part[1][1], '.') !== false)
{
and replace it with:
Code: [Select]
		if (!isset($part[1][1]))
log_error('Original address: ' . $addr);

// Looks like this is an IPv4 address
if (!isset($part[1][1]) || strpos($part[1][1], '.') !== false)
{

Then cleanup the error log and keep a eye on it to see if any error that looks like:
Code: [Select]
Original address: 123.123.123
appears. :D
Bugs creator.
Features destroyer.
Template killer.

Re: Undefined offset: 1

Reply #2

Thanks for your help. I did, but here is what I get now:

Re: Undefined offset: 1

Reply #3

Ops, wrong logic... O:-)
Sorry! :-[

Now, let's revert to something that should work, so:
Code: [Select]
		if (!isset($part[1][1]))
log_error('Original address: ' . $addr);

// Looks like this is an IPv4 address
if (!isset($part[1][1]) || strpos($part[1][1], '.') !== false)
{
becomes:
Code: [Select]
		// Looks like this is an IPv4 address
if (isset($part[1][1]) && strpos($part[1][1], '.') !== false)
{
Bugs creator.
Features destroyer.
Template killer.

Re: Undefined offset: 1

Reply #4

It seems to work for now, no errors in the last 40 minutes. Thank you Emanuele!
sorry for my bad english

Re: Undefined offset: 1

Reply #5

YAY! :D

Note: yes, it is a bug, in particular IPv6 addresses may not have anything after the "::" like in:
Code: [Select]
2001:41d0:2:e494::
present in the log posted by radu.
In this case,
Code: [Select]
$part[1]
is an empty array, and so it should not do anything about IPv4, but go straight to the "expand missing pieces" just after that.

 emanuele moves the topic
Bugs creator.
Features destroyer.
Template killer.

Re: Undefined offset: 1

Reply #6

After a few hours my error log is still empty ;) Thanks again!
sorry for my bad english

Re: Undefined offset: 1

Reply #7

Did this get tracked for 1.0.5 ?

Re: Undefined offset: 1

Reply #8

I guess not... O:-)
Bugs creator.
Features destroyer.
Template killer.


 

Re: Undefined offset: 1

Reply #10

And fixed in 1.0.5
Bugs creator.
Features destroyer.
Template killer.