• Resolved lucatd

    (@lucatd)


    Un errore di E_PARSE è stato causato nella linea 1447 del file …/wp-content/plugins/lazy-blocks/classes/class-blocks.php. Messaggio di errore: syntax error, unexpected ‘?’

    How can we resolve it?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Same here in Pro Version. Hope, this is getting fixed soon as it also happened in production environment.

    Plugin Author Nikita

    (@nko)

    Hey guys.

    This line contains the ?? operator, which is introduced in the PHP 7.0 https://github.com/nk-crew/lazy-blocks/blob/a4219fcf9cbe111a2915fa528f6bf1f0462f35ac/classes/class-blocks.php#L1447C13-L1447C13

    Not sure it is a problem because our plugin requires PHP 7.2

    Regards,
    Nikita.

    We use php 8.1., so that is not the issue. My error message is a bit different, but it’s caused by the same file:

    Error Type E_ERROR in line 7 of the file xxxx/wp-content/plugins/lazy-blocks-pro/core-plugin/classes/class-blocks.php(1359) : eval()’d code causes error: Uncaught TypeError: Cannot access offset of type string on string in xxx/wp-content/plugins/lazy-blocks-pro/core-plugin/classes/class-blocks.php(1359) : eval()’d code:7 Stack trace:

    #0 xxxx/wp-content/plugins/lazy-blocks-pro/core-plugin/classes/class-blocks.php(1359): eval()

    #1 xxxx/wp-content/plugins/lazy-blocks-pro/core-plugin/classes/class-blocks.php(1519): LazyBlocks_Blocks->php_eval()

    #2 xxxx/wp-content/plugins/lazy-blocks-pro/core-plugin/classes/class-blocks.php(1391): LazyBlocks_Blocks->render_callback()

    Plugin Author Nikita

    (@nko)

    Hi @markusmai,

    Your case is different. Your error leads to this line https://github.com/nk-crew/lazy-blocks/blob/v3.4.0/classes/class-blocks.php#L1359C24-L1359C24

    This eval function is used when you add a string with PHP code to render your block output. Something is wrong in your block output code and since it is rendered using eval it is hard to debug what exactly is failed.

    Try to change your block code to the functional callback or template render to better understand what happens.

    Regards,
    Nikita.

    Okay, thank you. I think I can track that back to one of the custom blocks, where we used a different output method for the editor view.

    Best regards,
    Markus

    I tracked the issue back to a bunch of blocks, which all use the post selector. Since the last plugin update (June 30th) I cannot use them any more like I could before. I see an error in the editor as well, when I try to add them. When I update the plugin to the latest version (July 6th), I get a plugin has no header issue and also a plugin error I posted in my reply here and wordpress changes to recovery mode.

    I followed you suggested options and switched the blocks to php code in functions.php instead of the admin interface ony my staging environment, but this only solved the plugin error in the plugin list. I cannot add the blocks anymore, like I could in the versions before.

    Regarding the blocks, I have a post selector, where users can choose the posts they want to display in this block. In the combined code for FE & BE I go through that selected post objects via foreach like your documentation shows, I check for post_thumbnail and build a post grid with the selected posts and print them out via echo post by post.

    <?php 
    foreach( $attributes['post-obj-select'] as $post_selects ):
    
    /** Check Post_Thumbnail **/
     if (has_post_thumbnail( $post_selects->ID ) ) {
       $img = get_the_post_thumbnail_url( $post_selects->ID, "post-teaser" );
     } else {
       $img = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
     }
     
    echo '<a href="'.get_the_permalink($post_selects->ID).'"><img class="img-responsive wp-image-'.$post_selects->ID.'" src="'.$img.'" /><h4>'.esc_html($post_selects->post_title).'</h4></a>';
     
    endforeach; 
    ?> 

    When I use the code without the block environment as vanilla php, I don’t get any errors or warnings. Why is this causing troubles? The Log file only tells me about the eval()’d issue. All I changed is the version of the plugin.

    Thank you for any advice, how I can solve this issue.
    BR M

    Plugin Author Nikita

    (@nko)

    Hi @markusmai,

    I don’t know actually why do you get so many problems with the plugin, but if you talking about the Posts control, you most probably purchased the Pro plugin.

    Please, create a support ticket in our ticket system for Pro customers – https://nk.ticksy.com/

    Regards,
    Nikita.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘E_PARSE Error’ is closed to new replies.