Skip to content

Commit

Permalink
BackwardsCompatibilityBreak - Removed fCore::trigger()
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond committed Apr 12, 2012
1 parent 2238719 commit 843e4a0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 72 deletions.
48 changes: 6 additions & 42 deletions classes/fCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class fCore
const reset = 'fCore::reset';
const sendMessagesOnShutdown = 'fCore::sendMessagesOnShutdown';
const stringlike = 'fCore::stringlike';
const trigger = 'fCore::trigger';


/**
Expand Down Expand Up @@ -552,12 +551,12 @@ static public function getOS()
return 'windows';
}

self::trigger(
'warning',
trigger_error(
self::compose(
'Unable to reliably determine the server OS. Defaulting to %s.',
"'linux/unix'"
)
),
E_USER_WARNING
);

return 'linux/unix';
Expand Down Expand Up @@ -652,12 +651,12 @@ static public function handleException($exception)
try {
self::call(self::$exception_handler_callback, self::$exception_handler_parameters);
} catch (Exception $e) {
self::trigger(
'error',
trigger_error(
self::compose(
'An exception was thrown in the %s closing code callback',
'setExceptionHandling()'
)
),
E_USER_ERROR
);
}
}
Expand Down Expand Up @@ -800,41 +799,6 @@ static public function stringlike($value)
}


/**
* Triggers a user-level error
*
* The default error handler in PHP will show the line number of this
* method as the triggering code. To get a full backtrace, use
* ::enableErrorHandling().
*
* @param string $error_type The type of error to trigger: `'error'`, `'warning'`, `'notice'`
* @param string $message The error message
* @return void
*/
static public function trigger($error_type, $message)
{
$valid_error_types = array('error', 'warning', 'notice');
if (!in_array($error_type, $valid_error_types)) {
self::toss(
'fProgrammerException',
self::compose(
'Invalid error type, %1$s, specified. Must be one of: %2$s.',
self::dump($error_type),
join(', ', $valid_error_types)
)
);
}

static $error_type_map = array(
'error' => E_USER_ERROR,
'warning' => E_USER_WARNING,
'notice' => E_USER_NOTICE
);

trigger_error($message, $error_type_map[$error_type]);
}


/**
* Forces use as a static class
*
Expand Down
12 changes: 6 additions & 6 deletions classes/fDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1471,14 +1471,14 @@ public function query($sql)
);

if ($this->slow_query_threshold && $query_time > $this->slow_query_threshold) {
fCore::trigger(
'warning',
trigger_error(
self::compose(
'The following query took %1$s milliseconds, which is above the slow query threshold of %2$s:%3$s',
$query_time,
$this->slow_query_threshold,
"\n" . $result->getSQL()
)
),
E_USER_WARNING
);
}

Expand Down Expand Up @@ -1667,14 +1667,14 @@ public function unbufferedQuery($sql)
);

if ($this->slow_query_threshold && $query_time > $this->slow_query_threshold) {
fCore::trigger(
'warning',
trigger_error(
self::compose(
'The following query took %1$s milliseconds, which is above the slow query threshold of %2$s:%3$s',
$query_time,
$this->slow_query_threshold,
"\n" . $result->getSQL()
)
),
E_USER_WARNING
);
}

Expand Down
30 changes: 24 additions & 6 deletions classes/fEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ static public function fixQmail()

if (!$sendmail_command) {
self::$convert_crlf = TRUE;
fCore::trigger('warning', 'The proper fix for sending through qmail is not possible since the sendmail path is not set');
fCore::trigger('warning', 'Trying to fix qmail by converting all \r\n to \n. This will cause invalid (but possibly functioning) email headers to be generated.');
trigger_error(
self::compose('The proper fix for sending through qmail is not possible since the sendmail path is not set'),
E_USER_WARNING
);
trigger_error(
self::compose('Trying to fix qmail by converting all \r\n to \n. This will cause invalid (but possibly functioning) email headers to be generated.'),
E_USER_WARNING
);
}

$sendmail_command_parts = explode(' ', $sendmail_command, 2);
Expand Down Expand Up @@ -158,11 +164,23 @@ static public function fixQmail()
} else {
self::$convert_crlf = TRUE;
if ($safe_mode) {
fCore::trigger('warning', 'The proper fix for sending through qmail is not possible since safe mode is turned on and the sendmail binary is not in one of the paths defined by the safe_mode_exec_dir ini setting');
fCore::trigger('warning', 'Trying to fix qmail by converting all \r\n to \n. This will cause invalid (but possibly functioning) email headers to be generated.');
trigger_error(
self::compose('The proper fix for sending through qmail is not possible since safe mode is turned on and the sendmail binary is not in one of the paths defined by the safe_mode_exec_dir ini setting'),
E_USER_WARNING
);
trigger_error(
self::compose('Trying to fix qmail by converting all \r\n to \n. This will cause invalid (but possibly functioning) email headers to be generated.'),
E_USER_WARNING
);
} else {
fCore::trigger('warning', 'The proper fix for sending through qmail is not possible since the sendmail binary could not be found or is not executable');
fCore::trigger('warning', 'Trying to fix qmail by converting all \r\n to \n. This will cause invalid (but possibly functioning) email headers to be generated.');
trigger_error(
self::compose('The proper fix for sending through qmail is not possible since the sendmail binary could not be found or is not executable'),
E_USER_WARNING
);
trigger_error(
self::compose('Trying to fix qmail by converting all \r\n to \n. This will cause invalid (but possibly functioning) email headers to be generated.'),
E_USER_WARNING
);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions classes/fResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,30 +403,30 @@ private function fixDblibMSSQLDriver($row)
foreach ($row as $key => $value) {
if ($value == ' ') {
$row[$key] = '';
fCore::trigger(
'notice',
trigger_error(
self::compose(
'A single space was detected coming out of the database and was converted into an empty string - see %s for more information',
'http://bugs.php.net/bug.php?id=26315'
)
),
E_USER_NOTICE
);
}
if (strlen($key) == 30) {
fCore::trigger(
'notice',
trigger_error(
self::compose(
'A column name exactly 30 characters in length was detected coming out of the database - this column name may be truncated, see %s for more information.',
'http://bugs.php.net/bug.php?id=23990'
)
),
E_USER_NOTICE
);
}
if (strlen($value) == 256) {
fCore::trigger(
'notice',
trigger_error(
self::compose(
'A value exactly 255 characters in length was detected coming out of the database - this value may be truncated, see %s for more information.',
'http://bugs.php.net/bug.php?id=37757'
)
),
E_USER_NOTICE
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions classes/fUnbufferedResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,30 +338,30 @@ private function fixDblibMSSQLDriver($row)
foreach ($row as $key => $value) {
if ($value == ' ') {
$row[$key] = '';
fCore::trigger(
'notice',
trigger_error(
self::compose(
'A single space was detected coming out of the database and was converted into an empty string - see %s for more information',
'http://bugs.php.net/bug.php?id=26315'
)
),
E_USER_NOTICE
);
}
if (strlen($key) == 30) {
fCore::trigger(
'notice',
trigger_error(
self::compose(
'A column name exactly 30 characters in length was detected coming out of the database - this column name may be truncated, see %s for more information.',
'http://bugs.php.net/bug.php?id=23990'
)
),
E_USER_NOTICE
);
}
if (strlen($value) == 256) {
fCore::trigger(
'notice',
trigger_error(
self::compose(
'A value exactly 255 characters in length was detected coming out of the database - this value may be truncated, see %s for more information.',
'http://bugs.php.net/bug.php?id=37757'
)
),
E_USER_NOTICE
);
}
}
Expand Down

0 comments on commit 843e4a0

Please sign in to comment.