plausible / wordpress

Plausible Analytics WordPress plugin
https://plausible.io/wordpress-analytics-plugin
MIT License
52 stars 28 forks source link

Warning: Attempt to read property "post_name" on null #120

Closed aanndryyyy closed 1 year ago

aanndryyyy commented 1 year ago

Got Warning: Attempt to read property "post_name" on null reported when custom theme opened 404.php template at plugins/plausible-analytics/src/Includes/Actions.php on Plausible WP plugin version 1.2.6.

Line 103: https://github.com/plausible/wordpress/blob/0cdaadd0993b06e748918dd6989eca3fc1d45864/src/Includes/Actions.php#L97-L106

404.php contents:

<?php
/**
 * 404 template.
 */

declare(strict_types=1);

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

\get_header();
?>

<main><!-- Some HTML --></main>

<?php
\get_footer();

Link in HTML when logged in:

image

Sentry report:

image
Dan0sz commented 1 year ago

Thanks for the comprehensive bug report! A fix for this was already merged to develop in https://github.com/plausible/wordpress/pull/90 so it'll be fixed in the next release!