ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: scripple on September 17, 2017, 03:36:33 pm

Title: bootstrap.php causes error in Theme.php
Post by: scripple on September 17, 2017, 03:36:33 pm
Testing a custom add-on in 1.1 RC2.  It calls a php function via javascript from the Display page.  First line is require(appropriate path/SSI.php) .   SSI.php then does require_once(appropriate path/bootstrap.php).

This eventually calls setupThemeContext() which produces the following error.

PHP Notice:  Undefined index: default_forum_action in forum/themes/default/Theme.php on line 737

This didn't happen in 1.0.x
Title: Re: bootstrap.php causes error in Theme.php
Post by: emanuele on September 17, 2017, 04:00:54 pm
hmm...
That should do for the moment.
In bootstrap.php search for:
Code: [Select]
else
{
setupThemeContext();
}
and change it to:
Code: [Select]
else
{
if (!empty($modSettings['front_page']) && is_callable(array($modSettings['front_page'], 'frontPageHook')))
{
$modSettings['default_forum_action'] = '?action=forum;';
}
else
{
$modSettings['default_forum_action'] = '';
}

setupThemeContext();
}
I would prefer to have this code somewhere else, but honestly I can't see a good place for it at the moment.
Title: Re: bootstrap.php causes error in Theme.php
Post by: scripple on September 17, 2017, 04:07:55 pm
Thanks.  (Wasn't sure where you wanted that fix.)
Title: Re: bootstrap.php causes error in Theme.php
Post by: emanuele on September 17, 2017, 04:09:42 pm
I'm not sure either. xD
To be honest, at that point I'm not sure the code belongs to the dispatcher to begin with.
Title: Re: bootstrap.php causes error in Theme.php
Post by: scripple on September 17, 2017, 04:56:23 pm
I'm not sure what the actual point of creating bootstrap is, but given it's name I would think both SSI and the dispatcher should call it for common start up.
Title: Re: bootstrap.php causes error in Theme.php
Post by: emanuele on September 17, 2017, 05:37:58 pm
The idea behind bootstrap is to extract from the SSI the logic that allows to start Elk and make it standalone.
SSI would become then just a sort of "demo" of how to use bootstrap, providing few functions as goodie.
In an ideal world I would use bootstrap at the beginning of index.php too, but... there are few differences that I didn't want to tackle.

The missing index here, instead is part of the "new feature" in 1.1 that allows controllers to be able to acts as the "home page" and is a sort of hack I had to put together in order to fix an issue.
So, when I introduced this index I put it in the dispatcher because it seemed to work well, but now I'm not sure any more.
Title: Re: bootstrap.php causes error in Theme.php
Post by: scripple on October 27, 2017, 04:52:02 pm
This doesn't seem exterminated.  Or at least I don't know how to use the new system.  I set ssi_layers in my front page and I still get the same error with your change.  Not surprising as your change is in an else clause after if(isset($ssi_layers)). 

I added $modSettings['default_forum_action'] = '' to the if statement.

Code: [Select]
// Load the stuff like the menu bar, etc.
if (isset($ssi_layers))
{
******************************************************************
Added this to make SSI happy
$modSettings['default_forum_action'] = '';
******************************************************************
$template_layers = Template_Layers::instance();
$template_layers->removeAll();
foreach ($ssi_layers as $layer)
{
$template_layers->addBegin($layer);
}
template_header();
}
else
{
if (!empty($modSettings['front_page']) && is_callable(array($modSettings['front_page'], 'frontPageHook')))
{
$modSettings['default_forum_action'] = '?action=forum;';
}
else
{
$modSettings['default_forum_action'] = '';
}

setupThemeContext();
}
Title: Re: bootstrap.php causes error in Theme.php
Post by: Spuds on October 27, 2017, 08:28:18 pm
Please try the change here: https://github.com/emanuele45/Dialogo/commit/18c8e0dd8eadaf1e0435c4064dad5351bd20917b which moves most of that else statement before the if/else stuff.
Title: Re: bootstrap.php causes error in Theme.php
Post by: scripple on October 27, 2017, 09:05:06 pm
That version works.  :)