• Resolved nosilver4u

    (@nosilver4u)


    I was just going to test NextGEN with EWWW Image Optimizer in preparation for a release. When I activated NextGEN, I get these errors:

    [20-Jan-2022 22:23:49 UTC] PHP Warning:  Array to string conversion in /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php on line 120
    [20-Jan-2022 22:23:49 UTC] PHP Warning:  Only the first byte will be assigned to the string offset in /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php on line 120
    [20-Jan-2022 22:23:49 UTC] PHP Fatal error:  Uncaught Error: Cannot use string offset as an array in /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php:121
    Stack trace:
    #0 /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php(139): C_Photocrati_Transient_Manager->_track_key()
    #1 /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php(219): C_Photocrati_Transient_Manager->set()
    #2 /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/wordpress_routing/package.module.wordpress_routing.php(21): C_Photocrati_Transient_Manager::update()
    #3 [internal function]: A_WordPress_Base_Url->cache_lookups()
    #4 {main}
      thrown in /sites/test.exactlywww.com/files/wp-content/plugins/nextgen-gallery/non_pope/class.photocrati_transient_manager.php on line 121
    

    I haven’t used NextGEN in a while, but I just updated it. At first I thought it was from the latest update, but then I remembered I’m on PHP 8 now, so it’s entirely possible it’s connected to that. Let me know if you need any other info. Theme is Twenty Twenty, and not many plugins active.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter nosilver4u

    (@nosilver4u)

    Quick update, I swapped the site over to PHP 7.4 and still had the same errors.

    Benjamin

    (@benjaminowens)

    Hi @nosilver4u

    Could you try adding this to your wp-config.php:

    define('NGG_DISABLE_PHOTOCRATI_CACHE_TRACKER', true);

    and let me know if that resolves the issue.

    Thanks!

    Thread Starter nosilver4u

    (@nosilver4u)

    Nope, still throws the errors.

    Benjamin

    (@benjaminowens)

    It’s most likely then a complication with an external object cache; may I ask what other plugins you have active?

    As a temporary workaround you could edit that file (nextgen-gallery/non_pope/class.photocrati_transient_manager.php) and comment lines 113 through 122 (the entirety of the _track_key($key) method — this makes it so that NextGEN can’t flush it’s transients, but that’s not a major problem as transients will expire eventually anyway.

    Thread Starter nosilver4u

    (@nosilver4u)

    Yes, I do have an external object cache, though I’ve purged the object cache several times (did it again just now). Also disabled all plugins, and the error remains. As you noted, I do see that particular code looks like it only runs when object caching is enabled, and this is likely the first time I’ve ever had the plugin active on this environment.

    The error indicates that $this->_tracker is a string rather than an array, and that property comes from the photocrati_cache_tracker option. I checked that option, and it’s just set to “garbage”:
    AA A A
    (with spaces and all)

    I emptied it to see if Nextgen would fix it, but it still throws the error on an empty value, even with an object cache purge.

    Benjamin

    (@benjaminowens)

    That’s unusual; can you show me what debug_backtrace() added after line 137 results in; and what $key and $value are?

    The next NGG release will include a check for the previously mentioned constant in the _track_key() method which will fix the problem, but if possible I’d like to resolve the root issue too.

    Thanks!

    Thread Starter nosilver4u

    (@nosilver4u)

    Here’s what I got: https://pastebin.com/xsZ81ADm

    That was supposed to be in the set() method, right?

    In the _track_key() method, where the fatal error occurs, $this->_tracker is an empty string. Thus $this->_tracker[$group] is treated as a string offset, and when one tries to use it as an array via the [] assignment on this line, that’s where the error happens:
    $this->_tracker[$group][] = $id;

    Benjamin

    (@benjaminowens)

    Thanks @nosilver4u

    I’ll have that fixed in the next NGG release; in the meanwhile just commenting out the code inside of the _track_key() method should allow your site to continue working until then.

    Thread Starter nosilver4u

    (@nosilver4u)

    Great, thanks! I’ll be doing an EWWW IO release next week so I’ll watch for the NGG update and/or disable that code while I’m running through our compatibility testing.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘fatal error on PHP 8’ is closed to new replies.