Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1476557

    I’m surprised I couldn’t find anything else about this on the forum as it’s happening to me on all my sites that use the portfolio… and it takes down the site completely.

    In /themes/enfold/config-templatebuilder/avia-shortcodes/portfolio/portfolio.php on line 1312 inside the function sort_cat_string, the WordPress function get_the_terms() is called. get_the_terms returns OBJECTS (See: https://developer.wordpress.org/reference/functions/get_the_terms/) But the code in this function assumes it’s returning arrays, leading to Fatal errors.

    I’d love to see a fix to this get integrated so I can stop manually patching it! :)

    #1476562

    I run many portfolios – and I have never seen such a fatal error on my websites. As you mentioned, there are no other messages about this on the forum.
    What exactly are you changing manually? – Do you have any custom post types running?

    #1476565
    $item_categories = get_the_terms( $the_id, $params['taxonomy'] );
    
    			if( is_object( $item_categories ) || is_array( $item_categories ) )
    			{
    				foreach( $item_categories as $cat )
    				{
    					//fix for cyrillic, etc. characters - isotope does not support the % char
    					$cat['slug'] = str_replace('%', '', $cat['slug'] );
    
    					$sort_classes .= $cat['slug'] . '_sort ';
    				}
    			}

    becomes

    $item_categories = get_the_terms( $the_id, $params['taxonomy'] );
    
    			if( is_object( $item_categories ) || is_array( $item_categories ) )
    			{
    				foreach( $item_categories as $cat )
    				{
    					//fix for cyrillic, etc. characters - isotope does not support the % char
    					$cat->slug = str_replace('%', '', $cat->slug );
    
    					$sort_classes .= $cat->slug . '_sort ';
    				}
    			}

    Since they are objects, not arrays. I usually have custom post types and custom taxonomies. These are going through custom taxonomies in my current example.

    #1476568

    the other way round ? the first is your edited version – and the second the existing enfold one?

    #1476573

    The second one is what I’m changing it to – but I see what you mean, a fresh copy has these changes in them! But I have clients who when they auto-update are getting the old version of this code, and the site crashes, so I guess that’s where the investigation needs to go…. Let me check and see how they’re updating.

    #1476574

    Confirmed that in this most recent case it occurred when she updated the theme automatically through the Theme Updates feature. But if it’s not in the actual Enfold files incorrectly then I’d like to keep this open and monitor it after the next update in case there is something wrong with the sync for some reason.

    #1477829

    I’ve gotten a bit turned around, I think I’ve been staring at this problem too long. It seems that Enfold uses objects by default and that’s the problem, and that’s the error I’m getting.
    PHP Fatal error: Uncaught Error: Attempt to assign property “slug” on array in */public_html/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/portfolio/portfolio.php:1312
    and the manual fix I have to make is to switch them to arrays. (The opposite of what I said earlier).

    I guess the question is why is $cat seen as an array here?

    $item_categories = get_the_terms( $the_id, $params['taxonomy'] );
    if( is_object( $item_categories ) || is_array( $item_categories ) ) {
      foreach( $item_categories as $cat ) {
        $cat->slug = str_replace('%', '', $cat->slug );
      }
    }
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    • This reply was modified 2 weeks, 1 day ago by christiemade.
    #1477841

    I printed out $item_categories and it shoots back a WP_Error Object, so that’s surely the issue.

    #1477852

    Hi,

    We can’t reproduce the issue on our end. The sorting categories are returned as objects, not arrays.

    View post on imgur.com

    Have you tried deactivating the plugins?

    Best regards,
    Ismael

    #1477955

    Go ahead and close this, I’ll have to troubleshoot why the categories are errors, which is unrelated to the original request, anyway.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Attempt to read property “slug” on array portfolio/portfolio.php on line 1312’ is closed to new replies.