[emt] r224 committed - This fixes functions that have been deprecated in php 5.3. Instead of ...

5 views
Skip to first unread message

e...@googlecode.com

unread,
Jan 12, 2012, 6:32:22 PM1/12/12
to emt...@googlegroups.com
Revision: 224
Author: eric.bergen
Date: Thu Jan 12 15:31:08 2012
Log: This fixes functions that have been deprecated in php 5.3.
Instead of calling split call preg_split. There was an useless call to
define syslog variables. At some point php introduced an internal class
called sqlite3 which conflicts with the output handler so this has been
renamed to sqlite3_io. If you're using the sqlite3 handler you need to
change your config to reference sqlite3_io instead of sqlite3. The patch
was contributed by Kyle Wayman - kwa...@gmail.com. Thanks Kyle!

http://code.google.com/p/emt/source/detail?r=224

Modified:
/trunk/base/compact_field.php
/trunk/base/config_file.php
/trunk/base/field.php
/trunk/base/io_base.php
/trunk/base/log.php
/trunk/base/view.php
/trunk/bin/emt_nsca
/trunk/plugins/commands/proc_net.php
/trunk/plugins/output/sqlite3.php
/trunk/test/etc/emt.cnf
/trunk/test/etc/emt_sqlite_input.cnf

=======================================
--- /trunk/base/compact_field.php Fri Feb 11 09:39:21 2011
+++ /trunk/base/compact_field.php Thu Jan 12 15:31:08 2012
@@ -62,7 +62,7 @@
function parse_simple_field() {
$this->multi_value = FALSE;

- list ($key, $value) = split('=', $this->field_str);
+ list ($key, $value) = preg_split('/=/', $this->field_str);
$name = urldecode($key) . '_field';
$this->value = urldecode($value);

@@ -87,10 +87,10 @@
$f = new $name;
//print_r($this);

- $sub_csv = split(',', $sub_csv);
+ $sub_csv = preg_split('/,/', $sub_csv);

foreach ($sub_csv as $kv) {
- list($key, $value) = split('=', $kv);
+ list($key, $value) = preg_split('/=/', $kv);
$this->values[urldecode($key)] = urldecode($value);
}

@@ -99,7 +99,7 @@

function parse_off_instance_name() {
if (strstr($this->field_str, ':')) {
- list ($this->instance_name, $trash) = split(':',
$this->field_str);
+ list ($this->instance_name, $trash) = preg_split('/:/',
$this->field_str);
$this->field_str = str_replace($this->instance_name . ':', '',
$this->field_str);

return TRUE;
=======================================
--- /trunk/base/config_file.php Fri Feb 11 09:39:21 2011
+++ /trunk/base/config_file.php Thu Jan 12 15:31:08 2012
@@ -74,7 +74,7 @@
//The heading supports multiple instances. Colon denotes a
instance identifier
if (strstr($cur_heading, ':'))
{
- list($module_name, $instance_name) = split(':',
$cur_heading);
+ list($module_name, $instance_name) = preg_split('/:/',
$cur_heading);

if (isset($module_instances[$module_name]) &&
in_array($instance_name, $module_instances[$module_name]))
log_error_and_exit("Duplicate heading $cur_heading.
Instance $instance_name of module $module_name already exists");
=======================================
--- /trunk/base/field.php Thu Jun 17 14:00:27 2010
+++ /trunk/base/field.php Thu Jan 12 15:31:08 2012
@@ -138,11 +138,11 @@

foreach ($fields as $field)
{
- list($key, $value) = split('=', $field);
+ list($key, $value) = preg_split('/=/', $field);

if (strstr($key, '.'))
{
- list($name, $sub_name) = split('\.', $key);
+ list($name, $sub_name) = preg_split('/\./', $key);

if ($name == $this->name)
{
=======================================
--- /trunk/base/io_base.php Thu Jun 17 14:00:27 2010
+++ /trunk/base/io_base.php Thu Jan 12 15:31:08 2012
@@ -88,20 +88,20 @@
if (!strlen($kv))
continue;

- list ($key, $value) = split('=', $kv);
+ list ($key, $value) = preg_split('/=/', $kv);

//remove the instance from the key name
$instance = '';

if (strstr($key, ':'))
{
- list ($instance, $key) = split(':', $key);
+ list ($instance, $key) = preg_split('/:/', $key);
}

//separate the field name from the sub field name
$sub_name = '';
if (strstr($key, '.'))
- list ($key, $sub_name) = split('\.', $key);
+ list ($key, $sub_name) = preg_split('/\./', $key);

$f_name = $key . '_field';
/**
=======================================
--- /trunk/base/log.php Tue Jul 21 22:53:53 2009
+++ /trunk/base/log.php Thu Jan 12 15:31:08 2012
@@ -19,8 +19,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*

***************************************************************************/

-define_syslog_variables();
-
$log_mask = LOG_PID | LOG_PERROR;

openlog("emt", $log_mask, LOG_LOCAL0);
=======================================
--- /trunk/base/view.php Fri Jun 25 15:47:47 2010
+++ /trunk/base/view.php Thu Jan 12 15:31:08 2012
@@ -398,13 +398,13 @@
{
if (strstr($str, ':'))
{
- list ($instance) = split(':', $str);
+ list ($instance) = preg_split('/:/', $str);
$str = preg_replace('/.*:/', '', $str);
}

if (strstr($str, "."))
{
- list ($field, $sub_field) = split('\.', $str);
+ list ($field, $sub_field) = preg_split('/\./', $str);


if (in_array($field, $this->fields) === FALSE)
=======================================
--- /trunk/bin/emt_nsca Wed Feb 25 14:55:04 2009
+++ /trunk/bin/emt_nsca Thu Jan 12 15:31:08 2012
@@ -38,7 +38,7 @@

foreach (preg_split('/,/', $line) as $field)
{
- list ($name, $value) = split('=', $field);
+ list ($name, $value) = preg_split('/=/', $field);
if ($name == $FIELD->name)
{
if (!$FIELD->is_value_valid($value))
=======================================
--- /trunk/plugins/commands/proc_net.php Sun Jun 13 17:29:04 2010
+++ /trunk/plugins/commands/proc_net.php Thu Jan 12 15:31:08 2012
@@ -38,11 +38,11 @@
if (!strstr($field, '='))
continue;

- list($key, $value) = split('=', $field);
+ list($key, $value) = preg_split('/=/', $field);

if (strstr($key, '.'))
{
- list($name, $sub_name) = split('\.', $key);
+ list($name, $sub_name) = preg_split('/\./', $key);

if ($name == $this->name)
{
=======================================
--- /trunk/plugins/output/sqlite3.php Mon Jan 9 20:25:09 2012
+++ /trunk/plugins/output/sqlite3.php Thu Jan 12 15:31:08 2012
@@ -19,11 +19,11 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *

***************************************************************************/

-register_io_handler('sqlite3');
+register_io_handler('sqlite3_io');

require_once(INSTALL_PATH . '/base/compact_field.php');

-class sqlite3 extends emt_io
+class sqlite3_io extends emt_io
{
var $dbh;
var $stmt;
@@ -37,7 +37,7 @@
function open()
{
if (!isset($this->config['data_file']))
- log_error_and_exit("sqlite output handler needs a data_file
specified under [sqlite3] in emt.cnf");
+ log_error_and_exit("sqlite output handler needs a data_file
specified under [sqlite3_io] in emt.cnf");

if (!($this->dbh = new PDO('sqlite:' .
$this->config['data_file'])))
log_error_and_exit('sqlite output handler cannot open data
file, error (' . $this->dbh->errorInfo());
=======================================
--- /trunk/test/etc/emt.cnf Mon Jan 9 20:49:04 2012
+++ /trunk/test/etc/emt.cnf Thu Jan 12 15:31:08 2012
@@ -7,7 +7,7 @@
field=test_multiple
#field=time_me_out
output_handler=local_text
-output_handler=sqlite3
+output_handler=sqlite3_io
instances = 2

[test_command:inst_one]
@@ -19,7 +19,7 @@
[local_text]
output_file=./run/gather

-[sqlite3]
+[sqlite3_io]
data_file=./tmp/sqlite3.dat

[emt_view]
=======================================
--- /trunk/test/etc/emt_sqlite_input.cnf Mon Jan 9 20:49:04 2012
+++ /trunk/test/etc/emt_sqlite_input.cnf Thu Jan 12 15:31:08 2012
@@ -1,7 +1,7 @@
[emt_view]
default_view = default
output_records = 100
-input_handler=sqlite3
-
-[sqlite3]
+input_handler=sqlite3_io
+
+[sqlite3_io]
data_file=./tmp/sqlite3.dat

Reply all
Reply to author
Forward
0 new messages