OddOneOut / bwp-google-xml-sitemaps

WordPress plugin that helps generate XML Sitemaps for your website/blog.
http://betterwp.net/wordpress-plugins/google-xml-sitemaps/
19 stars 11 forks source link

Doesn't check for message_logger to exist before logging #45

Open eduardoarandah opened 7 years ago

eduardoarandah commented 7 years ago

Got this fatal error:

[15-Feb-2017 14:12:52 UTC] PHP Fatal error:  Uncaught Error: Call to a member function log() on null in PATH_HERE/plugins/bwp-google-xml-sitemaps/src/class-bwp-gxs.php:2545
Stack trace:
#0 PATH_HERE/plugins/bwp-google-xml-sitemaps/src/class-bwp-gxs.php(2573): BWP_Sitemaps->_log_message_item('Pinged <em>Goog...', 'success')
#1 PATH_HERE/plugins/bwp-google-xml-sitemaps/src/class-bwp-gxs.php(2603): BWP_Sitemaps->log_message('Pinged <em>Goog...', 'success')
#2 PATH_HERE/plugins/bwp-google-xml-sitemaps/src/class-bwp-gxs.php(3961): BWP_Sitemaps->log_success('Pinged <em>Goog...')
#3 /srv/users/serverpilot/apps/veracruzanos/public/wp-includes/class-wp-hook.php(298): BWP_Sitemaps->ping(Object(WP_Post))
#4 /srv/users/serverpilot/apps/veracruzanos/public/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array)
#5 /srv/users/serverpilot/apps/veracruzanos/publi in PATH_HERE/plugins/bwp-google-xml-sitemaps/src/class-bwp-gxs.php on line 2545

In function _log_message_item there's a call to an object before checking it exists:

$this->message_logger->log($item);

maybe this could prevent the error? (I haven't tested)

if(isset($this->message_logger))
    $this->message_logger->log($item);
kminh commented 7 years ago

Resolves also:

https://wordpress.org/support/topic/lots-of-php-error/