From 2a3ad9664b26f66cdcea20e217a45ccbab147daf Mon Sep 17 00:00:00 2001 From: Matt Roberts Date: Fri, 2 Feb 2018 10:14:39 -0800 Subject: [PATCH 1/2] Refactors error logging code. The plugin previosuly relied on `mysql_error` which was deprecated in 5.5 and completely removed in 7 in favor of the MySQL Improved extension. Regardless, WordPress provides a method of retrieving the last MySQL error that is interface agnostic, `$wpdb->last_error`. By using this functionality, the plugin no longer needs to be concerned with implementation details instead delegating that responsibility to WordPress Core. --- wp2syslog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp2syslog.php b/wp2syslog.php index 0dd0511..6414793 100644 --- a/wp2syslog.php +++ b/wp2syslog.php @@ -85,7 +85,7 @@ function init() { update_option('wp2syslog_version_num', WP2SYSLOG_VERSION_NUM); } - + //Force a config state and init() again .. $this->set_init_status('config'); $this->init(); @@ -94,7 +94,7 @@ function init() $check_options=$this->settings->get_options(); if($this->init_status=='config' && $check_options['db']=='true' ) - { + { //OK, let's go to create or upgrade wp2syslog table $this->wp2syslog('wp2syslog', __('wp2syslog is going to create table ..', 'wp2syslog'), 2); @@ -239,7 +239,7 @@ function wp2syslog($module, $message, $severity=1, $cut=500, $userid=0, $time=0) if ( false === $result) { - syslog(LOG_WARNING, "$block_header $severityname: MYSQLERROR ".mysql_error()); + syslog(LOG_WARNING, "$block_header $severityname: MYSQLERROR ".$wpdb->last_error); return false; } } From 0d5b5592ad757d4f8f53d7688d7704ddc19632cb Mon Sep 17 00:00:00 2001 From: Matt Roberts Date: Fri, 2 Feb 2018 10:19:33 -0800 Subject: [PATCH 2/2] Increments patch number and updates readme. --- readme.txt | 9 ++++++--- wp2syslog.php | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/readme.txt b/readme.txt index f87f2e8..6784480 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ === wp2syslog === Contributors: psicosi448 -Donate link: +Donate link: Tags: logging,events,actions,syslog Requires at least: 3.3 Tested up to: 4.2 @@ -12,13 +12,13 @@ wp2syslog -- Global logging facility for WordPress (WPsyslog revisited) == Description == -**End users can benefit from wp2syslog:** +**End users can benefit from wp2syslog:** * Log entries for core events help to keep track of the daily business, especially on multiuser blogs. * Log entries for core events can raise awareness for threats and problems, for example abuse attempts. * Log entries triggered by plugins allow the user to comprehend the functionality of the plugin. -**Developers can benefit in two ways from wp2syslog:** +**Developers can benefit in two ways from wp2syslog:** * At each point of the code, a log entry can be triggered. No need to print to the browser, just let wp2syslog put it in the database, and you can have a look later. * You can develop your plugins with support for wp2syslog. This will give your users the chance to better understand what your plugin is doing (see doc/specs.html). @@ -40,6 +40,9 @@ wp2syslog -- Global logging facility for WordPress (WPsyslog revisited) == Changelog == += 1.0.5 - +* fix: removed mysql_error call in favor of $wpdb->last_error + = 1.0.4 = * fix: load css only in showlog page diff --git a/wp2syslog.php b/wp2syslog.php index 6414793..363431f 100644 --- a/wp2syslog.php +++ b/wp2syslog.php @@ -4,7 +4,7 @@ Plugin URI: https://github.com/kataweb/wp2syslog Description: It keeps track of wordpress's events and log them to syslog. Author: psicosi448 - Version: 1.0.4 + Version: 1.0.5 Author URI: http://www.kataweb.it */ @@ -24,7 +24,7 @@ if (!defined('WP2SYSLOG_PLUGIN_DIR')) define('WP2SYSLOG_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . WP2SYSLOG_PLUGIN_NAME); if (!defined('WP2SYSLOG_VERSION_NUM')) -define('WP2SYSLOG_VERSION_NUM', '1.0.4'); +define('WP2SYSLOG_VERSION_NUM', '1.0.5'); require_once(WP2SYSLOG_PLUGIN_DIR.'/wp2syslog_settings.php'); require_once(WP2SYSLOG_PLUGIN_DIR.'/wp2syslog_showlog.php');