Skip to content

Commit

Permalink
MINOR Replaced use of deprecated split() with preg_split() and fixed …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
halkyon committed Mar 27, 2012
1 parent a4b668d commit cf014dc
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 28 deletions.
8 changes: 4 additions & 4 deletions admin/code/CMSBatchActionHandler.php
Expand Up @@ -81,7 +81,7 @@ function handleAction($request) {
$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) {
Expand Down Expand Up @@ -135,7 +135,7 @@ function handleApplicablePages($request) {
$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);

Expand All @@ -157,7 +157,7 @@ function handleConfirmation($request) {
$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);

Expand Down Expand Up @@ -211,4 +211,4 @@ function batchActions() {
return $actions;
}

}
}
2 changes: 1 addition & 1 deletion core/Core.php
Expand Up @@ -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);

/**
Expand Down
2 changes: 1 addition & 1 deletion core/Diff.php
Expand Up @@ -800,7 +800,7 @@ static function getHTMLChunks($content) {
if(is_array($content)) $content = implode(',', $content);

$content = str_replace(array("&nbsp;","<", ">"),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;
Expand Down
1 change: 1 addition & 0 deletions dev/Debug.php
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions dev/DebugView.php
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions thirdparty/simpletest/form.php
Expand Up @@ -172,7 +172,7 @@ function _setWidget(&$tag) {
*/
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);
Expand All @@ -191,7 +191,7 @@ function _addCheckbox(&$tag) {
$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);
Expand Down Expand Up @@ -352,4 +352,4 @@ function submit() {
return $this->_encode();
}
}
?>
?>
14 changes: 7 additions & 7 deletions thirdparty/simpletest/http.php
Expand Up @@ -98,9 +98,9 @@ function &createConnection($method, $timeout) {
*/
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;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ function readCookiesFromJar($jar, $url) {
* @access protected
*/
function &_createResponse(&$socket) {
$response = &new SimpleHttpResponse(
$response = new SimpleHttpResponse(
$socket,
$this->_route->getUrl(),
$this->_encoding);
Expand Down Expand Up @@ -516,13 +516,13 @@ function SimpleHttpResponse(&$socket, $url, $encoding) {
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);
}
}

Expand Down Expand Up @@ -621,4 +621,4 @@ function _isLastPacket($packet) {
return ! $packet;
}
}
?>
?>
10 changes: 5 additions & 5 deletions thirdparty/simpletest/page.php
Expand Up @@ -163,7 +163,7 @@ function &parse($response) {
* @access protected
*/
function &_createPage($response) {
$page = &new SimplePage($response);
$page = new SimplePage($response);
return $page;
}

Expand All @@ -175,7 +175,7 @@ function &_createPage($response) {
* @access protected
*/
function &_createParser(&$listener) {
$parser = &new SimpleHtmlSaxParser($listener);
$parser = new SimpleHtmlSaxParser($listener);
return $parser;
}

Expand All @@ -188,7 +188,7 @@ function &_createParser(&$listener) {
* @access public
*/
function startElement($name, $attributes) {
$factory = &new SimpleTagBuilder();
$factory = new SimpleTagBuilder();
$tag = $factory->createTag($name, $attributes);
if (! $tag) {
return true;
Expand Down Expand Up @@ -641,7 +641,7 @@ function _isFormElement($name) {
* @access public
*/
function acceptFormStart(&$tag) {
$this->_open_forms[] = &new SimpleForm($tag, $this);
$this->_open_forms[] = new SimpleForm($tag, $this);
}

/**
Expand Down Expand Up @@ -980,4 +980,4 @@ function getField($selector) {
return null;
}
}
?>
?>
6 changes: 3 additions & 3 deletions thirdparty/simpletest/parser.php
Expand Up @@ -197,7 +197,7 @@ function SimpleLexer(&$parser, $start = "accept", $case = false) {
$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);
}

Expand Down Expand Up @@ -579,7 +579,7 @@ function parse($raw) {
* @static
*/
function &createLexer(&$parser) {
$lexer = &new SimpleHtmlLexer($parser);
$lexer = new SimpleHtmlLexer($parser);
return $lexer;
}

Expand Down Expand Up @@ -761,4 +761,4 @@ function endElement($name) {
function addContent($text) {
}
}
?>
?>
8 changes: 4 additions & 4 deletions thirdparty/simpletest/url.php
Expand Up @@ -106,7 +106,7 @@ function _chompLogin(&$url) {
}
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);
Expand Down Expand Up @@ -184,7 +184,7 @@ function _chompRequest(&$url) {
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) {
Expand Down Expand Up @@ -379,7 +379,7 @@ function addRequestParameters($parameters) {
*/
function clearRequest() {
$this->_raw = false;
$this->_request = &new SimpleGetEncoding();
$this->_request = new SimpleGetEncoding();
}

/**
Expand Down Expand Up @@ -525,4 +525,4 @@ function getAllTopLevelDomains() {
return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum';
}
}
?>
?>

0 comments on commit cf014dc

Please sign in to comment.