mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Rewrote usages of error suppression operator
This commit is contained in:
parent
1cc366fe23
commit
0cbad41d3b
@ -245,7 +245,7 @@ class Director implements TemplateGlobalProvider {
|
|||||||
Requirements::set_backend(new Requirements_Backend());
|
Requirements::set_backend(new Requirements_Backend());
|
||||||
|
|
||||||
// Handle absolute URLs
|
// Handle absolute URLs
|
||||||
if (@parse_url($url, PHP_URL_HOST) != '') {
|
if (parse_url($url, PHP_URL_HOST)) {
|
||||||
$bits = parse_url($url);
|
$bits = parse_url($url);
|
||||||
// If a port is mentioned in the absolute URL, be sure to add that into the
|
// If a port is mentioned in the absolute URL, be sure to add that into the
|
||||||
// HTTP host
|
// HTTP host
|
||||||
|
@ -401,7 +401,12 @@ class Debug {
|
|||||||
$reporter = self::create_debug_view();
|
$reporter = self::create_debug_view();
|
||||||
|
|
||||||
// Coupling alert: This relies on knowledge of how the director gets its URL, it could be improved.
|
// Coupling alert: This relies on knowledge of how the director gets its URL, it could be improved.
|
||||||
$httpRequest = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : @$_REQUEST['url'];
|
$httpRequest = null;
|
||||||
|
if(isset($_SERVER['REQUEST_URI'])) {
|
||||||
|
$httpRequest = $_SERVER['REQUEST_URI'];
|
||||||
|
} elseif(isset($_REQUEST['url'])) {
|
||||||
|
$httpRequest = $_REQUEST['url'];
|
||||||
|
}
|
||||||
if(isset($_SERVER['REQUEST_METHOD'])) $httpRequest = $_SERVER['REQUEST_METHOD'] . ' ' . $httpRequest;
|
if(isset($_SERVER['REQUEST_METHOD'])) $httpRequest = $_SERVER['REQUEST_METHOD'] . ' ' . $httpRequest;
|
||||||
|
|
||||||
$reporter->writeHeader($httpRequest);
|
$reporter->writeHeader($httpRequest);
|
||||||
|
@ -167,8 +167,8 @@ class SS_Log {
|
|||||||
$message = array(
|
$message = array(
|
||||||
'errno' => '',
|
'errno' => '',
|
||||||
'errstr' => $message,
|
'errstr' => $message,
|
||||||
'errfile' => @$lastTrace['file'],
|
'errfile' => isset($lastTrace['file']) ? $lastTrace['file'] : null,
|
||||||
'errline' => @$lastTrace['line'],
|
'errline' => isset($lastTrace['line']) ? $lastTrace['line'] : null,
|
||||||
'errcontext' => $trace
|
'errcontext' => $trace
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ class SS_LogErrorEmailFormatter implements Zend_Log_Formatter_Interface {
|
|||||||
$relfile = Director::makeRelative($errfile);
|
$relfile = Director::makeRelative($errfile);
|
||||||
if($relfile && $relfile[0] == '/') $relfile = substr($relfile, 1);
|
if($relfile && $relfile[0] == '/') $relfile = substr($relfile, 1);
|
||||||
|
|
||||||
$host = @$_SERVER['HTTP_HOST'];
|
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
|
||||||
$uri = @$_SERVER['REQUEST_URI'];
|
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
|
||||||
|
|
||||||
$subject = "[$errorType] in $relfile:{$errline} (http://{$host}{$uri})";
|
$subject = "[$errorType] in $relfile:{$errline} (http://{$host}{$uri})";
|
||||||
|
|
||||||
|
@ -386,11 +386,15 @@ class InstallRequirements {
|
|||||||
*/
|
*/
|
||||||
function findWebserver() {
|
function findWebserver() {
|
||||||
// Try finding from SERVER_SIGNATURE or SERVER_SOFTWARE
|
// Try finding from SERVER_SIGNATURE or SERVER_SOFTWARE
|
||||||
$webserver = @$_SERVER['SERVER_SIGNATURE'];
|
if(!empty($_SERVER['SERVER_SIGNATURE'])) {
|
||||||
if(!$webserver) $webserver = @$_SERVER['SERVER_SOFTWARE'];
|
$webserver = $_SERVER['SERVER_SIGNATURE'];
|
||||||
|
} elseif(!empty($_SERVER['SERVER_SOFTWARE'])) {
|
||||||
|
$webserver = $_SERVER['SERVER_SOFTWARE'];
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if($webserver) return strip_tags(trim($webserver));
|
return strip_tags(trim($webserver));
|
||||||
else return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1116,7 +1120,7 @@ class InstallRequirements {
|
|||||||
$this->testing($testDetails);
|
$this->testing($testDetails);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(!@$result['cannotCreate']) {
|
if(empty($result['cannotCreate'])) {
|
||||||
$testDetails[2] .= ". Please create the database manually.";
|
$testDetails[2] .= ". Please create the database manually.";
|
||||||
} else {
|
} else {
|
||||||
$testDetails[2] .= " (user '$databaseConfig[username]' doesn't have CREATE DATABASE permissions.)";
|
$testDetails[2] .= " (user '$databaseConfig[username]' doesn't have CREATE DATABASE permissions.)";
|
||||||
@ -1194,7 +1198,7 @@ class InstallRequirements {
|
|||||||
$section = $testDetails[0];
|
$section = $testDetails[0];
|
||||||
$test = $testDetails[1];
|
$test = $testDetails[1];
|
||||||
|
|
||||||
$this->tests[$section][$test] = array("error", @$testDetails[2]);
|
$this->tests[$section][$test] = array("error", isset($testDetails[2]) ? $testDetails[2] : null);
|
||||||
$this->errors[] = $testDetails;
|
$this->errors[] = $testDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,7 +1206,7 @@ class InstallRequirements {
|
|||||||
$section = $testDetails[0];
|
$section = $testDetails[0];
|
||||||
$test = $testDetails[1];
|
$test = $testDetails[1];
|
||||||
|
|
||||||
$this->tests[$section][$test] = array("warning", @$testDetails[2]);
|
$this->tests[$section][$test] = array("warning", isset($testDetails[2]) ? $testDetails[2] : null);
|
||||||
$this->warnings[] = $testDetails;
|
$this->warnings[] = $testDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ Example `mysite/_config.php`:
|
|||||||
// Customized configuration for running with different database settings.
|
// Customized configuration for running with different database settings.
|
||||||
// Ensure this code comes after ConfigureFromEnv.php
|
// Ensure this code comes after ConfigureFromEnv.php
|
||||||
if(Director::isDev()) {
|
if(Director::isDev()) {
|
||||||
if($db = @$_GET['db']) {
|
if(isset($_GET['db']) && ($db = $_GET['db'])) {
|
||||||
global $databaseConfig;
|
global $databaseConfig;
|
||||||
if($db == 'sqlite3') $databaseConfig['type'] = 'SQLite3Database';
|
if($db == 'sqlite3') $databaseConfig['type'] = 'SQLite3Database';
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ class Form extends RequestHandler {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public function getAttribute($name) {
|
public function getAttribute($name) {
|
||||||
return @$this->attributes[$name];
|
if(isset($this->attributes[$name])) return $this->attributes[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttributes() {
|
public function getAttributes() {
|
||||||
|
@ -358,7 +358,7 @@ class FormField extends RequestHandler {
|
|||||||
*/
|
*/
|
||||||
public function getAttribute($name) {
|
public function getAttribute($name) {
|
||||||
$attrs = $this->getAttributes();
|
$attrs = $this->getAttributes();
|
||||||
return @$attrs[$name];
|
if(isset($attrs[$name])) return $attrs[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,10 +62,10 @@ class HtmlEditorSanitiser {
|
|||||||
foreach(explode(',', $validElements) as $validElement) {
|
foreach(explode(',', $validElements) as $validElement) {
|
||||||
if(preg_match($elementRuleRegExp, $validElement, $matches)) {
|
if(preg_match($elementRuleRegExp, $validElement, $matches)) {
|
||||||
|
|
||||||
$prefix = @$matches[1];
|
$prefix = isset($matches[1]) ? $matches[1] : null;
|
||||||
$elementName = @$matches[2];
|
$elementName = isset($matches[2]) ? $matches[2] : null;
|
||||||
$outputName = @$matches[3];
|
$outputName = isset($matches[3]) ? $matches[3] : null;
|
||||||
$attrData = @$matches[4];
|
$attrData = isset($matches[4]) ? $matches[4] : null;
|
||||||
|
|
||||||
// Create the new element
|
// Create the new element
|
||||||
$element = new stdClass();
|
$element = new stdClass();
|
||||||
@ -91,10 +91,10 @@ class HtmlEditorSanitiser {
|
|||||||
if(preg_match($attrRuleRegExp, $attr, $matches)) {
|
if(preg_match($attrRuleRegExp, $attr, $matches)) {
|
||||||
$attr = new stdClass();
|
$attr = new stdClass();
|
||||||
|
|
||||||
$attrType = @$matches[1];
|
$attrType = isset($matches[1]) ? $matches[1] : null;
|
||||||
$attrName = str_replace('::', ':', @$matches[2]);
|
$attrName = isset($matches[2]) ? str_replace('::', ':', $matches[2]) : null;
|
||||||
$prefix = @$matches[3];
|
$prefix = isset($matches[3]) ? $matches[3] : null;
|
||||||
$value = @$matches[4];
|
$value = isset($matches[4]) ? $matches[4] : null;
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
if($attrType === '!') {
|
if($attrType === '!') {
|
||||||
|
@ -615,7 +615,8 @@ class GridField extends FormField {
|
|||||||
public function gridFieldAlterAction($data, $form, SS_HTTPRequest $request) {
|
public function gridFieldAlterAction($data, $form, SS_HTTPRequest $request) {
|
||||||
$html = '';
|
$html = '';
|
||||||
$data = $request->requestVars();
|
$data = $request->requestVars();
|
||||||
$fieldData = @$data[$this->getName()];
|
$name = $this->getName();
|
||||||
|
$fieldData = isset($data[$name]) ? $data[$name] : null;
|
||||||
|
|
||||||
// Update state from client
|
// Update state from client
|
||||||
$state = $this->getState(false);
|
$state = $this->getState(false);
|
||||||
|
@ -211,14 +211,16 @@ abstract class SS_Database {
|
|||||||
foreach($this->schemaUpdateTransaction as $tableName => $changes) {
|
foreach($this->schemaUpdateTransaction as $tableName => $changes) {
|
||||||
switch($changes['command']) {
|
switch($changes['command']) {
|
||||||
case 'create':
|
case 'create':
|
||||||
$this->createTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['options'],
|
$this->createTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['options'],
|
||||||
@$changes['advancedOptions']);
|
isset($changes['advancedOptions']) ? $changes['advancedOptions'] : null
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'alter':
|
case 'alter':
|
||||||
$this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'],
|
$this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'],
|
||||||
$changes['alteredFields'], $changes['alteredIndexes'], $changes['alteredOptions'],
|
$changes['alteredFields'], $changes['alteredIndexes'], $changes['alteredOptions'],
|
||||||
@$changes['advancedOptions']);
|
isset($changes['advancedOptions']) ? $changes['advancedOptions'] : null
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,9 +163,13 @@ class SS_HTML4Value extends SS_HTMLValue {
|
|||||||
// Reset the document if we're in an invalid state for some reason
|
// Reset the document if we're in an invalid state for some reason
|
||||||
if (!$this->isValid()) $this->setDocument(null);
|
if (!$this->isValid()) $this->setDocument(null);
|
||||||
|
|
||||||
return @$this->getDocument()->loadHTML(
|
$errorState = libxml_use_internal_errors(true);
|
||||||
|
$result = $this->getDocument()->loadHTML(
|
||||||
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>' .
|
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>' .
|
||||||
"<body>$content</body></html>"
|
"<body>$content</body></html>"
|
||||||
);
|
);
|
||||||
|
libxml_clear_errors();
|
||||||
|
libxml_use_internal_errors($errorState);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,8 +229,8 @@ class ShortcodeParser {
|
|||||||
'text' => $match[0][0],
|
'text' => $match[0][0],
|
||||||
's' => $match[0][1],
|
's' => $match[0][1],
|
||||||
'e' => $match[0][1] + strlen($match[0][0]),
|
'e' => $match[0][1] + strlen($match[0][0]),
|
||||||
'open' => @$match['open'][0],
|
'open' => isset($match['open'][0]) ? $match['open'][0] : null,
|
||||||
'close' => @$match['close'][0],
|
'close' => isset($match['close'][0]) ? $match['close'][0] : null,
|
||||||
'attrs' => $attrs,
|
'attrs' => $attrs,
|
||||||
'content' => '',
|
'content' => '',
|
||||||
'escaped' => !empty($match['oesc'][0]) || !empty($match['cesc1'][0]) || !empty($match['cesc2'][0])
|
'escaped' => !empty($match['oesc'][0]) || !empty($match['cesc1'][0]) || !empty($match['cesc2'][0])
|
||||||
|
@ -26,8 +26,8 @@ class BasicAuthTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicAuthEnabledWithoutLogin() {
|
public function testBasicAuthEnabledWithoutLogin() {
|
||||||
$origUser = @$_SERVER['PHP_AUTH_USER'];
|
$origUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
|
||||||
$origPw = @$_SERVER['PHP_AUTH_PW'];
|
$origPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
|
||||||
|
|
||||||
unset($_SERVER['PHP_AUTH_USER']);
|
unset($_SERVER['PHP_AUTH_USER']);
|
||||||
unset($_SERVER['PHP_AUTH_PW']);
|
unset($_SERVER['PHP_AUTH_PW']);
|
||||||
@ -40,8 +40,8 @@ class BasicAuthTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicAuthDoesntCallActionOrFurtherInitOnAuthFailure() {
|
public function testBasicAuthDoesntCallActionOrFurtherInitOnAuthFailure() {
|
||||||
$origUser = @$_SERVER['PHP_AUTH_USER'];
|
$origUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
|
||||||
$origPw = @$_SERVER['PHP_AUTH_PW'];
|
$origPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
|
||||||
|
|
||||||
unset($_SERVER['PHP_AUTH_USER']);
|
unset($_SERVER['PHP_AUTH_USER']);
|
||||||
unset($_SERVER['PHP_AUTH_PW']);
|
unset($_SERVER['PHP_AUTH_PW']);
|
||||||
@ -60,8 +60,8 @@ class BasicAuthTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicAuthEnabledWithPermission() {
|
public function testBasicAuthEnabledWithPermission() {
|
||||||
$origUser = @$_SERVER['PHP_AUTH_USER'];
|
$origUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
|
||||||
$origPw = @$_SERVER['PHP_AUTH_PW'];
|
$origPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
|
||||||
|
|
||||||
$_SERVER['PHP_AUTH_USER'] = 'user-in-mygroup@test.com';
|
$_SERVER['PHP_AUTH_USER'] = 'user-in-mygroup@test.com';
|
||||||
$_SERVER['PHP_AUTH_PW'] = 'wrongpassword';
|
$_SERVER['PHP_AUTH_PW'] = 'wrongpassword';
|
||||||
@ -83,8 +83,8 @@ class BasicAuthTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicAuthEnabledWithoutPermission() {
|
public function testBasicAuthEnabledWithoutPermission() {
|
||||||
$origUser = @$_SERVER['PHP_AUTH_USER'];
|
$origUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
|
||||||
$origPw = @$_SERVER['PHP_AUTH_PW'];
|
$origPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
|
||||||
|
|
||||||
$_SERVER['PHP_AUTH_USER'] = 'user-without-groups@test.com';
|
$_SERVER['PHP_AUTH_USER'] = 'user-without-groups@test.com';
|
||||||
$_SERVER['PHP_AUTH_PW'] = 'wrongpassword';
|
$_SERVER['PHP_AUTH_PW'] = 'wrongpassword';
|
||||||
|
Loading…
Reference in New Issue
Block a user