Open bobbingwide opened 4 years ago
Gutenberg assumes that global $post is set. When run in PhpUnit tests and other batch routines this is not necessarily the case.
C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php(279:2) bw_trace_error_handler(1) 784 8 2020-06-23T09:42:44+00:00 2.346656 0.000754 cf=the_content,pre_render_block 35690 326 0 73400320/73400320 256M F=1423 err Array ( [0] => 8 [1] => Notice: Trying to get property 'ID' of non-object [2] => C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg\lib\compat.php [3] => 262 )
Change gutenberg_render_block_with_assigned_block_context()
to set only set values of $context which are available.
$context = [];
if ( $post ) {
$context['postId'] = $post->ID;
/*
* The `postType` context is largely unnecessary server-side, since the
* ID is usually sufficient on its own. That being said, since a block's
* manifest is expected to be shared between the server and the client,
* it should be included to consistently fulfill the expectation.
*/
$context['postType'] = $post->post_type;
}
$context['query'] = array('categoryIds' => array());
For some time now I've been ignoring a load of notices issued while running oik-batch. Now they've prevented my PhpUnit tests for oik from running.
Raising here since I've got to pick somewhere. Extract from output from PhpUnit for oik,