diff --git a/classes/colorutils.php b/classes/colorutils.php index 8b42a7cf8..4ba1d9123 100644 --- a/classes/colorutils.php +++ b/classes/colorutils.php @@ -32,7 +32,7 @@ public static function hex_rgb( $hex_string ) { $hex_string = ltrim( $hex_string, '#' ); if ( ! preg_match( '/^[0-9a-f]+$/i', $hex_string ) ) { - return Error::raise( _t( 'Not a valid hex color.' ) ); + return HabariError::raise( _t( 'Not a valid hex color.' ) ); } $normalized = ''; @@ -54,7 +54,7 @@ public static function hex_rgb( $hex_string ) $normalized = $hex_string . str_repeat( '0', 6 - strlen( $hex_string ) ); break; default: - return Error::raise( _t( 'Not a valid color format.' ) ); + return HabariError::raise( _t( 'Not a valid color format.' ) ); } return self::rgb_rgbarr( diff --git a/classes/error.php b/classes/habarierror.php similarity index 84% rename from classes/error.php rename to classes/habarierror.php index 174c9b539..839843b32 100644 --- a/classes/error.php +++ b/classes/habarierror.php @@ -8,19 +8,19 @@ * Contains error-related functions and Habari's error handler. * **/ -class Error extends Exception +class HabariError extends Exception { protected $message = ''; protected $is_error = false; /** - * Constructor for the Error class + * Constructor for the HabariError class * * @param string $message Exception to display * @param integer $code Code of the exception - * @param boolean $is_error true if the exception represents an error handled by the Error class + * @param boolean $is_error true if the exception represents an error handled by the HabariError class */ - public function __construct( $message = 'Generic Habari Error', $code = 0, $is_error = false ) + public function __construct( $message = 'Generic Habari HabariError', $code = 0, $is_error = false ) { parent::__construct( $message, $code ); $this->is_error = $is_error; @@ -29,13 +29,13 @@ public function __construct( $message = 'Generic Habari Error', $code = 0, $is_e /** * function handle_errors * - * Configures the Error class to handle all errors. + * Configures the HabariError class to handle all errors. */ public static function handle_errors() { - set_error_handler( array( 'Error', 'error_handler' ) ); - set_exception_handler( array( 'Error', 'exception_handler' ) ); - register_shutdown_function( array( 'Error', 'shutdown_handler' ) ); + set_error_handler( array( 'HabariError', 'error_handler' ) ); + set_exception_handler( array( 'HabariError', 'exception_handler' ) ); + register_shutdown_function( array( 'HabariError', 'shutdown_handler' ) ); } public static function shutdown_handler ( ) { @@ -95,7 +95,7 @@ public function humane_error() } /** - * Used to handle all PHP errors after Error::handle_errors() is called. + * Used to handle all PHP errors after HabariError::handle_errors() is called. */ public static function error_handler( $errno, $errstr, $errfile, $errline, $errcontext ) { @@ -113,23 +113,23 @@ function _t( $v ) // Don't be fooled, we can't actually handle most of these. $error_names = array( // @locale A fatal PHP error at runtime. Code execution is stopped - E_ERROR => _t( 'Error' ), + E_ERROR => _t( 'HabariError' ), // @locale A non-fatal PHP error at runtime. Code execution is not stopped E_WARNING => _t( 'Warning' ), // @locale A fatal PHP error generated while parsing the PHP - E_PARSE => _t( 'Parse Error' ), + E_PARSE => _t( 'Parse HabariError' ), // @locale PHP encountered something at runtime that could be an error or intended E_NOTICE => _t( 'Notice' ), // @locale A fatal PHP error during PHP startup. Code execution is stopped. - E_CORE_ERROR => _t( 'Core Error' ), + E_CORE_ERROR => _t( 'Core HabariError' ), // @locale A non-fatal PHP during PHP startup. Code execution is not stopped. E_CORE_WARNING => _t( 'Core Warning' ), // @locale A fatal PHP error at runtime. Code execution is stopped. - E_COMPILE_ERROR => _t( 'Compile Error' ), + E_COMPILE_ERROR => _t( 'Compile HabariError' ), // @locale A non-fatal PHP error at runtime. Code execution is not stopped. E_COMPILE_WARNING => _t( 'Compile Warning' ), // @locale A fatal error generated by Habari or an addon. Code execution is stopped. - E_USER_ERROR => _t( 'User Error' ), + E_USER_ERROR => _t( 'User HabariError' ), // @locale A non-fatal error generated by Habari or an addon. Code execution is not stopped. E_USER_WARNING => _t( 'User Warning' ), // @locale PHP encountered something generated by Habari or an addon at runtime that could be an error or intended @@ -137,7 +137,7 @@ function _t( $v ) // @locale A suggestion from PHP that the code may need updated for interoperability or forward compatibility E_STRICT => _t( 'Strict Notice' ), // @locale A fatal PHP error at runtime. An error handler may be able to work around it. If not, code execution stops. - E_RECOVERABLE_ERROR => _t( 'Recoverable Error' ), + E_RECOVERABLE_ERROR => _t( 'Recoverable HabariError' ), ); if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) { // @locale A notification from PHP that the code is outdated and may not work in the future @@ -158,7 +158,7 @@ function _t( $v ) $errline ); if ( DEBUG ) { - Error::print_backtrace(); + HabariError::print_backtrace(); } if ( Options::get( 'log_backtraces', false ) || DEBUG ) { @@ -177,8 +177,8 @@ function _t( $v ) EventLog::log( $errstr . ' in ' . $errfile . ':' . $errline, 'err', 'default', null, $backtrace ); } - // throwing an Error make every error fatal! - //throw new Error($errstr, 0, true); + // throwing an HabariError make every error fatal! + //throw new HabariError($errstr, 0, true); } /** @@ -203,7 +203,7 @@ private static function print_backtrace( $trace = null ) foreach ( $trace as $n => $a ) { $a = array_merge( $defaults, $a ); - if ( $a['class'] == 'Error' ) { + if ( $a['class'] == 'HabariError' ) { continue; } @@ -268,21 +268,21 @@ public function get() /** * function raise * - * Convenience method to create and return a new Error object + * Convenience method to create and return a new HabariError object */ public static function raise( $error_message, $severity = E_USER_ERROR ) { - return new Error( $error_message, $severity ); + return new HabariError( $error_message, $severity ); } /** * function is_error * - * Returns true if the argument is an Error instance + * Returns true if the argument is an HabariError instance */ public static function is_error( $obj ) { - return ($obj instanceof Error); + return ($obj instanceof HabariError); } } diff --git a/classes/habarilocale.php b/classes/habarilocale.php index bd1134945..71872f753 100644 --- a/classes/habarilocale.php +++ b/classes/habarilocale.php @@ -145,11 +145,11 @@ public static function list_all() private static function load_file( $domain, $file ) { if ( ! file_exists( $file ) ) { - Error::raise( _t( 'No translations found for locale %s, domain %s!', array( self::$locale, $domain ) ) ); + HabariError::raise( _t( 'No translations found for locale %s, domain %s!', array( self::$locale, $domain ) ) ); return false; } if ( filesize( $file ) < 24 ) { - Error::raise( _t( 'Invalid .MO file for locale %s, domain %s!', array( self::$locale, $domain ) ) ); + HabariError::raise( _t( 'Invalid .MO file for locale %s, domain %s!', array( self::$locale, $domain ) ) ); return false; } @@ -169,13 +169,13 @@ private static function load_file( $domain, $file ) $little_endian = false; break; default: - Error::raise( _t( 'Invalid magic number 0x%08x in %s!', array( $magic, $file ) ) ); + HabariError::raise( _t( 'Invalid magic number 0x%08x in %s!', array( $magic, $file ) ) ); return false; } $revision = substr( $data, 4, 4 ); if ( $revision != 0 ) { - Error::raise( _t( 'Unknown revision number %d in %s!', array( $revision, $file ) ) ); + HabariError::raise( _t( 'Unknown revision number %d in %s!', array( $revision, $file ) ) ); return false; } @@ -186,7 +186,7 @@ private static function load_file( $domain, $file ) $header = unpack( "{$l}1msgcount/{$l}1msgblock/{$l}1transblock", $header ); if ( $header['msgblock'] + ($header['msgcount'] - 1 ) * 8 > filesize( $file ) ) { - Error::raise( _t( 'Message count (%d) out of bounds in %s!', array( $header['msgcount'], $file ) ) ); + HabariError::raise( _t( 'Message count (%d) out of bounds in %s!', array( $header['msgcount'], $file ) ) ); return false; } diff --git a/classes/htmltokenizer.php b/classes/htmltokenizer.php index c77339448..c0df14712 100644 --- a/classes/htmltokenizer.php +++ b/classes/htmltokenizer.php @@ -77,7 +77,7 @@ public function parse() $this->state = $this->parse_pi(); break; default: - Error::raise( _t( 'Invalid state %d in %s->parse()', array( $this->state, __CLASS__ ) ) ); + HabariError::raise( _t( 'Invalid state %d in %s->parse()', array( $this->state, __CLASS__ ) ) ); $this->state = self::$STATE_FINISHED; break; } diff --git a/classes/inforecords.php b/classes/inforecords.php index 6f595c6e5..47b24adef 100644 --- a/classes/inforecords.php +++ b/classes/inforecords.php @@ -203,7 +203,7 @@ public function delete_all() WHERE ' . $this->_key_name . ' = ?', array( $this->_key_value ) ); - if ( Error::is_error( $result ) ) { + if ( HabariError::is_error( $result ) ) { $result->out(); return false; } @@ -256,7 +256,7 @@ public function commit( $metadata_key = null ) ); } - if ( Error::is_error( $result ) ) { + if ( HabariError::is_error( $result ) ) { $result->out(); } $this->__inforecord_array[$name] = array('value'=>$value); diff --git a/classes/inputfilter.php b/classes/inputfilter.php index 9c6cda20b..bc96b9078 100644 --- a/classes/inputfilter.php +++ b/classes/inputfilter.php @@ -406,7 +406,7 @@ private static function check_attr_value( $k, $v, $type ) return preg_match( '/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9](?:Z|[\+-][0-2][0-9]:[0-5][0-9])$/', $v ); break; default: - Error::raise( _t( 'Unknown attribute type "%s" in %s', array( $type, __CLASS__ ) ) ); + HabariError::raise( _t( 'Unknown attribute type "%s" in %s', array( $type, __CLASS__ ) ) ); return false; } } diff --git a/classes/options.php b/classes/options.php index 00877d45a..5869cb981 100644 --- a/classes/options.php +++ b/classes/options.php @@ -254,8 +254,8 @@ public function __set( $name, $value ) } else { $result = DB::update( DB::table( 'options' ), array( 'name' => $name, 'value' => $value, 'type' => 0 ), array( 'name' => $name ) ); - } - if ( Error::is_error( $result ) ) { + } + if ( HabariError::is_error( $result ) ) { $result->out(); die(); } diff --git a/classes/rpcclient.php b/classes/rpcclient.php index db3334e62..4ca2a500b 100644 --- a/classes/rpcclient.php +++ b/classes/rpcclient.php @@ -23,7 +23,7 @@ class RPCClient function __construct( $url, $method, $params ) { if ( ! function_exists( 'xmlrpc_encode_request' ) ) { - return Error::raise( _t( 'xmlrpc extension not found' ) ); + return HabariError::raise( _t( 'xmlrpc extension not found' ) ); } $this->url = $url; $this->method = $method; diff --git a/classes/site.php b/classes/site.php index 673a6e02c..c75d375e8 100644 --- a/classes/site.php +++ b/classes/site.php @@ -61,7 +61,7 @@ public static function script_name() self::$scriptname = $_SERVER['PHP_SELF']; break; default: - Error::raise( _t( 'Could not determine script name.' ) ); + HabariError::raise( _t( 'Could not determine script name.' ) ); die(); } return self::$scriptname; diff --git a/classes/utils.php b/classes/utils.php index 6b4621c84..4735ef77f 100644 --- a/classes/utils.php +++ b/classes/utils.php @@ -426,7 +426,7 @@ public static function crypt( $password, $hash = null ) case 'md5': return self::$algo( $password, $hash ); default: - Error::raise( _t( 'Unsupported digest algorithm "%s"', array( $algo ) ) ); + HabariError::raise( _t( 'Unsupported digest algorithm "%s"', array( $algo ) ) ); return false; } } @@ -436,7 +436,7 @@ public static function crypt( $password, $hash = null ) } } else { - Error::raise( _t( 'Invalid hash' ) ); + HabariError::raise( _t( 'Invalid hash' ) ); } } @@ -497,7 +497,7 @@ public static function ssha( $password, $hash = null ) else { // verify // is this a SSHA hash? if ( ! substr( $hash, 0, strlen( $marker ) ) == $marker ) { - Error::raise( _t( 'Invalid hash' ) ); + HabariError::raise( _t( 'Invalid hash' ) ); return false; } // cut off {SSHA} marker @@ -536,7 +536,7 @@ public static function ssha512( $password, $hash = null ) } else { // verify if ( ! substr( $hash, 0, strlen( $marker ) ) == $marker ) { - Error::raise( _t( 'Invalid hash' ) ); + HabariError::raise( _t( 'Invalid hash' ) ); return false; } $hash = substr( $hash, strlen( $marker ) ); diff --git a/handlers/userthemehandler.php b/handlers/userthemehandler.php index fc4c9c144..0d5d82c82 100644 --- a/handlers/userthemehandler.php +++ b/handlers/userthemehandler.php @@ -45,7 +45,7 @@ public function act( $action ) $this->theme->$action_method(); } } - catch( Error $e ) { + catch( HabariError $e ) { EventLog::log( $e->humane_error(), 'error', 'theme', 'habari', print_r( $e, 1 ) ); Session::error( $e->humane_error() ); //Should we display any error here? if ( DEBUG ) { @@ -73,7 +73,7 @@ protected function display( $template_name ) try { $this->theme->display( $template_name ); } - catch( Error $e ) { + catch( HabariError $e ) { EventLog::log( $e->humane_error(), 'error', 'theme', 'habari', print_r( $e, 1 ) ); } } diff --git a/index.php b/index.php index f07cda177..68cb1cf8b 100644 --- a/index.php +++ b/index.php @@ -57,7 +57,7 @@ // Use our own error reporting class. if ( !defined( 'SUPPRESS_ERROR_HANDLER' ) ) { - Error::handle_errors(); + HabariError::handle_errors(); } /** diff --git a/plugins/flickrsilo/flickrsilo.plugin.php b/plugins/flickrsilo/flickrsilo.plugin.php index 13d2e402f..e2d9c4b28 100644 --- a/plugins/flickrsilo/flickrsilo.plugin.php +++ b/plugins/flickrsilo/flickrsilo.plugin.php @@ -203,7 +203,7 @@ function photosetsGetList( $nsid = '' ) } $xml = $this->call( 'flickr.photosets.getList', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -213,7 +213,7 @@ function photosetsGetInfo( $photoset_id ) { $params = array( 'photoset_id' => $photoset_id ); $xml = $this->call( 'flickr.photosets.getInfo', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -228,7 +228,7 @@ function photosetsGetPhotos( $photoset_id ) { $params = array( 'photoset_id' => $photoset_id ); $xml = $this->call( 'flickr.photosets.getPhotos', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -254,7 +254,7 @@ function photosRecentlyUpdated() $xml = $this->call( 'flickr.photos.recentlyUpdated', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -273,7 +273,7 @@ function mediaSearch( $params = array() ) $xml = $this->call( 'flickr.photos.search', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -298,7 +298,7 @@ function photosSearch( $params = array() ) $xml = $this->call( 'flickr.photos.search', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -318,7 +318,7 @@ function videoSearch( $params = array() ) $xml = $this->call( 'flickr.photos.search', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } return $xml; @@ -346,7 +346,7 @@ function photosGetInfo( $photo_id ) $xml = $this->call( 'flickr.photos.getInfo', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } @@ -402,7 +402,7 @@ function upload( $photo, $title = '', $description = '', $tags = '', $perms = '' // call the upload method. $xml = $this->call( 'upload', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; } @@ -429,7 +429,7 @@ function photosUploadCheckTickets( $tickets ) } $xml = $this->call( 'flickr.photos.upload.checkTickets', $params ); - if ( Error::is_error( $xml ) ){ + if ( HabariError::is_error( $xml ) ){ throw $xml; }