• Resolved Harm10

    (@harm10)


    I have just updated WordPress to version 5.6.2 and Yoast to version 15.9 to experience memory exhaustion.
    I have analyzed this problem to identify that when dumping global variable $shortcode_tags this problem occurs. Further analyzing I found that shortcode wpseo_breadcrumb consist of an array that is too large to be displayed.
    When I code this ($value = array of shortcode wpseo_breadcrumb)

    $serialized_data = serialize($value);
    $size = strlen($serialized_data);
    echo 'size of wpseo_breadcrumb:'.$size.'<br/>';

    the result is: size of wpseo_breadcrumb:914533

    So apparently there is something wrong with this shortcode?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi @harm10,

    That sounds very strange. To help us troubleshoot, we’d like to get the following information:

    1. Are all your plugins and themes updated? If not, does updating solve the problem?

    2. We’d like to see if we can reproduce this, so can you give us more details like a link to a complete code example or more context about where this problem is happening?

    3. Can you let us know how you implemented the Yoast breadcrumbs on your site? We have details about the recommended ways to do this in this guide: How to implement Yoast SEO breadcrumbs.

    Thread Starter Harm10

    (@harm10)

    All my plugins and themes are up-to-date.
    I have changed the way of displaying the content of global shortcode_tags as I described above. I now looked at different pages and on different sites and in all cases the size of wpseo_breadcrumb is over 100.000. Sometimes not much (so probably the storage exhaustion would not happen for that particular page) but on my test site’s home page (not publicly accessible and created with block approach in stead of static lay-out) the size is huge!
    Apparently what is in that shortcode is created based on the page you are on?

    I do not understand your question about a code example. I am only looping through the global array of wordpress named $shortcode_tags. Nothing more. Due to the enormous size of this particular shortcode the storage problems occur. If I skip this shortcode from display entirely no problems occur anywhere.

    As far as I am aware I am not using wpseo_breadcrumb shortcode anywhere. At least I have not added it somewhere. I do not even know the functionality of this shortcode!
    What is it supposed to do?

    I would like to add that this problem is there since recent updates. So either the last WordPress update is the culprit or maybe the last Yoast update? If you want me to I can rollback any of those 2 on my test site and see what the size will be? I cannot look into the array itself as it gives me this memory exhaustion and my site breaks.
    If you want me to display part of this array please supply me with a PHP code for it.

    Hi,

    Yoast has two ways to add breadcrumbs to a site. We are not sure exactly how you are adding them. We would like some more information.

    1. Adding Breadcrumbs

    You can use our breadcrumb shortcode: [wpseo_breadcrumb]. This works only on the page that has this shortcode. You would need to insert it either using the text editor of the Classic Editor or insert a Gutenberg Shortcode block. See image here as an example: https://ibb.co/VCWKmYb.

    If you want to add breadcrumbs across all your site in an efficient manner you will need to add our breadcrumb code snippet here into a theme’s file (like the header.php).

    Can you elaborate a bit more on the following:

    A. Are you using the Yoast breadcrumbs on the site?

    B. If so, how did you implement them on the site?

    C. OR are the Yoast breadcrumbs not in use anywhere on the site and you just happened to analyze the shortcode data and determined that Yoast is generating some large breadcrumb shortcode data?

    2. Site Requirements

    Can you confirm your server has all the right requirements?  If you are not sure, speak to your host provider. They may need to increase the PHP memory by doubling or tripling it. This guide explains more: https://kb.yoast.com/kb/plugin-requirements/.

    3. I have changed the way of displaying the content of global shortcode_tags as I described above.

    To clarify, you modified the default WordPress settings for shortcodes and are discovering that the Yoast breadcrumbs are increasing in size?

    If that is correct, if you were to restore the WordPress defaults for shortcodes on the site does the issue resolve?

    4. I now looked at different pages and on different sites and in all cases the size of wpseo_breadcrumb is over 100.000.

    Can you elaborate a bit more on what the 100.000 is expected to measure? Is it a percentage of increase?

    5. Further analyzing I found that shortcode wpseo_breadcrumb consist of an array that is too large to be displayed.

    Can you provide an example of this array? If it is a huge file you can put the file in a Github gist and provide a link to it.

    6. Size of Site

    Can you elaborate more on how large the site is in terms of content? Is it like 100 URLs, 1000 URLs or something large like 1 million URLs?

    • This reply was modified 3 years, 1 month ago by Pcosta88.
    Thread Starter Harm10

    (@harm10)

    1 C

    2
    I am maintaining several sites that never had storage problems. Since recent updates (no changes in the home pages concerned whatsoever) this problem has occurred.

    3
    I am using debug code that is displayed in the page source (hidden but clickable to open) that is only added when I have logged in.
    Code for that is:

    ob_start(); // Start output buffering
    global $shortcode_tags;
    R_Debug::dump_remark($shortcode_tags);
    $shortcodes = ob_get_clean();
    $dcode .= '<div id="remark_debug_shortcodes" class="remark_debug_list" style="display: none">Shortcodes:'.$shortcodes.'</div>';

    dump_remark code:

    static function dump_remark($dumparray) {
    
            $output = '';
            $dumpcnt = count($dumparray);
            $output .= 'Array count ' . $dumpcnt . '<br/>';
            foreach ($dumparray as $key => $value) {
                if (is_array($value)) {
                    $serialized_data = serialize($value);
                    $size = strlen($serialized_data);
                    $output .= $key . ' is an array!<br/>';
                    if ($size > 10000) {
                        $output .= 'array size is too large! ' . $size . '<br/>';
                    } else {
                        $output .= print_r( $value, true );
                    }
                }
                else { $output .= "{$key} => {$value} <br/>"; }
            }
    
            echo '<pre>' . $output . '</pre>';
        }

    So I am not changing anything only displaying.

    4 See code above.

    5 This array is huge. So how would I be able to show it’s content? That why I asked for a sample PHP code.

    6 All involved sites are small. Only tens of URLs.

    I could give you an URL but I do not want to publish that here.

    • This reply was modified 3 years, 1 month ago by Harm10.
    Plugin Support Michael Tiña

    (@mikes41720)

    Hi,

    We did introduce some changes in v15.8 of the Yoast SEO for WordPress plugin relating to breadcrumbs — https://yoast.com/wordpress/plugins/seo/change-log-wordpress-seo/

    • Adds a breadcrumbs block, allowing users to add breadcrumbs to a page or post using the block editor, or to a widget area using the Gutenberg plugin.
    • Changes the default setting to enable breadcrumbs for the theme to true. This means themes that declare theme support for this feature automatically output Yoast breadcrumbs on every page. Existing installs will not be impacted by this change.
    • Breadcrumbs settings can now always be edited, regardless of if the breadcrumbs are enabled for the theme.
    • Like the block, the breadcrumbs shortcode is now always rendered, regardless of if the breadcrumbs are enabled for the theme.
    • Makes sure the breadcrumbs schema is always present, except on 404 pages.
    • If you roll back to v15.7 here, could you check if the issue then doesn’t occur anymore on your site?

    Thread Starter Harm10

    (@harm10)

    On version 15.9 I need to protect my sites for this storage problem by using the code published (too large).
    On 15.9 wpseo_breadcrumb shortcode exists and on my test site and the size is 914533 (Home page).
    On 15.7 the shortcode does not exist at all so cannot pose a problem.

    Still I am wondering what is in it? A breadcrumb is supposed to be small especially on the Home page! Do the WP blocks (I have a lot of them on my Home page of my test site) “blow” up the content?

    Is there a part of the content of the breadcrumb that you want to see/analyze? If so please specify the best way to code that in PHP.

    Hi @harm10,

    Thanks for bringing this to our attention and for giving us more details. Based on the information you provided, this is something that we expect to be a bug that needs to be checked by our developers. We’re actively using the bug tracking on our GitHub repository so your best next step would be to create a new issue for our developers at https://github.com/Yoast/wordpress-seo/issues/new.

    You’ll need an account to create a new issue. If this is your first bug report, please check out: https://kb.yoast.com/kb/how-to-write-a-good-bug-report/.

    Thread Starter Harm10

    (@harm10)

    I am used to reporting problems on GitHub (I have an account) but in this case this seems a bit extra work? Why should I create a totally new post (and having to explain everything anew) while you can just forward this all to development? Other plug-in support does that too. So why this difference?

    Plugin Support Michael Tiña

    (@mikes41720)

    Hi,

    We would need your help on this. You know how to reproduce this issue best, so the better you help us, the better we’ll be able to reproduce and fix it. It would be on your own environment and set-up as well, so those details are important. Another plus would be that you would be able to subscribe and receive updates directly from our developers when they comment on the issue.

    You can certainly reference this forum thread when creating the bug report as well. We appreciate your assistance on this.

    You can learn more about it here — https://yoast.com/help/how-to-write-a-good-bug-report/

    Just saw response.

    Thread Starter Harm10

    (@harm10)

    I have reported on GitHub. Here

    Plugin Support devnihil

    (@devnihil)

    @harm10 Thank you for submitting the bug report. If you should need any further assistance, please do not hesitate to let us know.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘wpseo_breadcrumb huge in size and exhausting memory’ is closed to new replies.