Zen Cart Logo
Forums / All Other Contributions/Addons / Undefined index: path in configure.php (using Apsona)

Undefined index: path in configure.php (using Apsona)

Views: 2,476

Results 1 to 3 of 3
4 Apr 2013, 9:11 AM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,872
Plugin Contributions:
7

Undefined index: path in configure.php (using Apsona)

Environment: Xampp 182 (Apache 2.4.3 (Win32), PHP 5.4.7) on a windows XP pc
Shop is accessed by this url www.motorvista.local which is redirected to 127.0.0.1 in the hosts file and a virtual host configuration for the apache server that points to the fileset in D:\My Documents etc…

To cut a long story short, I’ve been trying to solve a niggling problem with Apsona that boils down to the following:

If php.ini has

error_reporting = E_ALL & ~E_NOTICE

it loads ok.

Whereas if

error_reporting = E_ALL

it does not load and this error gets produced

[03-Apr-2013 18:13:20 UTC] PHP Notice: Undefined index: path in D:\My Documents\blah_blahadmin\includes\configure.php on line 32
[03-Apr-2013 18:13:20 UTC] PHP Notice: Undefined index: path in D:\My Documents\ blah_blahadmin \includes\configure.php on line 32
line 32 is this:

$t1 = parse_url(HTTP_SERVER);$p1 = $t1['path'];$t2 = parse_url(HTTPS_SERVER);$p2 = $t2['path'];

And the urls are

define('HTTP_SERVER', 'http://www.motorvista.local');
  define('HTTPS_SERVER', 'https://www.motorvista.local');

It is true that in all the PHP versions I have tested ['path'] is never set in this scenario.

Now in normal ZC use this does not cause any error messages but if as a test I put the same line in the admin header, it causes the same error messages.
Obviously the “problem” can be fixed easily by testing for the array element before assigning it, but my questions are:

  1.  Why does normal ZC use not produce the error message? Is it just suppressed or there is some mechanism I don’t understand:lol:
    
  2.  Is this something that should be fixed in configure.php with a test or is there something Apsona needs to include in their code to deal with this “correctly”?
    
  3. Why does logging/not-logging the error message break/allow the page?

Thanks
Steve

5 Apr 2013, 3:02 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Undefined index: path in configure.php (using Apsona)

torvista:

It is true that in all the PHP versions I have tested ['path'] is never set in this scenario.I suspect PHP is simply not recognizing ".local" as a valid TLD when running parse_url().

torvista:

  1.  Why does normal ZC use not produce the error message? Is it just suppressed or there is some mechanism I don’t understand:lol:
    
  2.  Is this something that should be fixed in configure.php with a test or is there something Apsona needs to include in their code to deal with this “correctly”?
    
  3. Why does logging/not-logging the error message break/allow the page?
  1. ZC's default error reporting setting suppresses E_NOTICE
  2. Probably easily fixed by not using a ".local" TLD.
  3. When triggering but not suppressing E_NOTICE, PHP execution may halt, hence breaking the page.
5 Apr 2013, 5:46 PM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,872
Plugin Contributions:
7

Re: Undefined index: path in configure.php (using Apsona)

Thanks for that information.

I tried other TLDs which did not fix it, and was thinking it was a virtualhost issue, but on further research I find other mentions of the error in Joomla and WP forums and then this:

Note that older versions of PHP (e.g., 4.1) returned an blank string as the path for URLs without any path, such as http://www.php.net

However more recent versions of PHP (e.g., 4.4.7) don't set the path element in the array, so old code will get a PHP warning about an undefined index.
http://www.php.net/manual/en/function.parse-url.php#77591

I was unable to find this change documented anywhere.

Anyway, I have used this in my local admin configure.php

$t1 = parse_url(HTTP_SERVER);(isset($t1['path']) ? $p1 = $t1['path'] : $p1 = '');$t2 = parse_url(HTTPS_SERVER);(isset($t2['path']) ? $p2 = $t2['path'] : $p2 = '');