Author Topic: Notice: Undefined offset: 1 in..com_virtuemart  (Read 5102 times)

pencaitland

  • Beginner
  • *
  • Posts: 24
Notice: Undefined offset: 1 in..com_virtuemart
« on: September 21, 2010, 17:52:26 pm »
I've found several posts with this error but no solutions; I have a localhost site under develpoment; this message displays twice at the top of my main shop page; it refers to the code
24: $my_page= explode ( '.', $page );
25: $modulename = $my_page[0];
26: $pagename = $my_page[1];
the last line being the cause of the error.

this looks like a pretty basic fault in my configuration, but where?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27536
  • Always on vacation
    • Jenkin Hill Internet
Re: Notice: Undefined offset: 1 in..com_virtuemart
« Reply #1 on: September 21, 2010, 23:28:04 pm »
Are you using WAMP? I'd guess that $my_page[1]; is the issue, but not a showstopper. Reduce the level of error reporting in php.ini or by using .htaccess and the error will not show again.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.3.10163 on Joomla 3.9.12 PHP 7.0.33

pencaitland

  • Beginner
  • *
  • Posts: 24
Re: Notice: Undefined offset: 1 in...virtuemart.php line 26
« Reply #2 on: September 22, 2010, 18:32:00 pm »
hmm, I am using wamp, and the console shows settings as display errors=off; I have also edited the php.ini file that is linked from the console so that it now has the line

- Show only errors
;
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR


but I still see the NOTICE lines at the top of my main shop page; in fact, when no-one is logged-in I get three lines:

Notice: Undefined offset: 1 in C:\wamp\www\lbpsjoomla\components\com_virtuemart\virtuemart.php on line 26

Notice: Undefined index: page in C:\wamp\www\lbpsjoomla\components\com_virtuemart\virtuemart.php on line 69

Notice: Undefined offset: 1 in C:\wamp\www\lbpsjoomla\components\com_virtuemart\virtuemart.php on line 85

Ok, these are not showstopppers, as you say, though I dont like brushing them under the carpet, but I can't see why they should still display ...

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27536
  • Always on vacation
    • Jenkin Hill Internet
Re: Notice: Undefined offset: 1 in..com_virtuemart
« Reply #3 on: September 22, 2010, 23:44:51 pm »
I'd use this to turn off all errors and work back from that:

error_reporting(0);

You have more than one php.ini file so it is always worth checking for that.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.3.10163 on Joomla 3.9.12 PHP 7.0.33

pencaitland

  • Beginner
  • *
  • Posts: 24
Re: Notice: Undefined offset: 1 in..com_virtuemart
« Reply #4 on: September 23, 2010, 12:06:24 pm »
I have edited the php.ini files that I can find to read error_reporting =0; {error_reporting(0) threw the thing into chaos, displaying a page with a MYSQL error; I now know that this should have been put in the viruemart.php file itself)
So I have been exploring the cause of the error: the code that begins it is:
$my_page= explode ( '.', $page );
This is expected to give two pieces of data; one is assigned to $modulename and one to $pagename. I ran a test on the contents of $my_page which revealed that it contains only 'shop-front', ie the name of my shop page - no module name in sight;
so I have edited the virtuemart.php page at the offending lines (26 and 85) to read:
if (count($my_page)==1) {
   $pagename = $my_page[0];
   } else {   
   $modulename = $my_page[0];
   $pagename = $my_page[1];
   }

This code needs to be added at lin 85 as well, where the same code runs, after resetting the $page variable.
If no-one is logged-in when this page is called, it also displays the following notice:
Notice: Undefined index: page in C:\wamp\www\lbpsjoomla\components\com_virtuemart\virtuemart.php on line 77 (originally line 69; 77 after my edit above).
This is the result of a call to the $_REQUEST['page']:
if (( !$pagePermissionsOK || !$funcParams ) && $_REQUEST['page'] != 'checkout.index') {
 $_REQUEST is not set when the page first opens; so I added code to check:
if (isset($_REQUEST['page'])) {etc}


I hope this helps others; perhaps it should be included in any update?