From 92d2245ca6e55a5965e638a41e815380f882d8fb Mon Sep 17 00:00:00 2001 From: Sergey Makinen Date: Fri, 21 Jul 2017 00:03:16 +0300 Subject: [PATCH 1/5] Add support for an older SQLite in constraints (fixes #14483) (#14497) --- framework/db/sqlite/Schema.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/framework/db/sqlite/Schema.php b/framework/db/sqlite/Schema.php index b217bc6..b3ffcb9 100644 --- a/framework/db/sqlite/Schema.php +++ b/framework/db/sqlite/Schema.php @@ -399,6 +399,16 @@ class Schema extends \yii\db\Schema { $indexes = $this->db->createCommand('PRAGMA INDEX_LIST (' . $this->quoteValue($tableName) . ')')->queryAll(); $indexes = $this->normalizePdoRowKeyCase($indexes, true); + $tableColumns = null; + if (!empty($indexes) && !isset($indexes[0]['origin'])) { + /* + * SQLite may not have an "origin" column in INDEX_LIST + * See https://www.sqlite.org/src/info/2743846cdba572f6 + */ + $tableColumns = $this->db->createCommand('PRAGMA TABLE_INFO (' . $this->quoteValue($tableName) . ')')->queryAll(); + $tableColumns = $this->normalizePdoRowKeyCase($tableColumns, true); + $tableColumns = ArrayHelper::index($tableColumns, 'cid'); + } $result = [ 'primaryKey' => null, 'indexes' => [], @@ -408,6 +418,15 @@ class Schema extends \yii\db\Schema $columns = $this->db->createCommand('PRAGMA INDEX_INFO (' . $this->quoteValue($index['name']) . ')')->queryAll(); $columns = $this->normalizePdoRowKeyCase($columns, true); ArrayHelper::multisort($columns, 'seqno', SORT_ASC, SORT_NUMERIC); + if ($tableColumns !== null) { + // SQLite may not have an "origin" column in INDEX_LIST + $index['origin'] = 'c'; + if (!empty($columns) && $tableColumns[$columns[0]['cid']]['pk'] > 0) { + $index['origin'] = 'pk'; + } elseif ($index['unique'] && $this->isSystemIdentifier($index['name'])) { + $index['origin'] = 'u'; + } + } $result['indexes'][] = new IndexConstraint([ 'isPrimary' => $index['origin'] === 'pk', 'isUnique' => (bool) $index['unique'], @@ -430,4 +449,15 @@ class Schema extends \yii\db\Schema } return $result[$returnType]; } + + /** + * Return whether the specified identifier is a SQLite system identifier. + * @param string $identifier + * @return bool + * @see https://www.sqlite.org/src/artifact/74108007d286232f + */ + private function isSystemIdentifier($identifier) + { + return strpos($identifier, 'sqlite_') === 0; + } } From 21d2d72534472ef361e451d6b16786573f6e72a8 Mon Sep 17 00:00:00 2001 From: Dmitry Dorogin Date: Fri, 21 Jul 2017 12:21:46 +0300 Subject: [PATCH 2/5] Fixes #14487: Changed i18n message error to warning --- framework/CHANGELOG.md | 1 + framework/i18n/PhpMessageSource.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 26625e3..6f37182 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -39,6 +39,7 @@ Yii Framework 2 Change Log - Bug #14423: Fixed `ArrayHelper::merge` behavior with null values for integer-keyed elements (dmirogin) - Bug #14406: Fixed caching rules in `yii\web\UrlManager` with different ruleConfig configuration (dmirogin) - Chg #7936: Deprecate `yii\base\Object` in favor of `yii\base\BaseObject` for compatibility with PHP 7.2 (rob006, cebe, klimov-paul) +- Chg #14487: Changed i18n message error to warning (dmirogin) 2.0.12 June 05, 2017 diff --git a/framework/i18n/PhpMessageSource.php b/framework/i18n/PhpMessageSource.php index 1e0f41d..ec4dcd1 100644 --- a/framework/i18n/PhpMessageSource.php +++ b/framework/i18n/PhpMessageSource.php @@ -80,7 +80,7 @@ class PhpMessageSource extends MessageSource $messages = $this->loadFallbackMessages($category, $this->sourceLanguage, $messages, $messageFile); } else { if ($messages === null) { - Yii::error("The message file for category '$category' does not exist: $messageFile", __METHOD__); + Yii::warning("The message file for category '$category' does not exist: $messageFile", __METHOD__); } } From acf29e000183e9cbf05705e2915190efbce15728 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 21 Jul 2017 12:49:33 +0300 Subject: [PATCH 3/5] Fixes #14492: Fixed error handler not escaping error info debug mode --- framework/CHANGELOG.md | 2 +- framework/views/errorHandler/exception.php | 2 +- framework/views/errorHandler/previousException.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 6f37182..39aa0b1 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -39,9 +39,9 @@ Yii Framework 2 Change Log - Bug #14423: Fixed `ArrayHelper::merge` behavior with null values for integer-keyed elements (dmirogin) - Bug #14406: Fixed caching rules in `yii\web\UrlManager` with different ruleConfig configuration (dmirogin) - Chg #7936: Deprecate `yii\base\Object` in favor of `yii\base\BaseObject` for compatibility with PHP 7.2 (rob006, cebe, klimov-paul) +- Bug #14492: Fixed error handler not escaping error info debug mode (samdark) - Chg #14487: Changed i18n message error to warning (dmirogin) - 2.0.12 June 05, 2017 -------------------- diff --git a/framework/views/errorHandler/exception.php b/framework/views/errorHandler/exception.php index 6de9904..5a303c7 100644 --- a/framework/views/errorHandler/exception.php +++ b/framework/views/errorHandler/exception.php @@ -373,7 +373,7 @@ body.mousedown pre {

htmlEncode($exception->getMessage())) ?>

errorInfo)): ?> -
Error Info: errorInfo, true) ?>
+
Error Info: htmlEncode(print_r($exception->errorInfo, true)) ?>
renderPreviousExceptions($exception) ?> diff --git a/framework/views/errorHandler/previousException.php b/framework/views/errorHandler/previousException.php index 59e1451..a93f59f 100644 --- a/framework/views/errorHandler/previousException.php +++ b/framework/views/errorHandler/previousException.php @@ -17,7 +17,7 @@

htmlEncode($exception->getMessage())) ?>

in getFile() ?> at line getLine() ?>

errorInfo)): ?> -
Error Info: errorInfo, true) ?>
+
Error Info: htmlEncode(print_r($exception->errorInfo, true)) ?>
renderPreviousExceptions($exception) ?> From 1f26db9fb781715a469f52ac01bed77430a53766 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 21 Jul 2017 15:42:06 +0300 Subject: [PATCH 4/5] Applied code style fixes --- framework/console/ExitCode.php | 4 ++-- framework/data/Sort.php | 2 +- framework/db/ActiveRecord.php | 2 +- framework/db/Schema.php | 2 +- framework/db/TableSchema.php | 2 +- framework/mail/BaseMessage.php | 2 +- framework/mutex/MysqlMutex.php | 4 ++-- framework/mutex/OracleMutex.php | 4 ++-- framework/mutex/PgsqlMutex.php | 8 ++++---- framework/validators/IpValidator.php | 2 +- framework/web/CookieCollection.php | 2 +- framework/web/UrlNormalizer.php | 2 +- framework/web/UrlRule.php | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/framework/console/ExitCode.php b/framework/console/ExitCode.php index ac86fd6..84cb518 100644 --- a/framework/console/ExitCode.php +++ b/framework/console/ExitCode.php @@ -127,7 +127,7 @@ class ExitCode */ public static $reasons = [ self::OK => 'Success', - self::UNSPECIFIED_ERROR => "Unspecified error", + self::UNSPECIFIED_ERROR => 'Unspecified error', self::USAGE => 'Incorrect usage, argument or option error', self::DATAERR => 'Error in input data', self::NOINPUT => 'Input file not found or unreadable', @@ -154,6 +154,6 @@ class ExitCode */ public static function getReason($exitCode) { - return isset($exReasons[$exitCode]) ? $exReasons[$exitCode] : "Unknown exit code"; + return isset($exReasons[$exitCode]) ? $exReasons[$exitCode] : 'Unknown exit code'; } } diff --git a/framework/data/Sort.php b/framework/data/Sort.php index 371bbe5..7f03266 100644 --- a/framework/data/Sort.php +++ b/framework/data/Sort.php @@ -8,8 +8,8 @@ namespace yii\data; use Yii; -use yii\base\InvalidConfigException; use yii\base\BaseObject; +use yii\base\InvalidConfigException; use yii\helpers\Html; use yii\helpers\Inflector; use yii\web\Request; diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index d820826..c73059b 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -195,7 +195,7 @@ class ActiveRecord extends BaseActiveRecord { $pk = []; // disambiguate column names in case ActiveQuery adds a JOIN - foreach($this->getPrimaryKey(true) as $key => $value) { + foreach ($this->getPrimaryKey(true) as $key => $value) { $pk[static::tableName() . '.' . $key] = $value; } /* @var $record BaseActiveRecord */ diff --git a/framework/db/Schema.php b/framework/db/Schema.php index f208aeb..e466b6b 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -8,10 +8,10 @@ namespace yii\db; use Yii; +use yii\base\BaseObject; use yii\base\InvalidCallException; use yii\base\InvalidConfigException; use yii\base\NotSupportedException; -use yii\base\BaseObject; use yii\caching\Cache; use yii\caching\CacheInterface; use yii\caching\TagDependency; diff --git a/framework/db/TableSchema.php b/framework/db/TableSchema.php index 1183398..d792a46 100644 --- a/framework/db/TableSchema.php +++ b/framework/db/TableSchema.php @@ -7,8 +7,8 @@ namespace yii\db; -use yii\base\InvalidParamException; use yii\base\BaseObject; +use yii\base\InvalidParamException; /** * TableSchema represents the metadata of a database table. diff --git a/framework/mail/BaseMessage.php b/framework/mail/BaseMessage.php index 5eeed4b..b0500c1 100644 --- a/framework/mail/BaseMessage.php +++ b/framework/mail/BaseMessage.php @@ -8,8 +8,8 @@ namespace yii\mail; use Yii; -use yii\base\ErrorHandler; use yii\base\BaseObject; +use yii\base\ErrorHandler; /** * BaseMessage serves as a base class that implements the [[send()]] method required by [[MessageInterface]]. diff --git a/framework/mutex/MysqlMutex.php b/framework/mutex/MysqlMutex.php index 4e97bb8..6bab1a2 100644 --- a/framework/mutex/MysqlMutex.php +++ b/framework/mutex/MysqlMutex.php @@ -56,7 +56,7 @@ class MysqlMutex extends DbMutex */ protected function acquireLock($name, $timeout = 0) { - return $this->db->useMaster(function($db) use ($name, $timeout) { + return $this->db->useMaster(function ($db) use ($name, $timeout) { /** @var \yii\db\Connection $db */ return (bool) $db->createCommand( 'SELECT GET_LOCK(:name, :timeout)', @@ -75,7 +75,7 @@ class MysqlMutex extends DbMutex { return $this->db->useMaster(function ($db) use ($name) { /** @var \yii\db\Connection $db */ - return (bool)$db->createCommand( + return (bool) $db->createCommand( 'SELECT RELEASE_LOCK(:name)', [':name' => $name] )->queryScalar(); diff --git a/framework/mutex/OracleMutex.php b/framework/mutex/OracleMutex.php index b9ff544..b1a776a 100644 --- a/framework/mutex/OracleMutex.php +++ b/framework/mutex/OracleMutex.php @@ -88,7 +88,7 @@ class OracleMutex extends DbMutex $timeout = abs((int) $timeout); // inside pl/sql scopes pdo binding not working correctly :( - $this->db->useMaster(function($db) use ($name, $timeout, $releaseOnCommit, &$lockStatus) { + $this->db->useMaster(function ($db) use ($name, $timeout, $releaseOnCommit, &$lockStatus) { /** @var \yii\db\Connection $db */ $db->createCommand( 'DECLARE @@ -115,7 +115,7 @@ END;', protected function releaseLock($name) { $releaseStatus = null; - $this->db->useMaster(function($db) use ($name, &$releaseStatus) { + $this->db->useMaster(function ($db) use ($name, &$releaseStatus) { /** @var \yii\db\Connection $db */ $db->createCommand( 'DECLARE diff --git a/framework/mutex/PgsqlMutex.php b/framework/mutex/PgsqlMutex.php index 430d8e5..22f09b7 100644 --- a/framework/mutex/PgsqlMutex.php +++ b/framework/mutex/PgsqlMutex.php @@ -71,9 +71,9 @@ class PgsqlMutex extends DbMutex throw new InvalidParamException('PgsqlMutex does not support timeout.'); } list($key1, $key2) = $this->getKeysFromName($name); - return $this->db->useMaster(function($db) use ($key1, $key2) { + return $this->db->useMaster(function ($db) use ($key1, $key2) { /** @var \yii\db\Connection $db */ - return (bool)$db->createCommand( + return (bool) $db->createCommand( 'SELECT pg_try_advisory_lock(:key1, :key2)', [':key1' => $key1, ':key2' => $key2] )->queryScalar(); @@ -89,9 +89,9 @@ class PgsqlMutex extends DbMutex protected function releaseLock($name) { list($key1, $key2) = $this->getKeysFromName($name); - return $this->db->useMaster(function($db) use ($key1, $key2) { + return $this->db->useMaster(function ($db) use ($key1, $key2) { /** @var \yii\db\Connection $db */ - return (bool)$db->createCommand( + return (bool) $db->createCommand( 'SELECT pg_advisory_unlock(:key1, :key2)', [':key1' => $key1, ':key2' => $key2] )->queryScalar(); diff --git a/framework/validators/IpValidator.php b/framework/validators/IpValidator.php index 72ac999..3747a48 100644 --- a/framework/validators/IpValidator.php +++ b/framework/validators/IpValidator.php @@ -569,7 +569,7 @@ class IpValidator extends Validator $unpack = unpack('A16', inet_pton($ip)); $binStr = array_shift($unpack); $bytes = static::IPV6_ADDRESS_LENGTH / 8; // 128 bit / 8 = 16 bytes - $result = ''; + $result = ''; while ($bytes-- > 0) { $result = sprintf('%08b', isset($binStr[$bytes]) ? ord($binStr[$bytes]) : '0') . $result; } diff --git a/framework/web/CookieCollection.php b/framework/web/CookieCollection.php index 6ceab61..b0e7dff 100644 --- a/framework/web/CookieCollection.php +++ b/framework/web/CookieCollection.php @@ -9,8 +9,8 @@ namespace yii\web; use ArrayIterator; use Yii; -use yii\base\InvalidCallException; use yii\base\BaseObject; +use yii\base\InvalidCallException; /** * CookieCollection maintains the cookies available in the current request. diff --git a/framework/web/UrlNormalizer.php b/framework/web/UrlNormalizer.php index 274c781..0b7c940 100644 --- a/framework/web/UrlNormalizer.php +++ b/framework/web/UrlNormalizer.php @@ -8,8 +8,8 @@ namespace yii\web; use Yii; -use yii\base\InvalidConfigException; use yii\base\BaseObject; +use yii\base\InvalidConfigException; /** * UrlNormalizer normalizes URLs for [[UrlManager]] and [[UrlRule]]. diff --git a/framework/web/UrlRule.php b/framework/web/UrlRule.php index afa1933..f59a655 100644 --- a/framework/web/UrlRule.php +++ b/framework/web/UrlRule.php @@ -8,8 +8,8 @@ namespace yii\web; use Yii; -use yii\base\InvalidConfigException; use yii\base\BaseObject; +use yii\base\InvalidConfigException; /** * UrlRule represents a rule used by [[UrlManager]] for parsing and generating URLs. From 462b5f5b50572e5c5d6e85a63981499429075a4f Mon Sep 17 00:00:00 2001 From: Robert Korulczyk Date: Fri, 21 Jul 2017 18:05:57 +0200 Subject: [PATCH 5/5] Use new trusty images on travis (#14508) This should fix "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'" errors. --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index fcf48ea..843288c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,10 @@ dist: trusty # faster builds on new travis setup not using sudo -sudo: false +# temporary disable, see https://github.com/travis-ci/travis-ci/issues/6842 +#sudo: false +sudo: required +group: edge # build only on master branches # commented as this prevents people from running builds on their forks: @@ -67,8 +70,6 @@ matrix: # Test against HHVM 3.12 LTS version by using trusty - php: hhvm-3.12 sudo: true - dist: trusty - group: edge # Use edge image until the next travis CI image update addons: code_climate: repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b @@ -83,8 +84,6 @@ matrix: # test against the latest HHVM version by using a newer image - php: hhvm sudo: true - dist: trusty - group: edge # Use edge image until the next travis CI image update addons: code_climate: repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b @@ -104,7 +103,6 @@ matrix: - language: node_js node_js: 6 env: TASK_TESTS_PHP=0 TASK_TESTS_JS=1 - dist: trusty # overwrite services used for PHP tests services: