Topic Closed
a2exfr
242 Posts
25.8K Downloads
2 Themes
10 Plugins

Need help to fix error with my plugin Catalog Easy .  http://www.gpeasy.com/Plugins/287_Catalog_Easy

Some users have fatal error:

Error File: /include/tool/SectionContent.php
Line: 38
Error Message: Unsupported operand types

Somewhing like that:

type Fatal Error (1) message Unsupported operand types file /homepages/29/d66127337/htdocs/testlauf/include/tool/SectionContent.php line 39 request /WER addon_name Catalog Easy addon_id 287 time 1439654467 request_method GET

I used it at line 276

$content = section_content::Render($file_sections,$title,$file_stats);

 

 

4 years ago#8071

Josh S.
2K Posts
280K Downloads
16 Themes
18 Plugins

Looks like the error comes from this code:

        $section_data        = $sections[$curr_section_num];
        $section_data        += array('attributes' => array() );

The $section_data variable should be an array but is probably a string.

So, when you call section_content::Render($file_sections,$title,$file_stats); the $file_sections variable should be an array of arrays. Can you check the contents of $file_sections?

4 years ago#8072

a2exfr
242 Posts
25.8K Downloads
2 Themes
10 Plugins

Yes, $file_sections is array of arrays.

Problem is that in my case everhing work fine.

it's a part of code only where $file_sections is used

function getImageandInfo($title){
    
        $file = gpFiles::PageFile($title);

        $file_sections = $file_stats = array();
        ob_start();
        include($file);
        ob_get_clean();

        if( !is_array($file_sections) ){
            return;
        }

        //get short info and datafilter
        
        foreach ($file_sections as $sect){
        
            if(    isset($sect['attributes']['class'])){
            
                if ($sect['attributes']['class'] == "short_info"){
                    $short_info = $sect['content'];
                }
            }
        
            if(    isset($sect['attributes']['data-filter'])){
                            
                    $datafilter = $sect['attributes']['data-filter'];
                
            }            
        
        
        }
        
        if( !isset($short_info) ){
            $short_info="";
        }
        
       //get the image
        $content = section_content::Render($file_sections,$title,$file_stats);

4 years ago#8078

juergen
1.5K Posts
53.7K Downloads
16 Plugins
design, web development & visual effects

Hmm, I would check for the attributes array first:

if ( isset($sect['attributes']) ){
  if ( isset($sect['attributes']['class']) ){
  [...]
  }
}

Not all file sections have the attributes array (e.g. the pre-defined ones like Home.php, More.php)
Don't know if this is the cause* but I would do the check this way.
edit: * probably not
 

edit2: Could it be that 'attributes' in one of the sections is something other than an array, maybe NULL or FALSE?
I think this would cause the fatal 'unsupported operand types' error.

Edited: 4 years ago#8079

a2exfr
242 Posts
25.8K Downloads
2 Themes
10 Plugins

But if  section "attributes" other than array (null or false),  do not this must be a reason to make error on  page that contains such a section,  when Gpeasy render it?

Anyway I check it.

 

4 years ago#8080

juergen
1.5K Posts
53.7K Downloads
16 Plugins
design, web development & visual effects
If this is actually the case, I don't think gpEasy itself has created it but maybe another plugin.
(and I desperately hope it's not one if mine o_O - It wouldn't be the first time one of my plugins cause some hassle)
4 years ago#8082

Josh S.
2K Posts
280K Downloads
16 Themes
18 Plugins

Problem is that in my case everhing work fine.

Hmm. Yes it would help tremendously if we could see the data that actually causing the problem

4 years ago#8083

juergen
1.5K Posts
53.7K Downloads
16 Plugins
design, web development & visual effects
If the error comes from SectionContent.php line 39 I'd say it neccesarily must be 'attributes' something other than an array (could also be a string, integer, whatever)

I have checked my plugins to see if one of them might be the cause, but I found nothing.

So I guess the errors got posted from someone either playing around with the content arrays or creating his own plugin and has error reporting on (which is quite a bad idea when developing).

I can't imagine something different.
4 years ago#8085

Josh S.
2K Posts
280K Downloads
16 Themes
18 Plugins

I don't think it's the 'attributes'. For example, this test code works fine:

        $section_data    = array('attributes'=>'');
        $section_data    += array('attributes'=>array());

It also works if we start with $section_data = array(). However, we get a fatal error if $section_data is a string or object.

I've added some checks to prevent invalid section data from causing a fatal errors.

4 years ago#8088

a2exfr
242 Posts
25.8K Downloads
2 Themes
10 Plugins
If someone wil have such error again, I would require information about all installed plugin.
4 years ago#8089

Josh S.
2K Posts
280K Downloads
16 Themes
18 Plugins
Yep, not much we can do about this right now without more information.
4 years ago#8091

juergen
1.5K Posts
53.7K Downloads
16 Plugins
design, web development & visual effects

this test code works fine:

        $section_data    = array('attributes'=>'');
        $section_data    += array('attributes'=>array());

really? I would have thought "unioning" an array with a string would cause such an error.

4 years ago#8092

Josh S.
2K Posts
280K Downloads
16 Themes
18 Plugins

This only does the union of $section_data and the array('attr....). The union operation is not recursive so there's no union of the first 'attributes' string and the second 'attributes' array.

4 years ago#8093

Topic Closed

 

News

elFinder 2.1.50 in Upcoming Release
12/28/2019

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1
8/12/2017

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register