• Resolved chillibasket

    (@chillibasket)


    On one of my websites I get an internal server error when trying to access the admin settings page for the Justified Gallery plugin. The page does not load and the following WordPress error message appears: “There has been a critical error on this website. Please check your site admin email inbox for instructions.” All other pages and the front-end galleries are still loading perfectly without any errors.

    I tried disabling other plugins to see if there was a compatibility issue. When I disabled “Smart Slider 3” by Nextend the Justified Gallery settings page loaded without showing an error, but only the header and the 3 page tabs appeared while the contents of the tabs was still missing. The settings page used to load fine in the past but I haven’t looked at it for a few months so am not sure if there was any specific update which caused the issue.

    I tried to replicate the issue on a second website by installing both plugins, but am not able to reproduce the error. Do you have any ideas what could be causing this issue, or suggestions of how to narrow it down further?

    Here is some information about my setup:

    • WordPress Version: 6.1.1
    • Php Version: 8.1.0 (recently updated)
    • Justified Gallery Version: 1.7.3
    • Smart Slider 3 Version: 3.5.1.14
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mateusz Czardybon

    (@matczar)

    Hi,

    Could you try to collect the error logs? Please follow these steps:

    1. Add the following constants to your wp-config.php file, right before the /* That's all, stop editing! Happy publishing. */ line:
      define( 'WP_DEBUG', true );
      define( 'WP_DEBUG_LOG', true );
    2. Trigger the error, so that it gets logged.
    3. Open the file with logs: wp-content/debug.log.
    4. Check the logs for errors.
    5. After checking, remove the constant added in point 1 and remove the wp-content/debug.log file.
    Thread Starter chillibasket

    (@chillibasket)

    Thanks for the extremely quick reply!

    Several of these warnings appear: PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /***.com/wp-includes/class-wp-scripts.php on line 710
    But the main error appears to be a memory allocation fault: PHP Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 20480 bytes) in /***.com/wp-includes/class-wpdb.php on line 2153

    The same errors also appear when Smart Slider is deactivated, so probably it is not the cause.

    (Edit) I’ve provisionally fixed this issue by increasing the WordPress memory limit in wp-config.php. I’ll have a closer look at why this limit was being exceeded this weekend when I have more time.

    Thread Starter chillibasket

    (@chillibasket)

    I installed the “Query Monitor” plugin to see which database queries were using up excessive memory. When loading the “Justified Gallery” settings page, four large database request are made within the file wp-content/plugins/justified-gallery/includes/Gallery.php:214:

    • WP_Query->get_posts() – loads ~28,000 rows
    • _prime_post_caches() – loads ~28,000 rows
    • WP_Term_Query->get_terms() – loads ~28,000 rows
    • update_meta_cache() – loads ~113,000 rows

    These database queries appear to be very inefficient and are pretty much loading the whole database into memory. For small websites this usually does not cause a problem but since my website has an unusually large database, it is causing the memory issues and this was the root cause of the critical error I saw. The Settings page does not appear to show any information which would warrant these database queries, so I’m unsure as to why they are called.

    Thread Starter chillibasket

    (@chillibasket)

    In Gallery.php the issue was that it is doing a database search even when the post_parent ID is 0. Since the admin page is not a post, this bug causes the database to load all posts and all images. To solve this, one extra condition could be added to the if-statement on line 207; I quickly tested it on my site and it appears to work:

    } else if ($id != 0) {
    $attachments = get_children( array(
    'post_parent' => $id,
    'post_status' => 'inherit',
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'order' => $atts['order'],
    'orderby' => $atts['orderby'],
    ) );
    }

    Let me know if you can replicate this issue and the potential fix. If so I can mark this as resolved.

    Plugin Author Mateusz Czardybon

    (@matczar)

    Hi,

    This issue has been fixed in v1.8.1.

    Thread Starter chillibasket

    (@chillibasket)

    Thanks! I just tested it now and can confirm that the problem is fixed.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Critical Error when loading Plugin Settings Page’ is closed to new replies.