Skip to content

Commit

Permalink
Merge pull request #161 from NeilWJames/master
Browse files Browse the repository at this point in the history
Version 3.2.2 gives an "property of non-object" at line 1403 on load
  • Loading branch information
benbalter committed Apr 26, 2019
2 parents 24c4639 + 862146f commit d0436c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions includes/class-wp-document-revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1400,8 +1400,8 @@ public function verify_post_type( $documentish = false ) {
}

// Assume that a document feed is a document feed, even without a post object.
if ( is_array( $wp_query->query_vars ) && ( array_key_exists( 'post_type', $wp_query->query_vars ) ) &&
'document' === $wp_query->query_vars['post_type'] && is_feed() ) {
if ( isset( $wp_query->query_vars ) && is_array( $wp_query->query_vars ) &&
( array_key_exists( 'post_type', $wp_query->query_vars ) ) && 'document' === $wp_query->query_vars['post_type'] && is_feed() ) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function _make_user( $role = 'administrator', $user_login = '', $pass = '', $ema
'user_email' => ( $email ) ? $email : rand_str() . '@example.com',
);

$user_id = wp_insert_user( $user );
$user_id = wp_insert_user( $user );

return $user_id;

Expand Down
3 changes: 3 additions & 0 deletions tests/class-test-wp-document-revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,17 @@ public function test_verify_post_type() {

$_GET['post_type'] = 'document';
$this->assertTrue( $wpdr->verify_post_type(), 'verify post type via explicit' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_GET['post_type'] );

$_GET['post'] = $doc_id;
$this->assertTrue( $wpdr->verify_post_type(), 'verify post type via get' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_GET['post'] );

$_REQUEST['post_id'] = $doc_id;
$this->assertTrue( $wpdr->verify_post_type(), 'verify post type via request (post_id)' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_REQUEST['post_id'] );

// @codingStandardsIgnoreStart WordPress.Variables.GlobalVariables.OverrideProhibited
Expand Down

0 comments on commit d0436c1

Please sign in to comment.