From cf014dc56d38868fda09e1466845aa8c8a3439f4 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 27 Mar 2012 22:54:13 +1300 Subject: [PATCH] MINOR Replaced use of deprecated split() with preg_split() and fixed use of "&new Class()" which is deprecated in PHP 5.3 ENHANCEMENT E_DEPRECATED and E_USER_DEPRECATED are now handled as notice level errors in Debug. --- admin/code/CMSBatchActionHandler.php | 8 ++++---- core/Core.php | 2 +- core/Diff.php | 2 +- dev/Debug.php | 1 + dev/DebugView.php | 4 ++++ thirdparty/simpletest/form.php | 6 +++--- thirdparty/simpletest/http.php | 14 +++++++------- thirdparty/simpletest/page.php | 10 +++++----- thirdparty/simpletest/parser.php | 6 +++--- thirdparty/simpletest/url.php | 8 ++++---- 10 files changed, 33 insertions(+), 28 deletions(-) diff --git a/admin/code/CMSBatchActionHandler.php b/admin/code/CMSBatchActionHandler.php index f45533ba9..4bc6c4f3b 100644 --- a/admin/code/CMSBatchActionHandler.php +++ b/admin/code/CMSBatchActionHandler.php @@ -81,7 +81,7 @@ class CMSBatchActionHandler extends RequestHandler { $actionHandler = new $actionClass(); // Sanitise ID list and query the database for apges - $ids = split(' *, *', trim($request->requestVar('csvIDs'))); + $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs'))); foreach($ids as $k => $v) if(!is_numeric($v)) unset($ids[$k]); if($ids) { @@ -135,7 +135,7 @@ class CMSBatchActionHandler extends RequestHandler { $actionHandler = new $actionClass['class'](); // Sanitise ID list and query the database for apges - $ids = split(' *, *', trim($request->requestVar('csvIDs'))); + $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs'))); foreach($ids as $k => $id) $ids[$k] = (int)$id; $ids = array_filter($ids); @@ -157,7 +157,7 @@ class CMSBatchActionHandler extends RequestHandler { $actionHandler = new $actionClass(); // Sanitise ID list and query the database for apges - $ids = split(' *, *', trim($request->requestVar('csvIDs'))); + $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs'))); foreach($ids as $k => $id) $ids[$k] = (int)$id; $ids = array_filter($ids); @@ -211,4 +211,4 @@ class CMSBatchActionHandler extends RequestHandler { return $actions; } -} \ No newline at end of file +} diff --git a/core/Core.php b/core/Core.php index 04f8fdf1f..622655494 100644 --- a/core/Core.php +++ b/core/Core.php @@ -38,7 +38,7 @@ /////////////////////////////////////////////////////////////////////////////// // ENVIRONMENT CONFIG -if(defined('E_DEPRECATED')) error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT)); +if(defined('E_DEPRECATED')) error_reporting(E_ALL & ~(E_STRICT)); else error_reporting(E_ALL); /** diff --git a/core/Diff.php b/core/Diff.php index f59da6705..8623f8b14 100644 --- a/core/Diff.php +++ b/core/Diff.php @@ -800,7 +800,7 @@ class Diff if(is_array($content)) $content = implode(',', $content); $content = str_replace(array(" ","<", ">"),array(" "," <", "> "),$content); - $candidateChunks = split("[\t\r\n ]+", $content); + $candidateChunks = preg_split("/[\t\r\n ]+/", $content); while(list($i,$item) = each($candidateChunks)) { if(isset($item[0]) && $item[0] == "<") { $newChunk = $item; diff --git a/dev/Debug.php b/dev/Debug.php index b2d51b9a8..847b3bedd 100644 --- a/dev/Debug.php +++ b/dev/Debug.php @@ -697,6 +697,7 @@ function errorHandler($errno, $errstr, $errfile, $errline) { case E_NOTICE: case E_USER_NOTICE: + case E_DEPRECATED: case E_USER_DEPRECATED: Debug::noticeHandler($errno, $errstr, $errfile, $errline, null); break; diff --git a/dev/DebugView.php b/dev/DebugView.php index c6fa60b26..d29d9987a 100644 --- a/dev/DebugView.php +++ b/dev/DebugView.php @@ -30,6 +30,10 @@ class DebugView extends Object { 'title' => 'User Notice', 'class' => 'notice' ), + E_DEPRECATED => array( + 'title' => 'Deprecation', + 'class' => 'notice' + ), E_USER_DEPRECATED => array( 'title' => 'Deprecation', 'class' => 'notice' diff --git a/thirdparty/simpletest/form.php b/thirdparty/simpletest/form.php index cbef6636d..b359552f4 100644 --- a/thirdparty/simpletest/form.php +++ b/thirdparty/simpletest/form.php @@ -172,7 +172,7 @@ class SimpleForm { */ function _addRadioButton(&$tag) { if (! isset($this->_radios[$tag->getName()])) { - $this->_widgets[] = &new SimpleRadioGroup(); + $this->_widgets[] = new SimpleRadioGroup(); $this->_radios[$tag->getName()] = count($this->_widgets) - 1; } $this->_widgets[$this->_radios[$tag->getName()]]->addWidget($tag); @@ -191,7 +191,7 @@ class SimpleForm { $index = $this->_checkboxes[$tag->getName()]; if (! SimpleTestCompatibility::isA($this->_widgets[$index], 'SimpleCheckboxGroup')) { $previous = &$this->_widgets[$index]; - $this->_widgets[$index] = &new SimpleCheckboxGroup(); + $this->_widgets[$index] = new SimpleCheckboxGroup(); $this->_widgets[$index]->addWidget($previous); } $this->_widgets[$index]->addWidget($tag); @@ -352,4 +352,4 @@ class SimpleForm { return $this->_encode(); } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/http.php b/thirdparty/simpletest/http.php index e6c6e89da..176d9fccd 100644 --- a/thirdparty/simpletest/http.php +++ b/thirdparty/simpletest/http.php @@ -98,9 +98,9 @@ class SimpleRoute { */ function &_createSocket($scheme, $host, $port, $timeout) { if (in_array($scheme, array('https'))) { - $socket = &new SimpleSecureSocket($host, $port, $timeout); + $socket = new SimpleSecureSocket($host, $port, $timeout); } else { - $socket = &new SimpleSocket($host, $port, $timeout); + $socket = new SimpleSocket($host, $port, $timeout); } return $socket; } @@ -279,7 +279,7 @@ class SimpleHttpRequest { * @access protected */ function &_createResponse(&$socket) { - $response = &new SimpleHttpResponse( + $response = new SimpleHttpResponse( $socket, $this->_route->getUrl(), $this->_encoding); @@ -516,13 +516,13 @@ class SimpleHttpResponse extends SimpleStickyError { function _parse($raw) { if (! $raw) { $this->_setError('Nothing fetched'); - $this->_headers = &new SimpleHttpHeaders(''); + $this->_headers = new SimpleHttpHeaders(''); } elseif (! strstr($raw, "\r\n\r\n")) { $this->_setError('Could not split headers from content'); - $this->_headers = &new SimpleHttpHeaders($raw); + $this->_headers = new SimpleHttpHeaders($raw); } else { list($headers, $this->_content) = split("\r\n\r\n", $raw, 2); - $this->_headers = &new SimpleHttpHeaders($headers); + $this->_headers = new SimpleHttpHeaders($headers); } } @@ -621,4 +621,4 @@ class SimpleHttpResponse extends SimpleStickyError { return ! $packet; } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/page.php b/thirdparty/simpletest/page.php index 08e5649dc..6c037626c 100644 --- a/thirdparty/simpletest/page.php +++ b/thirdparty/simpletest/page.php @@ -163,7 +163,7 @@ class SimplePageBuilder extends SimpleSaxListener { * @access protected */ function &_createPage($response) { - $page = &new SimplePage($response); + $page = new SimplePage($response); return $page; } @@ -175,7 +175,7 @@ class SimplePageBuilder extends SimpleSaxListener { * @access protected */ function &_createParser(&$listener) { - $parser = &new SimpleHtmlSaxParser($listener); + $parser = new SimpleHtmlSaxParser($listener); return $parser; } @@ -188,7 +188,7 @@ class SimplePageBuilder extends SimpleSaxListener { * @access public */ function startElement($name, $attributes) { - $factory = &new SimpleTagBuilder(); + $factory = new SimpleTagBuilder(); $tag = $factory->createTag($name, $attributes); if (! $tag) { return true; @@ -641,7 +641,7 @@ class SimplePage { * @access public */ function acceptFormStart(&$tag) { - $this->_open_forms[] = &new SimpleForm($tag, $this); + $this->_open_forms[] = new SimpleForm($tag, $this); } /** @@ -980,4 +980,4 @@ class SimplePage { return null; } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/parser.php b/thirdparty/simpletest/parser.php index 3f3b37b83..93f8cf980 100644 --- a/thirdparty/simpletest/parser.php +++ b/thirdparty/simpletest/parser.php @@ -197,7 +197,7 @@ class SimpleLexer { $this->_case = $case; $this->_regexes = array(); $this->_parser = &$parser; - $this->_mode = &new SimpleStateStack($start); + $this->_mode = new SimpleStateStack($start); $this->_mode_handlers = array($start => $start); } @@ -579,7 +579,7 @@ class SimpleHtmlSaxParser { * @static */ function &createLexer(&$parser) { - $lexer = &new SimpleHtmlLexer($parser); + $lexer = new SimpleHtmlLexer($parser); return $lexer; } @@ -761,4 +761,4 @@ class SimpleSaxListener { function addContent($text) { } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/url.php b/thirdparty/simpletest/url.php index 0ea220409..d3461657a 100644 --- a/thirdparty/simpletest/url.php +++ b/thirdparty/simpletest/url.php @@ -106,7 +106,7 @@ class SimpleUrl { } if (preg_match('/^([^\/]*)@(.*)/', $url, $matches)) { $url = $prefix . $matches[2]; - $parts = split(":", $matches[1]); + $parts = preg_split('/:/', $matches[1]); return array( urldecode($parts[0]), isset($parts[1]) ? urldecode($parts[1]) : false); @@ -184,7 +184,7 @@ class SimpleUrl { function _parseRequest($raw) { $this->_raw = $raw; $request = new SimpleGetEncoding(); - foreach (split("&", $raw) as $pair) { + foreach (preg_split('/&/', $raw) as $pair) { if (preg_match('/(.*?)=(.*)/', $pair, $matches)) { $request->add($matches[1], urldecode($matches[2])); } elseif ($pair) { @@ -379,7 +379,7 @@ class SimpleUrl { */ function clearRequest() { $this->_raw = false; - $this->_request = &new SimpleGetEncoding(); + $this->_request = new SimpleGetEncoding(); } /** @@ -525,4 +525,4 @@ class SimpleUrl { return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum'; } } -?> \ No newline at end of file +?>