From 3a79881f861ed795f2a8d4e4124624de63214131 Mon Sep 17 00:00:00 2001 From: kiswa Date: Thu, 22 Jan 2015 14:35:46 -0500 Subject: [PATCH] Revert commits to master. --- api/api.php | 1 - api/lib/Slim/Middleware/PrettyExceptions.php | 2 +- api/lib/Slim/Route.php | 6 - api/lib/Slim/Slim.php | 12 -- api/lib/Slim/View.php | 2 +- api/lib/rb.php | 214 +++---------------- 6 files changed, 26 insertions(+), 211 deletions(-) diff --git a/api/api.php b/api/api.php index f46c75b..f2efbf1 100644 --- a/api/api.php +++ b/api/api.php @@ -24,7 +24,6 @@ function exceptionHandler($exception) { $jsonResponse->message = 'API Error.'; $jsonResponse->data = $exception->getMessage(); - $jsonResponse->trace = $exception->getTrace(); echo $jsonResponse->asJson(); }; set_exception_handler('exceptionHandler'); diff --git a/api/lib/Slim/Middleware/PrettyExceptions.php b/api/lib/Slim/Middleware/PrettyExceptions.php index 0ea3823..8a56442 100644 --- a/api/lib/Slim/Middleware/PrettyExceptions.php +++ b/api/lib/Slim/Middleware/PrettyExceptions.php @@ -89,7 +89,7 @@ class PrettyExceptions extends \Slim\Middleware $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); - $trace = str_replace(array('#', "\n"), array('
#', '
'), $exception->getTraceAsString()); + $trace = str_replace(array('#', '\n'), array('
#', '
'), $exception->getTraceAsString()); $html = sprintf('

%s

', $title); $html .= '

The application could not run because of the following error:

'; $html .= '

Details

'; diff --git a/api/lib/Slim/Route.php b/api/lib/Slim/Route.php index e10c442..99b47a1 100644 --- a/api/lib/Slim/Route.php +++ b/api/lib/Slim/Route.php @@ -288,9 +288,6 @@ class Route public function appendHttpMethods() { $args = func_get_args(); - if(count($args) && is_array($args[0])){ - $args = $args[0]; - } $this->methods = array_merge($this->methods, $args); } @@ -301,9 +298,6 @@ class Route public function via() { $args = func_get_args(); - if(count($args) && is_array($args[0])){ - $args = $args[0]; - } $this->methods = array_merge($this->methods, $args); return $this; diff --git a/api/lib/Slim/Slim.php b/api/lib/Slim/Slim.php index c2de8b4..cb8ef66 100644 --- a/api/lib/Slim/Slim.php +++ b/api/lib/Slim/Slim.php @@ -1099,18 +1099,6 @@ class Slim $this->response->redirect($url, $status); $this->halt($status); } - - /** - * RedirectTo - * - * Redirects to a specific named route - * - * @param string $route The route name - * @param array $params Associative array of URL parameters and replacement values - */ - public function redirectTo($route, $params = array(), $status = 302){ - $this->redirect($this->urlFor($route, $params), $status); - } /******************************************************************************** * Flash Messages diff --git a/api/lib/Slim/View.php b/api/lib/Slim/View.php index e427d60..1a3973b 100644 --- a/api/lib/Slim/View.php +++ b/api/lib/Slim/View.php @@ -108,7 +108,7 @@ class View * @param string $key * @param mixed $value */ - public function keep($key, \Closure $value) + public function keep($key, Closure $value) { $this->data->keep($key, $value); } diff --git a/api/lib/rb.php b/api/lib/rb.php index 1c7c904..a851d8d 100644 --- a/api/lib/rb.php +++ b/api/lib/rb.php @@ -194,11 +194,6 @@ class Debug extends RDefault implements Logger */ private function writeQuery( $newSql, $newBindings ) { - //avoid str_replace collisions: slot1 and slot10 (issue 407). - uksort( $newBindings, function( $a, $b ) { - return ( strlen( $b ) - strlen( $a ) ); - } ); - $newStr = $newSql; foreach( $newBindings as $slot => $value ) { if ( strpos( $slot, ':' ) === 0 ) { @@ -703,8 +698,6 @@ class RPDO implements Driver //PHP 5.3 PDO SQLite has a bug with large numbers: if ( strpos( $this->dsn, 'sqlite' ) === 0 && PHP_MAJOR_VERSION === 5 && PHP_MINOR_VERSION === 3) { $this->max = 2147483647; //otherwise you get -2147483648 ?! demonstrated in build #603 on Travis. - } elseif ( strpos( $this->dsn, 'cubrid' ) === 0 ) { - $this->max = 2147483647; //bindParam in pdo_cubrid also fails... } else { $this->max = PHP_INT_MAX; //the normal value of course (makes it possible to use large numbers in LIMIT clause) } @@ -743,14 +736,14 @@ class RPDO implements Driver $this->pdo = new\PDO( $this->dsn, $user, - $pass + $pass, + array(\PDO::ATTR_ERRMODE =>\PDO::ERRMODE_EXCEPTION, + \PDO::ATTR_DEFAULT_FETCH_MODE =>\PDO::FETCH_ASSOC, + ) ); $this->setEncoding(); $this->pdo->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, TRUE ); - //cant pass these as argument to constructor, CUBRID driver does not understand... - $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE,\PDO::FETCH_ASSOC); $this->isConnected = TRUE; } catch (\PDOException $exception ) { @@ -1028,78 +1021,6 @@ use RedBeanPHP\OODBBean as OODBBean; */ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable { - /** - * @var boolean - */ - protected static $errorHandlingFUSE = FALSE; - - /** - * @var callable|NULL - */ - protected static $errorHandler = NULL; - - /** - * FUSE error modes. - */ - const C_ERR_IGNORE = FALSE; - const C_ERR_LOG = 1; - const C_ERR_NOTICE = 2; - const C_ERR_WARN = 3; - const C_ERR_EXCEPTION = 4; - const C_ERR_FUNC = 5; - const C_ERR_FATAL = 6; - - /** - * Sets the error mode for FUSE. - * What to do if a FUSE model method does not exist? - * You can set the following options: - * - * OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL - * OODBBean::C_ERR_LOG, logs the incident using error_log - * OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE - * OODBBean::C_ERR_WARN, triggers a E_USER_WARNING - * OODBBean::C_ERR_EXCEPTION, throws an exception - * OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function) - * OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR - * - * Custom handler method signature: handler( array ( - * 'message' => string - * 'bean' => OODBBean - * 'method' => string - * ) ) - * - * This method returns the old mode and handler as an array. - * - * @param integer $mode mode - * @param callable|NULL $func custom handler - * - * @return array - */ - public static function setErrorHandlingFUSE($mode, $func = NULL) { - if ( - $mode !== self::C_ERR_IGNORE - && $mode !== self::C_ERR_LOG - && $mode !== self::C_ERR_NOTICE - && $mode !== self::C_ERR_WARN - && $mode !== self::C_ERR_EXCEPTION - && $mode !== self::C_ERR_FUNC - && $mode !== self::C_ERR_FATAL - ) throw new \Exception( 'Invalid error mode selected' ); - - if ( $mode === self::C_ERR_FUNC && !is_callable( $func ) ) { - throw new \Exception( 'Invalid error handler' ); - } - - $old = array( self::$errorHandlingFUSE, self::$errorHandler ); - self::$errorHandlingFUSE = $mode; - if ( is_callable( $func ) ) { - self::$errorHandler = $func; - } else { - self::$errorHandler = NULL; - } - return $old; - } - /** * This is where the real properties of the bean live. They are stored and retrieved * by the magic getter and setter (__get and __set). @@ -1512,7 +1433,6 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable $vn = array(); foreach ( $value as $i => $b ) { - if ( !( $b instanceof OODBBean ) ) continue; $vn[] = $b->export( $meta, FALSE, FALSE, $filters ); $value = $vn; } @@ -2114,39 +2034,6 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable $this->__info['model'] = $model; } if ( !method_exists( $this->__info['model'], $method ) ) { - - if ( self::$errorHandlingFUSE === FALSE ) { - return NULL; - } - - if ( in_array( $method, array( 'update', 'open', 'delete', 'after_delete', 'after_update', 'dispense' ), TRUE ) ) { - return NULL; - } - - $message = "FUSE: method does not exist in model: $method"; - if ( self::$errorHandlingFUSE === self::C_ERR_LOG ) { - error_log( $message ); - return NULL; - } elseif ( self::$errorHandlingFUSE === self::C_ERR_NOTICE ) { - trigger_error( $message, E_USER_NOTICE ); - return NULL; - } elseif ( self::$errorHandlingFUSE === self::C_ERR_WARN ) { - trigger_error( $message, E_USER_WARNING ); - return NULL; - } elseif ( self::$errorHandlingFUSE === self::C_ERR_EXCEPTION ) { - throw new \Exception( $message ); - } elseif ( self::$errorHandlingFUSE === self::C_ERR_FUNC ) { - if ( is_callable( self::$errorHandler ) ) { - $func = self::$errorHandler; - return $func(array( - 'message' => $message, - 'method' => $method, - 'args' => $args, - 'bean' => $this - )); - } - } - trigger_error( $message, E_USER_ERROR ); return NULL; } @@ -2544,15 +2431,13 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable $firstKey = key( $this->withParams ); } - $joinSql = $this->parseJoin( $type ); - if ( !is_numeric( $firstKey ) || $firstKey === NULL ) { $bindings = $this->withParams; $bindings[':slot0'] = $this->getID(); - $count = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount( $type, array(), " {$joinSql} $myFieldLink = :slot0 " . $this->withSql, $bindings ); + $count = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount( $type, array(), " $myFieldLink = :slot0 " . $this->withSql, $bindings ); } else { $bindings = array_merge( array( $this->getID() ), $this->withParams ); - $count = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount( $type, array(), " {$joinSql} $myFieldLink = ? " . $this->withSql, $bindings ); + $count = $this->beanHelper->getToolbox()->getWriter()->queryRecordCount( $type, array(), " $myFieldLink = ? " . $this->withSql, $bindings ); } } @@ -3917,13 +3802,10 @@ abstract class AQueryWriter { //bracket must be here - otherwise coverage softwa * A cache tag is used to make sure the cache remains consistent. In most cases the cache tag * will be the bean type, this makes sure queries associated with a certain reference type will * never contain conflicting data. - * Why not use the cache tag as a key? Well + * You can only store one item under a cache tag. Why not use the cache tag as a key? Well * we need to make sure the cache contents fits the key (and key is based on the cache values). * Otherwise it would be possible to store two different result sets under the same key (the cache tag). * - * In previous versions you could only store one key-entry, I have changed this to - * improve caching efficiency (issue #400). - * * @param string $cacheTag cache tag (secondary key) * @param string $key key * @param array $values content to be stored @@ -3932,8 +3814,9 @@ abstract class AQueryWriter { //bracket must be here - otherwise coverage softwa */ private function putResultInCache( $cacheTag, $key, $values ) { - if (!isset($this->cache[$cacheTag])) $this->cache[$cacheTag] = array(); - $this->cache[$cacheTag][$key] = $values; + $this->cache[$cacheTag] = array( + $key => $values + ); } /** @@ -4728,10 +4611,9 @@ class MySQL extends AQueryWriter implements QueryWriter const C_DATATYPE_BOOL = 0; const C_DATATYPE_UINT32 = 2; const C_DATATYPE_DOUBLE = 3; - const C_DATATYPE_TEXT7 = 4; //InnoDB cant index varchar(255) utf8mb4 - so keep 191 as long as possible - const C_DATATYPE_TEXT8 = 5; - const C_DATATYPE_TEXT16 = 6; - const C_DATATYPE_TEXT32 = 7; + const C_DATATYPE_TEXT8 = 4; + const C_DATATYPE_TEXT16 = 5; + const C_DATATYPE_TEXT32 = 6; const C_DATATYPE_SPECIAL_DATE = 80; const C_DATATYPE_SPECIAL_DATETIME = 81; const C_DATATYPE_SPECIAL_POINT = 90; @@ -4822,8 +4704,7 @@ class MySQL extends AQueryWriter implements QueryWriter MySQL::C_DATATYPE_BOOL => ' TINYINT(1) UNSIGNED ', MySQL::C_DATATYPE_UINT32 => ' INT(11) UNSIGNED ', MySQL::C_DATATYPE_DOUBLE => ' DOUBLE ', - MySQL::C_DATATYPE_TEXT7 => ' VARCHAR(191) ', - MYSQL::C_DATATYPE_TEXT8 => ' VARCHAR(255) ', + MySQL::C_DATATYPE_TEXT8 => ' VARCHAR(255) ', MySQL::C_DATATYPE_TEXT16 => ' TEXT ', MySQL::C_DATATYPE_TEXT32 => ' LONGTEXT ', MySQL::C_DATATYPE_SPECIAL_DATE => ' DATE ', @@ -4899,7 +4780,6 @@ class MySQL extends AQueryWriter implements QueryWriter $this->svalue = $value; if ( is_null( $value ) ) return MySQL::C_DATATYPE_BOOL; - if ( $value === INF ) return MySQL::C_DATATYPE_TEXT8; if ( $flagSpecial ) { if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) { @@ -4935,10 +4815,6 @@ class MySQL extends AQueryWriter implements QueryWriter } } - if ( mb_strlen( $value, 'UTF-8' ) <= 191 ) { - return MySQL::C_DATATYPE_TEXT7; - } - if ( mb_strlen( $value, 'UTF-8' ) <= 255 ) { return MySQL::C_DATATYPE_TEXT8; } @@ -5367,7 +5243,6 @@ class SQLiteT extends AQueryWriter implements QueryWriter $this->svalue = $value; if ( $value === NULL ) return self::C_DATATYPE_INTEGER; - if ( $value === INF ) return self::C_DATATYPE_TEXT; if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT; @@ -5375,7 +5250,7 @@ class SQLiteT extends AQueryWriter implements QueryWriter if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) return self::C_DATATYPE_INTEGER; - if ( ( is_numeric( $value ) && $value < 2147483648 && $value > -2147483648) + if ( ( is_numeric( $value ) && $value < 2147483648 ) || preg_match( '/\d{4}\-\d\d\-\d\d/', $value ) || preg_match( '/\d{4}\-\d\d\-\d\d\s\d\d:\d\d:\d\d/', $value ) ) { @@ -5750,8 +5625,6 @@ class PostgreSQL extends AQueryWriter implements QueryWriter { $this->svalue = $value; - if ( $value === INF ) return self::C_DATATYPE_TEXT; - if ( $flagSpecial && $value ) { if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) { return PostgreSQL::C_DATATYPE_SPECIAL_DATE; @@ -5777,7 +5650,7 @@ class PostgreSQL extends AQueryWriter implements QueryWriter return PostgreSQL::C_DATATYPE_SPECIAL_POLYGON; } - if ( preg_match( '/^\-?(\$|€|¥|£)[\d,\.]+$/', $value ) ) { + if ( preg_match( '/^\-?\$[\d,\.]+$/', $value ) ) { return PostgreSQL::C_DATATYPE_SPECIAL_MONEY; } } @@ -9219,12 +9092,12 @@ class Facade /** * @var array */ - public static $toolboxes = array(); + private static $toolboxes = array(); /** * @var ToolBox */ - public static $toolbox; + private static $toolbox; /** * @var OODB @@ -9269,18 +9142,13 @@ class Facade /** * @var string */ - public static $currentDB = ''; + private static $currentDB = ''; /** * @var array */ private static $plugins = array(); - /** - * Not in use (backward compatibility SQLHelper) - */ - public static $f; - /** * @var string */ @@ -9485,13 +9353,10 @@ class Facade $adapter = new DBAdapter( $db ); - $writers = array( - 'pgsql' => 'PostgreSQL', - 'sqlite' => 'SQLiteT', - 'cubrid' => 'CUBRID', - 'mysql' => 'MySQL', - 'sqlsrv' => 'SQLServer', - ); + $writers = array('pgsql' => 'PostgreSQL', + 'sqlite' => 'SQLiteT', + 'cubrid' => 'CUBRID', + 'mysql' => 'MySQL'); $wkey = trim( strtolower( $dbType ) ); if ( !isset( $writers[$wkey] ) ) trigger_error( 'Unsupported DSN: '.$wkey ); @@ -10707,37 +10572,6 @@ class Facade } return $list; } - - /** - * Sets the error mode for FUSE. - * What to do if a FUSE model method does not exist? - * You can set the following options: - * - * OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL - * OODBBean::C_ERR_LOG, logs the incident using error_log - * OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE - * OODBBean::C_ERR_WARN, triggers a E_USER_WARNING - * OODBBean::C_ERR_EXCEPTION, throws an exception - * OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function) - * OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR - * - * Custom handler method signature: handler( array ( - * 'message' => string - * 'bean' => OODBBean - * 'method' => string - * ) ) - * - * This method returns the old mode and handler as an array. - * - * @param integer $mode mode - * @param callable|NULL $func custom handler - * - * @return array - */ - public static function setErrorHandlingFUSE( $mode, $func = NULL ) - { - return OODBBean::setErrorHandlingFUSE( $mode, $func ); - } /** * Simple but effective debug function. @@ -11217,7 +11051,7 @@ class DuplicationManager } } - $rs = $this->duplicate( ( clone $bean ), $trail, $preserveIDs ); + $rs = $this->duplicate( clone( $bean ), $trail, $preserveIDs ); if ( !$this->cacheTables ) { $this->tables = array();