Jump to content

Weird bug with widget on PHP 8


Go to solution Solved by DawPi,

Recommended Posts

Hello,

I have strange (for me) problem with one of the widgets on PHP 8. On 7.4 was fine.

Error code:

#0 /.../plugins/sdstreamcontent/widgets/sdStreamContent.php(56): IPS\_Theme->getTemplate('plugins', 'core', 'global')
#1 /.../system/Widget/Widget.php(103): IPS\plugins\sdstreamcontent\widgets\_sdStreamContent->init()
#2 /.../system/Widget/Widget.php(396): IPS\_Widget->__construct('34y8hagzy', Array, NULL, 'vertical')
#3 /.../system/Dispatcher/Front.php(626): IPS\_Widget::load(Object(IPS\Plugin), 'sdStreamContent', '34y8hagzy', Array, NULL, 'vertical')
#4 /.../system/Dispatcher/Dispatcher.php(155): IPS\Dispatcher\_Front->finish()
#5 /.../index.php(13): IPS\_Dispatcher->run()
#6 {main}

 

What is might be?

Init function in the widget file is standard:

    /**
     * Initialise this widget
     *
     * @return void
     */
    public function init()
    {
        $this->template( array( \IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' ), $this->key ) );

        parent::init();
    }

Template bit is there:

obraz.png.0611faa7f0a138e20122a95f7c675e69.png

 

 

Any tips, advices? Thanks in advance.

Link to comment
Share on other sites

56 minutes ago, Adriano Faria said:

You don’t need to return parent in that case. See 

 

that only applies to applications, not plugins. it checks to see if the $app property is populated, plugins that property is empty. 

@DawPi what is the error message? you provide the trace log, but excluded the actual error message?

Link to comment
Share on other sites

my best guess, is $this->key is either empty or its not the name of the template, try setting the name of the template there instead of using $this->key in:

 

$this->template( array( \IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' ), $this->key ) );

(as the template class will throw an unexpectevalueexception if it can't find the template group)

Edited by CodingJungle
Link to comment
Share on other sites

46 minutes ago, CodingJungle said:

my best guess, is $this->key is either empty or its not the name of the template, try setting the name of the template there instead of using $this->key in:

 

$this->template( array( \IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' ), $this->key ) );

(as the template class will throw an unexpectevalueexception if it can't find the template group)

Quote

/**
 * sdStreamContent Widget
 */
class _sdStreamContent extends \IPS\Widget
{
    /**
     * @brief Widget Key
     */
    public $key = 'sdStreamContent';

Theme:

obraz.png.485a1c1ccf0867a54fd659453081edb8.png

 

 

43 minutes ago, Sonya* said:

Just to mention, if you are on latest beta, no custom block templates are loaded at the moment:

I'm on 4.6.10.

Link to comment
Share on other sites

Sure:

<h3 class='ipsType_reset ipsWidget_title'>{$title|raw}</h3>
{{if $viewType}}
    <div class='ipsWidget_inner ipsPad_half'>
        <ul class='ipsDataList ipsDataList_reducedSpacing' data-controller='core.front.core.ignoredComments'>
            {{foreach $results as $result}}
                {template="sdResult" group="plugins" app="core" location="global" params="$result[ 'indexData' ], $result[ 'authorData' ], $result[ 'itemData' ], $type"}
            {{endforeach}}
        </ul>
    </div>
{{else}}
    {{if $orientation == 'vertical'}}
        <div class='ipsPad_half ipsWidget_inner'>
            <ul class='ipsDataList ipsDataList_reducedSpacing' data-controller='core.front.core.ignoredComments'>
                {{foreach $results as $result}}
                    {template="sdResultRow" group="plugins" app="core" location="global" params="$result[ 'indexData' ], $result[ 'authorData' ], $result[ 'itemData' ], $result[ 'containerData' ]"}
                {{endforeach}}
            </ul>
        </div>
    {{else}}
        <div class='ipsWidget_inner'>
            <ul class='ipsDataList' data-controller='core.front.core.ignoredComments'>
                {{foreach $results as $result}}
                    {template="sdResultRow2" group="plugins" app="core" location="global" params="$result[ 'indexData' ], $result[ 'authorData' ], $result[ 'itemData' ], $result[ 'containerData' ]"}
                {{endforeach}}
            </ul>
        </div>
    {{endif}}
{{endif}}

 

Link to comment
Share on other sites

template looks fine, i'm assuming the other 3 templates being called are also clean?

have you checked the server error log to see if it gives any more information? 

from what i can tell, one of the plugins templates is causing the eval to throw an error (it might not even be your plugin that is the culprit, cause any plugin with a template is gonna be apart of that template group).

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...