• Resolved Magali

    (@oellin)


    Hi !

    I have a fatal error when i try to complete the indexation.

    There’s the message :

    XHRPOST
    https://****.******.com/wp-admin/admin-ajax.php
    [HTTP/2 500 Internal Server Error 560ms]
    
    Fatal error: Uncaught Error: Cannot access offset of type string on string
    in /***/******/*****/wp-includes/media.php on line 2210
    Call stack:
    
    1. img_caption_shortcode()
        wp-includes/shortcodes.php:355
    2. do_shortcode_tag()
    3. preg_replace_callback()
        wp-includes/shortcodes.php:227
    4. do_shortcode()
        wp-content/plugins/relevanssi-premium/lib/utils.php:225
    5. relevanssi_do_shortcode()
        wp-content/plugins/relevanssi-premium/lib/indexing.php:1507
    6. relevanssi_index_content()
        wp-content/plugins/relevanssi-premium/lib/indexing.php:592
    7. relevanssi_index_doc()
        wp-content/plugins/relevanssi-premium/lib/indexing.php:359
    8. relevanssi_build_index()
        wp-content/plugins/relevanssi-premium/lib/admin-ajax.php:85
    9. relevanssi_index_posts_ajax_wrapper()
        wp-includes/class-wp-hook.php:308
    10. WP_Hook::apply_filters()
        wp-includes/class-wp-hook.php:332
    11. WP_Hook::do_action()
        wp-includes/plugin.php:517
    12. do_action()
        wp-admin/admin-ajax.php:188

    I have this error on ajax call action :

    relevanssi_index_posts

    I tried to activate another theme, and with only relevanssi, the error still exists. (I have WP file Download but i try without and nothing). I read known conflitcs page ??

    There’s the function on l2210 en media.php (inside the img_caption_shortcode function) :

    if ( ! isset( $attr['caption'] ) ) {
    if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
    $content         = $matches[1];
    $attr['caption'] = trim( $matches[2] ); /**TRIGGER L2210**/
    }
    } elseif ( strpos( $attr['caption'], '<' ) !== false ) {
    $attr['caption'] = wp_kses( $attr['caption'], 'post' );
    }

    I saw similar problem here https://www.ads-software.com/support/topic/php-fatal-error-when-expand-shortcodes-is-enabled/ but your quickfix is now include so i don’t know what to do !

    Have a nice day, i hope you’ll find my error !

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Mikko Saari

    (@msaari)

    It’s something in your captions. What’s the next post Relevanssi is indexing? Relevanssi indexes posts in the descending order of post ID. You can see the last indexed post ID on the indexing settings page, so the next post is the one below that. What kind of captions are there in that post?

    Does disabling shortcode expansion help?

    Thread Starter Magali

    (@oellin)

    Thxs a lot for your reply !

    What’s the next post Relevanssi is indexing?

    How can i know that ? I have the lower ID but not the higher.

    7461 documents in the index.
    0 counts in the index.
    0 taxonomy terms in the index.

    1157153 terms in the index.
    141 is the lowest indexed content ID.

    For captions its ACF fiels. And the disabling shortcode didnt change anything.

    Have a good day !

    Plugin Author Mikko Saari

    (@msaari)

    If the lowest post ID indexed is 141, the next one is the one below that, as Relevanssi goes through the posts in descending order. Try 140, 139, 138… and so on until you find one that is a post.

    Can you show me an example of a caption with an ACF field?

    Thread Starter Magali

    (@oellin)

    Oh i see ! Sorry my question was stupid ! Because plugin say to me “1200 posts left to complain the indexation”, so i think it was higher not lower.

    • 140 is a media
    • 139 doesnt exist
    • 138 is a media
    • 137 doesnt exist
    • 136 is a media
    • 135 doesnt exist
    • 134 doesnt exist
    • 133 doesnt exist
    • 132 IS A PAGE ! And contains two shortcodes. Hum.

    When i say “doesnt exist” i have this message like a wp_die()

    You are trying to edit content that does not exist. Maybe it was deleted?

    However hook is already placed on functions.php (and i also tested with relevanssi_disable_shortcodes_excerpt)

    add_filter(
      'relevanssi_disabled_shortcodes',
      function( $shortcodes ) {
        return array_merge( $shortcodes, array( 'my_shortcode', 'my_shortcode2' ) );
      }
    );

    Still 500Internal Server Error with response on ajax :

    Fatal error: Uncaught Error: Cannot access offset of type string on string
    in /*****/*******/*********/wp-includes/media.php on line 2210

    I’m sorry !

    Plugin Author Mikko Saari

    (@msaari)

    This problem isn’t about shortcodes in general but about image captions specifically. Are there any image captions on page 132?

    You said you use ACF fields in captions. Can you elaborate on that, what does that mean?

    Thread Starter Magali

    (@oellin)

    Hi !

    In this shortcode there’s a loop wp_query but no custom fields on images sorry.

    I though it tried to index a CPT with custom fields on images but no, the ID 132 is a page.

    Plugin Author Mikko Saari

    (@msaari)

    When you try to save the page 132, does that go through without problems? If you do that, is the lowest post ID indexed now 132?

    Thread Starter Magali

    (@oellin)

    You’re right, i saved my page 132 and now :

    132 is the lowest indexed content ID.

    But now it triggers on 131 ID, is there a tips for it or i have to save all pages + CPTs ? (1510 publications left).

    Plugin Author Mikko Saari

    (@msaari)

    Try going downwards for a while – Relevanssi probably tries to index the next ten posts or so, so if there’s a problem, it should come up soon. If you can save the next ten posts without problems, then we can try something else.

    Thread Starter Magali

    (@oellin)

    Hi !

    I’m sorry for the delay.

    Can you give me the other solutions ? With more than 1500 publications left i cant save each post (most of them have a shortcode).

    Have a nice day !

    Plugin Author Mikko Saari

    (@msaari)

    I still don’t know the problem, so I can’t give you a solution. I wasn’t expecting you to manually save 1500 posts – I was hoping within the next ten posts there would be one that would trigger the fatal error, so I could start to get an idea what is causing the problem. As it is, I don’t know what causes the fatal error exactly, so I can’t provide a fix.

    Thread Starter Magali

    (@oellin)

    Yeah, on this website there’s a custom post type for create shortcodes.

    I don’t index them but they are everywhere on post / pages etc.

    Plugin Author Mikko Saari

    (@msaari)

    The best solution I can offer is the relevanssi_post_content filter hook, which runs before the shortcode expansion. You can use it to remove the caption shortcodes from the post content before Relevanssi runs do_shortcode(). You can find the filter documentation here: https://www.relevanssi.com/user-manual/filter-hooks/relevanssi_post_content/.

    Thread Starter Magali

    (@oellin)

    Thxs for your reply.

    Unfortunately all solutions didnt unlock the problem so, i removed the plugin.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Fatal error media.php’ is closed to new replies.