Skip to content

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

@eduardoarandah

Description

@eduardoarandah

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);

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions