0

When I update PHP from PHP7 to PHP7.2 the website gives this error:

500 Internal Server Error

This is in the Log file:

[Thu Jan 24 04:44:56.061781 2019] [proxy_fcgi:error] [pid 30185:tid 139984342161152] [client xxxxx] AH01071: Got error 'PHP message: PHP Notice: Undefined variable: option in /home/xxxxx/domains/xxxxxxxxx.xx/public_html/templates/dj-business004/index.php on line 51\n'

Line 51 is:

if ($option && isset($sideBarsScheme[$option]) && trim($sideBarsScheme[$option]) && stristr($sideBarsScheme[$option],'content')!= false){

This is the code line 51 - 55:

if ($option && isset($sideBarsScheme[$option]) && trim($sideBarsScheme[$option]) && stristr($sideBarsScheme[$option],'content')!= false){
    $currentScheme = trim($sideBarsScheme[$option]);
} else {
    $currentScheme = $sideBarsScheme['default'];
}

How can I repair this?

  • Where is $option being defined? Please search for $option = and show the code for this in your question – Lodder Jan 24 at 15:56
  • In the index.php file I don't see any other place where $option is shown apart from the lines I showed above. Is it helpful when I paste the complete index.php code? – Joflx Jan 24 at 16:08
  • I would like to state as a matter of best practice that condition 3 doesn't make sense to implement because condition 4 will include this check (of course the trimmed value will be non-empty if the existence of content is true. Also, when checking for the existence of a substring (and not actually extracting the substring), best practice dictates that you should not be calling strstr() or stristr(), but rather strpos() or stripos(). This advice is specifically noted in the php manual: php.net/manual/en/function.strstr.php (see 2nd Note) – mickmackusa Jan 24 at 23:24
0

Ok I've just taken a look at the code for your template and it looks like a Joomla 1.5 template.

If you're using Joomla 1.5, PHP 7.2 isn't supported at all. I'd strongly suggest migrating to Joomla 3.x

If you already are using Joomla 3.x, then the $option simply isn't defined anywhere in your index.php or menu.php. Perhaps the PHP 7.0 version you had supressed all errors, not sure but it needs fixing.

The issue being is I have no idea what $option is supposed to be.

Based on the following code on your template:

$sideBarsScheme = array (
    //by default
    'default'=>      'left-right-content',

    // specify extra options for different components
    // if you dont write left or right - these positions wont be published
    // left-right-content | right-left-content | content-right-left | content-left-right
    // left-content-right | right-content-left
    // right-content | content-left | left-content | content-right
    'com_contact'=>  'content',
    'com_search'=>  'content-left-right',
    'com_content'=>  'left-content-right',
    'com_frontpage'=> 'left-content-right'

);

I believe this was originally a Joomla 1.0 template which was updated to support 1.5

So you have 2 options:

Option 1: Use a new (HTML5) template that utilises the Joomla API and was build fro Joomla 3.x

Option 2: Add the following line of code to the top of your index.php, just above the big block of code I shared above:

$option = JFactory::getApplication()->input->get('option');
  • The website/template is using the latest Joomla version J3.9.2 – Joflx Jan 24 at 16:14
  • It is a very old template, that's right. – Joflx Jan 24 at 16:14
  • I added $option = $jinput = JFactory::getApplication()->input->get('option'); and on PHP7 the error is not shown anymore. On PHP7.2 the homepage still gives a 500 error. Other pages give 0 - [] operator not supported for strings. I checked if $field->html = ''; is in index.php file but it's not there. – Joflx Jan 24 at 16:16
  • I would choose option 1 :) – Zollie Jan 24 at 19:21
  • @Joflx sorry I made a mistake in the code, please copy and paste it again – Lodder Jan 24 at 19:59
-1

I set debug in configuration file to 1 and opened another page (not homepage that only gave 500 error) The other page showed this error: 0 - [] operator not supported for strings [] operator not supported for strings
/home/xxx/domains/xxx.xx/public_html/templates/dj-business004/index.php:68

Call stack

Function Location

1 () JROOT/templates/dj-business004/index.php:68

I replaced

$schemeOutput = '';

by

$schemeOutput = array();

and the issue was solved. Website works on PHP7.2 now.

  • It's nice that finally you've found another error and corrected an expected array in the code, but your original question was totally different. So this is not an answer on your original question... – Zollie Jan 25 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.