Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#38307 closed defect (bug) (invalid)

WPTests | PHP7 | clone not object

Reported by: gregoireduchenews's profile gregoireduchenews Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

Hi there,

PHPUnit are failing with PHP7 with the following error:

Error: clone method called on non-object

/srv/www/wp-tests/tests/phpunit/includes/testcase.php:238
/srv/www/wp-tests/tests/phpunit/includes/testcase.php:98

Change History (5)

#1 @pento
9 years ago

  • Component changed from General to Build/Test Tools
  • Version changed from 4.6.1 to trunk

Thanks for the bug report, @gregoireduchenews!

This isn't failing in Travis, which suggests it's a plugin you have installed that's causing the failure.

In particular, it looks like it's a plugin that directly writes to the $wp_filter global, which will no longer work in WordPress 4.7.

Could you confirm if you have any plugins installed, and what they are?

#2 @gregoireduchenews
9 years ago

Hi there

I deactivated all of the plugins, removed the plugin folder, removed the mu-plugin folder, and ran only that test that does the following:

<?php
<?php

namespace NewsCorpAU\NLM\Kidspot\Tests;

class TwigTester extends \WP_UnitTestCase {

        /**
         * @test
         */
        public function assert_class_is_set_up() {
                $this->assertTrue( true );
        }
}

Same result.
I have dumped the $GLOBALSwp_filter?, below is the result.
Have I missed something?

<?php
Installing...
Installing network...
Running as multisite...
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
Not running external-oembed tests. To execute these, use --group external-oembed.
PHPUnit 5.6.1 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)array(350) {
  ["site_option_active_sitewide_plugins"]=>
  array(1) {
    [10]=>
    array(1) {
      ["xwp_filter_active_plugins_for_phpunit"]=>
      array(2) {
        ["function"]=>
        string(37) "xwp_filter_active_plugins_for_phpunit"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["option_active_plugins"]=>
  array(1) {
    [10]=>
    array(1) {
      ["xwp_filter_active_plugins_for_phpunit"]=>
      array(2) {
        ["function"]=>
        string(37) "xwp_filter_active_plugins_for_phpunit"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["muplugins_loaded"]=>
  array(1) {
    [10]=>
    array(1) {
      ["xwp_unit_test_load_plugin_file"]=>
      array(2) {
        ["function"]=>
        string(30) "xwp_unit_test_load_plugin_file"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["wp_die_handler"]=>
  array(1) {
    [10]=>
    array(1) {
      ["_wp_die_handler_filter"]=>
      array(2) {
        ["function"]=>
        string(22) "_wp_die_handler_filter"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_term_name"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_comment_author_name"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_link_name"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_link_target"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_link_rel"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_user_display_name"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_user_first_name"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_user_last_name"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["pre_user_nickname"]=>
  array(2) {
    [10]=>
    array(2) {
      ["sanitize_text_field"]=>
      array(2) {
        ["function"]=>
        string(19) "sanitize_text_field"
        ["accepted_args"]=>
        int(1)
      }
      ["wp_filter_kses"]=>
      array(2) {
        ["function"]=>
        string(14) "wp_filter_kses"
        ["accepted_args"]=>
        int(1)
      }
    }
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["term_name"]=>
  array(2) {
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
    [10]=>
    array(3) {
      ["wptexturize"]=>
      array(2) {
        ["function"]=>
        string(11) "wptexturize"
        ["accepted_args"]=>
        int(1)
      }
      ["convert_chars"]=>
      array(2) {
        ["function"]=>
        string(13) "convert_chars"
        ["accepted_args"]=>
        int(1)
      }
      ["esc_html"]=>
      array(2) {
        ["function"]=>
        string(8) "esc_html"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["comment_author_name"]=>
  array(1) {
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["link_name"]=>
  array(2) {
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
    [10]=>
    array(3) {
      ["wptexturize"]=>
      array(2) {
        ["function"]=>
        string(11) "wptexturize"
        ["accepted_args"]=>
        int(1)
      }
      ["convert_chars"]=>
      array(2) {
        ["function"]=>
        string(13) "convert_chars"
        ["accepted_args"]=>
        int(1)
      }
      ["esc_html"]=>
      array(2) {
        ["function"]=>
        string(8) "esc_html"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["link_target"]=>
  array(1) {
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["link_rel"]=>
  array(1) {
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["user_display_name"]=>
  array(1) {
    [30]=>
    array(1) {
      ["_wp_specialchars"]=>
      array(2) {
        ["function"]=>
        string(16) "_wp_specialchars"
        ["accepted_args"]=>
        int(1)
      }
    }
  }
  ["user_first_name"]=>
  array(1) {
    [30]=>
    ar 

WordPress.org: Please note that this content has been truncated for display.

#3 @pento
9 years ago

Huh, that's some interesting behaviour. $wp_filter is behaving like it's a WordPress 4.6 install, but the code in testcase.php that you're referencing is from trunk.

Is this running the WordPress Core unit tests, or the tests associated with a project? If it's the later, how are you grabbing the unit test infrastructure? If it's this script, what is your WP_VERSION environment variable set to?

#4 @gregoireduchenews
9 years ago

I am using a docker implementation of VIP Quickstart that I haven't build myself.
However, when I add

<?php
global $wp_version;
echo $wp_version;

in testcase.php

I have the following result:

ing(5) "4.6.1"

Is that any useful?

#5 @pento
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version trunk deleted

This sounds like a problem with how VIP Quickstart is keeping its WordPress and WordPress tests repos in sync.

If rebuilding your Quickstart instance doesn't help, I recommend opening a ticket on the VIP Quickstart repo, they'll be able to investigate further.

Note: See TracTickets for help on using tickets.