Support » Plugin: Collapsing Archives » Great until PHP 8

  • It works great except if you try to upgrade to PHP 8. The author uses {} to access some data elements instead of the standard []. You can fix it pretty easily but it would also be wonderful if the plugin was updated to fix this minor thing. I’d happily contribute a PR if the author had the code publicly somewhere (Github/etc.).

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’m looking for the fix but not know PHP too much, is it ok to share the changes with gist or somewhere like it?

    Thread Starter ober0330

    (@ober0330)

    I don’t remember where all the changes were. Basically anywhere you have an array using blah{x}, just switch it to blah[x]. Or just run the plugin in a PHP 8 environment, you’ll see it pretty quick.

    whusnoopy

    (@whusnoopy)

    I’ve tried to find any array using {} in wp-content/plugins/collapse-archives/

    None of them use incorrect {} which should be []

    According to the error message, it says

    2022/08/31 16:01:50 [error] 1088#1088: *266661 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, class collapsArch does not have a method "enqueue_scripts" in /home/foo/www/blog/wp-includes/class-wp-hook.php:307

    seems like it crashed because WordPress changed the way to call plugin? This plugin register in an incorrect way?

    For the “enqueue_scripts” error, @usuari0’s solution in https://wordpress.org/support/topic/an-error-occurred-11/ worked for me.

    After fixing that, I still had the issue where upgrading to PHP 8.x resulted in WordPress displaying as a completely blank page – not even any errors in the logs. Like @whusnoopy I couldn’t find any instances of arrays using blah{x} but while I was combing through all the files I did discover a typo in defaults.php where line 27 had ‘taxoncmy’. Correcting this to ‘taxonomy’ (as referred to in other files) resolved the issue and I was able to upgrade to PHP 8.1 successfully.

    Thanks to @deborahfitchett , it works after fix the typo

    There are two places need to fix

    change line 42 on /wp-content/plugins/collapsing-archives/collapsArch.php from

    if (!is_admin()) {
        wp_enqueue_script('jquery');
        add_action( 'wp_enqueue_scripts', array( 'collapsArch', 'enqueue_scripts' ) );
    } else {

    to

    if (!is_admin()) {
        wp_enqueue_script('jquery');
        add_action( 'wp_head', array( 'collapsArch', 'get_head' ) );
    } else {

    and change line 27 on /wp-content/plugins/collapsing-archives/defaults.php from

    'post_type' => 'post',
    'taxoncmy' => 'category',
    'postTitleLength' => '');

    to

    'post_type' => 'post',
    'taxonomy' => 'category',
    'postTitleLength' => '');
    • This reply was modified 3 weeks, 2 days ago by whusnoopy.
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this review.