From 7dfa23ec9172dfda1346d188d009f16861ae69c7 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 7 Nov 2018 22:17:51 +0200 Subject: [PATCH 01/23] Use latest Zephir Parser --- .travis.yml | 2 +- appveyor.yml | 4 ++-- tests/_ci/install-zephir-parser.sh | 35 ++++++++++-------------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc40c3b5501..c02b9e3861a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ services: env: global: - CC="gcc" - - ZEPHIR_PARSER_VERSION="v1.1.2" + - ZEPHIR_PARSER_VERSION="development" - ZEPHIR_VERSION="0.10.12" - RE2C_VERSION="1.1.1" - REPORT_EXIT_STATUS=1 diff --git a/appveyor.yml b/appveyor.yml index 37548297ade..f03bc1651d6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,8 +38,8 @@ environment: NO_INTERACTION: 1 REPORT_EXIT_STATUS: 1 COMPOSER_NO_INTERACTION: 1 - PARSER_VERSION: 1.1.2 - PARSER_RELEASE: 290 + PARSER_VERSION: 1.1.3 + PARSER_RELEASE: 401 PHALCON_STABLE_VERSION: 3.3.2 PSR_PECL_VERSION: 0.5.1 ZEPHIR_VERSION: 0.10.12 diff --git a/tests/_ci/install-zephir-parser.sh b/tests/_ci/install-zephir-parser.sh index 04c4a60d3d5..a6d5f58da71 100755 --- a/tests/_ci/install-zephir-parser.sh +++ b/tests/_ci/install-zephir-parser.sh @@ -7,33 +7,22 @@ # For the full copyright and license information, please view the LICENSE.txt # file that was distributed with this source code. -ZEPHIR_PARSER_VERSION=${ZEPHIR_PARSER_VERSION:-development} -PHP_MAJOR=`$(phpenv which php-config) --version | cut -d '.' -f 1,2` - -LOCAL_SRC_DIR=${HOME}/.cache/zephir-parser/src -LOCAL_LIB_DIR=${HOME}/.local/lib -LOCAL_LIBRARY=${LOCAL_LIB_DIR}/zephir-parser-${ZEPHIR_PARSER_VERSION}-${PHP_MAJOR}.so - -EXTENSION_DIR=`$(phpenv which php-config) --extension-dir` +# Exit the script if any statement returns a non-true return value +set -e -if [ ! -f ${LOCAL_LIBRARY} ]; then - mkdir -p ${LOCAL_SRC_DIR} - mkdir -p ${LOCAL_LIB_DIR} - - rm -rf ${LOCAL_SRC_DIR}/* - git clone --depth=1 -v https://github.com/phalcon/php-zephir-parser.git -b ${ZEPHIR_PARSER_VERSION} ${LOCAL_SRC_DIR} +ZEPHIR_PARSER_VERSION=${ZEPHIR_PARSER_VERSION:-development} - bash ${LOCAL_SRC_DIR}/install +pushd /tmp - if [ ! -f "${EXTENSION_DIR}/zephir_parser.so" ]; then - echo "Unable to locate installed zephir_parser.so" - exit 1 - fi +git clone --depth=1 -v https://github.com/phalcon/php-zephir-parser.git -b ${ZEPHIR_PARSER_VERSION} +cd php-zephir-parser +phpize +./configure +make +make install - cp "${EXTENSION_DIR}/zephir_parser.so" ${LOCAL_LIBRARY} -fi +popd -echo "[Zephir Parser]" > ${HOME}/.phpenv/versions/$(phpenv version-name)/etc/conf.d/zephir-parser.ini -echo "extension=${LOCAL_LIBRARY}" >> ${HOME}/.phpenv/versions/$(phpenv version-name)/etc/conf.d/zephir-parser.ini +echo "extension=zephir_parser.so" >> $(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/zephir-parser.ini php --ri 'Zephir Parser' From 659d5b13572b641e2140035b7563f893481e0cf9 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Thu, 8 Nov 2018 17:14:17 +1100 Subject: [PATCH 02/23] Updated stale to not close issues labelled as bugs Issues shouldn't be marked as stale if they're confirmed bugs. --- .github/stale.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/stale.yml b/.github/stale.yml index dfedb856483..6e5a4cb9b89 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -9,6 +9,9 @@ daysUntilClose: 1 # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable exemptLabels: + - "Bug - Low" + - "Bug - Medium" + - "Bug - High" - WIP - Locked From de1c12fdebb5117d1a12081b02e90d9ab82f971c Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Thu, 8 Nov 2018 09:28:19 +1100 Subject: [PATCH 03/23] Fixed RawValue objects being prepared instead of inserted Wrote unit tests for issue #13058 Update CHANGELOG-3.4.md Fixed an issue with unit test. --- CHANGELOG-3.4.md | 10 ++++++++++ composer.json | 3 ++- phalcon/db/adapter.zep | 15 +++++++++++---- tests/_data/db/DateTime.php | 11 +++++++++++ tests/unit/Mvc/ModelTest.php | 22 ++++++++++++++++++++++ 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 tests/_data/db/DateTime.php diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index c93adc0bbd5..11266abe520 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -1,5 +1,15 @@ # [3.4.2](https://github.com/phalcon/cphalcon/releases/tag/v3.4.2) (2018-XX-XX) - Fixed `Phalcon\Validation\Validator\Numericality` to accept float numbers on locales with comma decimal point [#13450](https://github.com/phalcon/cphalcon/issues/13450) +- Added missing Volt tags to array helper in `Phalcon\Mvc\View\Engine\Volt\Compiler::functionCall` [#13447](https://github.com/phalcon/cphalcon/issues/13447) +- Added the ability to explicitly define nullable columns (especially timestamp ones). [#13099](https://github.com/phalcon/cphalcon/issues/13099) +- Refactored `Phalcon\Db\Adapter\Pdo::query` to use PDO's prepare and execute. `Phalcon\Db\Adapter::fetchAll` to use PDO's fetchAll +- Fixed `Phalcon\Validation\Validator\Numericality` to accept float numbers on locales with comma decimal point [#13450](https://github.com/phalcon/cphalcon/issues/13450) +- Fixed `Phalcon\Tag` so it unsets `parameters` before passing options array to `self::renderAttributes` +- Fixed `Phalcon\Http\Response::setFileToSend` filename; when file downloaded it had an extra `_` +- Fixed `Phalcon\Mvc\Model\Query::execute` to properly bind parameters to sub queries [#11605](https://github.com/phalcon/cphalcon/issues/11605) +- Fixed `Phalcon\Http\Request::getJsonRawBody` [#13501](https://github.com/phalcon/cphalcon/issues/13501). It will now return false when the body content is empty, as well as when it encounters an error whilst decoding the JSON content. +- Fixed `Phalcon\Validation::preChecking` to allow use `Phalcon\Db\RawValue` as an empty container for `isAllowEmpty` option [#13549](https://github.com/phalcon/cphalcon/pull/13549), [#13573](https://github.com/phalcon/cphalcon/issues/13573), [#12519](https://github.com/phalcon/cphalcon/pull/12519) +- Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058). # [3.4.1](https://github.com/phalcon/cphalcon/releases/tag/v3.4.1) (2018-08-04) - Changed `Phalcon\Cache\Backend\Redis` to support connection timeout parameter diff --git a/composer.json b/composer.json index 6ea32739413..dca976c756b 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,8 @@ "Phalcon\\Test\\Unit\\": "tests/unit/", "Phalcon\\Test\\Integration\\": "tests/integration/", "Phalcon\\Test\\Module\\": "tests/_support/Module/", - "Phalcon\\Test\\Listener\\": "tests/_data/listener/" + "Phalcon\\Test\\Listener\\": "tests/_data/listener/", + "Phalcon\\Test\\Db\\": "tests/_data/db/" } }, "support": { diff --git a/phalcon/db/adapter.zep b/phalcon/db/adapter.zep index 26eacdd8761..40624566b72 100644 --- a/phalcon/db/adapter.zep +++ b/phalcon/db/adapter.zep @@ -692,9 +692,13 @@ abstract class Adapter implements AdapterInterface, EventsAwareInterface * Objects are casted using __toString, null values are converted to string "null", everything else is passed as "?" */ for position, value in values { - if typeof value == "object" { + if typeof value == "object" && value instanceof RawValue { let placeholders[] = (string) value; } else { + if typeof value == "object" { + let value = (string) value; + } + if typeof value == "null" { let placeholders[] = "null"; } else { @@ -1022,10 +1026,13 @@ abstract class Adapter implements AdapterInterface, EventsAwareInterface } let escapedField = this->escapeIdentifier(field); - - if typeof value == "object" { - let placeholders[] = escapedField . " = " . value; + if typeof value == "object" && value instanceof RawValue { + let placeholders[] = escapedField . " = " . (string) value; } else { + if typeof value == "object" { + let value = (string) value; + } + if typeof value == "null" { let placeholders[] = escapedField . " = null"; } else { diff --git a/tests/_data/db/DateTime.php b/tests/_data/db/DateTime.php new file mode 100644 index 00000000000..9f895724d8a --- /dev/null +++ b/tests/_data/db/DateTime.php @@ -0,0 +1,11 @@ +format('Y-m-d H:i:s'); + } +} diff --git a/tests/unit/Mvc/ModelTest.php b/tests/unit/Mvc/ModelTest.php index eede90c8e45..5fd1016afb5 100644 --- a/tests/unit/Mvc/ModelTest.php +++ b/tests/unit/Mvc/ModelTest.php @@ -897,4 +897,26 @@ function () { } ); } + + /** + * Tests binding of non-scalar values by casting to string and binding them. + * + * @issue https://github.com/phalcon/cphalcon/issues/13058 + * @author Cameron Hall + * @since 2018-11-06 + */ + public function testIssue13058() + { + $this->specify( + 'Issue 13058 is happening, non-scalar values are not being casted and bound.', + function () { + $robots = new Robots(); + $robots->name = ''; + $robots->datetime = new \Phalcon\Test\Db\DateTime(); + $robots->text = 'text'; + $result = $robots->save(); + expect($result)->true(); + } + ); + } } From 6766951396d2a097a80a7fba7ba2be0ff3741b4b Mon Sep 17 00:00:00 2001 From: David Schissler Date: Sun, 11 Nov 2018 00:55:42 -0800 Subject: [PATCH 04/23] Remove name property from Service. --- phalcon/di.zep | 13 ++++-- .../exception/serviceresolutionexception.zep | 26 ++++++++++++ phalcon/di/factorydefault.zep | 42 +++++++++---------- phalcon/di/factorydefault/cli.zep | 20 ++++----- phalcon/di/service.zep | 26 +++--------- phalcon/di/serviceinterface.zep | 5 --- 6 files changed, 72 insertions(+), 60 deletions(-) create mode 100644 phalcon/di/exception/serviceresolutionexception.zep diff --git a/phalcon/di.zep b/phalcon/di.zep index 8ff46130013..1ba72916018 100644 --- a/phalcon/di.zep +++ b/phalcon/di.zep @@ -20,6 +20,7 @@ use Phalcon\Config; use Phalcon\Di\Service; use Phalcon\DiInterface; use Phalcon\Di\Exception; +use Phalcon\Di\Exception\ServiceResolutionException; use Phalcon\Config\Adapter\Php; use Phalcon\Config\Adapter\Yaml; use Phalcon\Di\ServiceInterface; @@ -127,7 +128,7 @@ class Di implements DiInterface public function set(string! name, var definition, boolean shared = false) -> { var service; - let service = new Service(name, definition, shared), + let service = new Service(definition, shared), this->_services[name] = service; return service; } @@ -160,7 +161,7 @@ class Di implements DiInterface var service; if !isset this->_services[name] { - let service = new Service(name, definition, shared), + let service = new Service(definition, shared), this->_services[name] = service; return service; } @@ -210,7 +211,7 @@ class Di implements DiInterface */ public function get(string! name, parameters = null) -> var { - var service, eventsManager, instance = null; + var service, eventsManager, instance = null, e; let eventsManager = this->_eventsManager; @@ -227,7 +228,11 @@ class Di implements DiInterface /** * The service is registered in the DI */ - let instance = service->resolve(parameters, this); + try { + let instance = service->resolve(parameters, this); + } catch ServiceResolutionException, e { + throw new Exception("Service '" . name . "' cannot be resolved"); + } } else { /** * The DI also acts as builder for any class even if it isn't defined in the DI diff --git a/phalcon/di/exception/serviceresolutionexception.zep b/phalcon/di/exception/serviceresolutionexception.zep new file mode 100644 index 00000000000..a325331a9ab --- /dev/null +++ b/phalcon/di/exception/serviceresolutionexception.zep @@ -0,0 +1,26 @@ +/* + +------------------------------------------------------------------------+ + | Phalcon Framework | + +------------------------------------------------------------------------+ + | Copyright (c) 2011-2018 Phalcon Team (https://phalconphp.com) | + +------------------------------------------------------------------------+ + | This source file is subject to the New BSD License that is bundled | + | with this package in the file LICENSE.txt. | + | | + | If you did not receive a copy of the license and are unable to | + | obtain it through the world-wide-web, please send an email | + | to license@phalconphp.com so we can send you a copy immediately. | + +------------------------------------------------------------------------+ + */ + +namespace Phalcon\Di\Exception; + +use Phalcon\Di\Exception\ServiceResolutionException; + +/** + * Phalcon\Di\Exception\ServiceResolutionException + * + */ +class ServiceResolutionException extends \Phalcon\Di\Exception +{ +} \ No newline at end of file diff --git a/phalcon/di/factorydefault.zep b/phalcon/di/factorydefault.zep index 0e31395b9f6..319640bd47c 100644 --- a/phalcon/di/factorydefault.zep +++ b/phalcon/di/factorydefault.zep @@ -37,27 +37,27 @@ class FactoryDefault extends \Phalcon\Di parent::__construct(); let this->_services = [ - "router": new Service("router", "Phalcon\\Mvc\\Router", true), - "dispatcher": new Service("dispatcher", "Phalcon\\Mvc\\Dispatcher", true), - "url": new Service("url", "Phalcon\\Mvc\\Url", true), - "modelsManager": new Service("modelsManager", "Phalcon\\Mvc\\Model\\Manager", true), - "modelsMetadata": new Service("modelsMetadata", "Phalcon\\Mvc\\Model\\MetaData\\Memory", true), - "response": new Service("response", "Phalcon\\Http\\Response", true), - "cookies": new Service("cookies", "Phalcon\\Http\\Response\\Cookies", true), - "request": new Service("request", "Phalcon\\Http\\Request", true), - "filter": new Service("filter", "Phalcon\\Filter", true), - "escaper": new Service("escaper", "Phalcon\\Escaper", true), - "security": new Service("security", "Phalcon\\Security", true), - "crypt": new Service("crypt", "Phalcon\\Crypt", true), - "annotations": new Service("annotations", "Phalcon\\Annotations\\Adapter\\Memory", true), - "flash": new Service("flash", "Phalcon\\Flash\\Direct", true), - "flashSession": new Service("flashSession", "Phalcon\\Flash\\Session", true), - "tag": new Service("tag", "Phalcon\\Tag", true), - "session": new Service("session", "Phalcon\\Session\\Adapter\\Files", true), - "sessionBag": new Service("sessionBag", "Phalcon\\Session\\Bag"), - "eventsManager": new Service("eventsManager", "Phalcon\\Events\\Manager", true), - "transactionManager": new Service("transactionManager", "Phalcon\\Mvc\\Model\\Transaction\\Manager", true), - "assets": new Service("assets", "Phalcon\\Assets\\Manager", true) + "router": new Service("Phalcon\\Mvc\\Router", true), + "dispatcher": new Service("Phalcon\\Mvc\\Dispatcher", true), + "url": new Service("Phalcon\\Mvc\\Url", true), + "modelsManager": new Service("Phalcon\\Mvc\\Model\\Manager", true), + "modelsMetadata": new Service("Phalcon\\Mvc\\Model\\MetaData\\Memory", true), + "response": new Service("Phalcon\\Http\\Response", true), + "cookies": new Service("Phalcon\\Http\\Response\\Cookies", true), + "request": new Service("Phalcon\\Http\\Request", true), + "filter": new Service("Phalcon\\Filter", true), + "escaper": new Service("Phalcon\\Escaper", true), + "security": new Service("Phalcon\\Security", true), + "crypt": new Service("Phalcon\\Crypt", true), + "annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", true), + "flash": new Service("Phalcon\\Flash\\Direct", true), + "flashSession": new Service("Phalcon\\Flash\\Session", true), + "tag": new Service("Phalcon\\Tag", true), + "session": new Service("Phalcon\\Session\\Adapter\\Files", true), + "sessionBag": new Service("Phalcon\\Session\\Bag"), + "eventsManager": new Service("Phalcon\\Events\\Manager", true), + "transactionManager": new Service("Phalcon\\Mvc\\Model\\Transaction\\Manager", true), + "assets": new Service("Phalcon\\Assets\\Manager", true) ]; } } diff --git a/phalcon/di/factorydefault/cli.zep b/phalcon/di/factorydefault/cli.zep index fe222ad15df..b116d11466d 100644 --- a/phalcon/di/factorydefault/cli.zep +++ b/phalcon/di/factorydefault/cli.zep @@ -41,16 +41,16 @@ class Cli extends FactoryDefault parent::__construct(); let this->_services = [ - "router": new Service("router", "Phalcon\\Cli\\Router", true), - "dispatcher": new Service("dispatcher", "Phalcon\\Cli\\Dispatcher", true), - "modelsManager": new Service("modelsManager", "Phalcon\\Mvc\\Model\\Manager", true), - "modelsMetadata": new Service("modelsMetadata", "Phalcon\\Mvc\\Model\\MetaData\\Memory", true), - "filter": new Service("filter", "Phalcon\\Filter", true), - "escaper": new Service("escaper", "Phalcon\\Escaper", true), - "annotations": new Service("annotations", "Phalcon\\Annotations\\Adapter\\Memory", true), - "security": new Service("security", "Phalcon\\Security", true), - "eventsManager": new Service("eventsManager", "Phalcon\\Events\\Manager", true), - "transactionManager": new Service("transactionManager", "Phalcon\\Mvc\\Model\\Transaction\\Manager", true) + "router": new Service("Phalcon\\Cli\\Router", true), + "dispatcher": new Service("Phalcon\\Cli\\Dispatcher", true), + "modelsManager": new Service("Phalcon\\Mvc\\Model\\Manager", true), + "modelsMetadata": new Service("Phalcon\\Mvc\\Model\\MetaData\\Memory", true), + "filter": new Service("Phalcon\\Filter", true), + "escaper": new Service("Phalcon\\Escaper", true), + "annotations": new Service("Phalcon\\Annotations\\Adapter\\Memory", true), + "security": new Service("Phalcon\\Security", true), + "eventsManager": new Service("Phalcon\\Events\\Manager", true), + "transactionManager": new Service("Phalcon\\Mvc\\Model\\Transaction\\Manager", true) ]; } } diff --git a/phalcon/di/service.zep b/phalcon/di/service.zep index 997dd4e0501..66e3fecc2b8 100644 --- a/phalcon/di/service.zep +++ b/phalcon/di/service.zep @@ -21,6 +21,7 @@ namespace Phalcon\Di; use Phalcon\DiInterface; use Phalcon\Di\Exception; +use Phalcon\Di\Exception\ServiceResolutionException; use Phalcon\Di\ServiceInterface; use Phalcon\Di\Service\Builder; @@ -41,8 +42,6 @@ use Phalcon\Di\Service\Builder; class Service implements ServiceInterface { - protected _name; - protected _definition; protected _shared = false; @@ -56,21 +55,12 @@ class Service implements ServiceInterface * * @param mixed definition */ - public final function __construct(string! name, definition, boolean shared = false) + public final function __construct(definition, boolean shared = false) { - let this->_name = name, - this->_definition = definition, + let this->_definition = definition, this->_shared = shared; } - /** - * Returns the service's name - */ - public function getName() -> string - { - return this->_name; - } - /** * Sets if the service is shared or not */ @@ -201,8 +191,8 @@ class Service implements ServiceInterface /** * If the service can't be built, we must throw an exception */ - if found === false { - throw new Exception("Service '" . this->_name . "' cannot be resolved"); + if found === false { + throw new ServiceResolutionException(); } /** @@ -292,10 +282,6 @@ class Service implements ServiceInterface { var name, definition, shared; - if !fetch name, attributes["_name"] { - throw new Exception("The attribute '_name' is required"); - } - if !fetch definition, attributes["_definition"] { throw new Exception("The attribute '_definition' is required"); } @@ -304,6 +290,6 @@ class Service implements ServiceInterface throw new Exception("The attribute '_shared' is required"); } - return new self(name, definition, shared); + return new self(definition, shared); } } diff --git a/phalcon/di/serviceinterface.zep b/phalcon/di/serviceinterface.zep index 4d436c26ece..74083be2ef6 100644 --- a/phalcon/di/serviceinterface.zep +++ b/phalcon/di/serviceinterface.zep @@ -28,11 +28,6 @@ use Phalcon\DiInterface; */ interface ServiceInterface { - /** - * Returns the service's name - */ - public function getName() -> string; - /** * Sets if the service is shared or not */ From 68a8ce9a7ff46b56ab0ffecddfd28a63513d59bd Mon Sep 17 00:00:00 2001 From: David Schissler Date: Sun, 11 Nov 2018 00:56:05 -0800 Subject: [PATCH 05/23] Remove name property from Service. --- tests/unit/DiTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/DiTest.php b/tests/unit/DiTest.php index b1ad3bab490..1af3e23dbae 100644 --- a/tests/unit/DiTest.php +++ b/tests/unit/DiTest.php @@ -257,13 +257,11 @@ public function testGetServices() function () { $expectedServices = [ 'service1' => Service::__set_state([ - '_name' => 'service1', '_definition' => 'some-service', '_shared' => false, '_sharedInstance' => null, ]), 'service2' => Service::__set_state([ - '_name' => 'service2', '_definition' => 'some-other-service', '_shared' => false, '_sharedInstance' => null, From 138dab611a3b05e421ba1422d1087f3c6a6d7f4e Mon Sep 17 00:00:00 2001 From: David Schissler Date: Mon, 12 Nov 2018 05:48:06 -0800 Subject: [PATCH 06/23] Add changelog entry. --- CHANGELOG-4.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index a4ef0664e32..c63bb96c763 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -34,6 +34,7 @@ - Refactored `Phalcon\Db\Adapter\Pdo::query` to use PDO's prepare and execute. `Phalcon\Db\Adapter::fetchAll` to use PDO's fetchAll - Fixed `\Phalcon\Http\Response::setFileToSend` filename last much _ - Changed `Phalcon\Tag::getTitle()`. It returns only the text. It accepts `prepend`, `append` booleans to prepend or append the relevant text to the title. [#13547](https://github.com/phalcon/cphalcon/issues/13547) +- Changed `Phalcon\Di\Service` constructor to no longer takes the name of the service. ## Removed - PHP < 7.0 no longer supported From a27fec362a5c3d8f10bf6d078c06f63cf46eed2f Mon Sep 17 00:00:00 2001 From: Hristomir Kotzev Date: Tue, 13 Nov 2018 21:36:56 +0200 Subject: [PATCH 07/23] add offset to query builder --- CHANGELOG-4.0.md | 1 + phalcon/mvc/model/query/builder.zep | 2 +- phalcon/mvc/model/query/builderinterface.zep | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index c63bb96c763..a7a5465d5b4 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -14,6 +14,7 @@ - Added `Phalcon\Tag::renderTitle()` that renders the title enclosed in `` tags. [#13547](https://github.com/phalcon/cphalcon/issues/13547) - Added `hasHeader()` method to `Phalcon\Http\Response` to provide the ability to check if a header exists. [PR-12189](https://github.com/phalcon/cphalcon/pull/12189) - Added global setting `orm.case_insensitive_column_map` to attempt to find value in the column map case-insensitively. Can be also enabled by setting `caseInsensitiveColumnMap` key in `\Phalcon\Mvc\Model::setup()`. [#11802](https://github.com/phalcon/cphalcon/pull/11802) +- Query Builder Interface has offset property now ## Changed - By configuring `prefix` and `statsKey` the `Phalcon\Cache\Backend\Redis::queryKeys` no longer returns prefixed keys, now it returns original keys without prefix. [PR-13456](https://github.com/phalcon/cphalcon/pull/13456) diff --git a/phalcon/mvc/model/query/builder.zep b/phalcon/mvc/model/query/builder.zep index 5f843214b1c..056794ba839 100644 --- a/phalcon/mvc/model/query/builder.zep +++ b/phalcon/mvc/model/query/builder.zep @@ -930,7 +930,7 @@ class Builder implements BuilderInterface, InjectionAwareInterface * $builder->offset(30); *</code> */ - public function offset(int offset) -> <Builder> + public function offset(int offset) -> <BuilderInterface> { let this->_offset = offset; return this; diff --git a/phalcon/mvc/model/query/builderinterface.zep b/phalcon/mvc/model/query/builderinterface.zep index ab3e22b5798..6c694f305c2 100644 --- a/phalcon/mvc/model/query/builderinterface.zep +++ b/phalcon/mvc/model/query/builderinterface.zep @@ -197,4 +197,9 @@ interface BuilderInterface */ public function getQuery() -> <QueryInterface>; + /** + * Sets an OFFSET clause + */ + public function offset(int offset) -> <BuilderInterface>; + } From f310e79e482ba338c98819a091724f023aed215d Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <sergeyklay@users.noreply.github.com> Date: Wed, 14 Nov 2018 09:50:46 +0200 Subject: [PATCH 08/23] Update CHANGELOG-4.0.md Co-Authored-By: Izopi4a <izopi4a@gmail.com> --- CHANGELOG-4.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index a7a5465d5b4..3d433c32169 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -14,7 +14,7 @@ - Added `Phalcon\Tag::renderTitle()` that renders the title enclosed in `<title>` tags. [#13547](https://github.com/phalcon/cphalcon/issues/13547) - Added `hasHeader()` method to `Phalcon\Http\Response` to provide the ability to check if a header exists. [PR-12189](https://github.com/phalcon/cphalcon/pull/12189) - Added global setting `orm.case_insensitive_column_map` to attempt to find value in the column map case-insensitively. Can be also enabled by setting `caseInsensitiveColumnMap` key in `\Phalcon\Mvc\Model::setup()`. [#11802](https://github.com/phalcon/cphalcon/pull/11802) -- Query Builder Interface has offset property now +- Added `Phalcon\Mvc\Model\Query\BuilderInterface::offset` [#13599](https://github.com/phalcon/cphalcon/pull/13599) ## Changed - By configuring `prefix` and `statsKey` the `Phalcon\Cache\Backend\Redis::queryKeys` no longer returns prefixed keys, now it returns original keys without prefix. [PR-13456](https://github.com/phalcon/cphalcon/pull/13456) From 9be6bd98b7188a773781250a34727e02e8c04bf6 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Wed, 14 Nov 2018 01:36:20 +0200 Subject: [PATCH 09/23] Update build/test deps for Travis CI --- .travis.yml | 36 +++++++++++++----------------- tests/_ci/install-prereqs.sh | 9 ++++---- tests/_ci/install-zephir-parser.sh | 28 ----------------------- tests/_ci/precompile-headers.sh | 6 +---- 4 files changed, 20 insertions(+), 59 deletions(-) delete mode 100755 tests/_ci/install-zephir-parser.sh diff --git a/.travis.yml b/.travis.yml index c02b9e3861a..1557722d47d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ -language: php - -dist: trusty sudo: false +language: php php: - 'master' - '7.3' @@ -39,7 +37,6 @@ cache: - ${HOME}/.composer/cache - ${HOME}/pear - ${HOME}/.local/opt - - ${HOME}/.cache/composer services: - beanstalkd @@ -50,44 +47,41 @@ services: env: global: - CC="gcc" - - ZEPHIR_PARSER_VERSION="development" - ZEPHIR_VERSION="0.10.12" - RE2C_VERSION="1.1.1" - REPORT_EXIT_STATUS=1 - NO_INTERACTION=1 - TEST_PHP_ARGS="--show-diff" - CFLAGS="-g -O0 -Wall -std=gnu90" - - PATH="${HOME}/bin:${PATH}" + - PATH="${HOME}/bin:${HOME}/.composer/vendor/bin:${PATH}" - DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest" before_install: - '[[ -z "${GH_TOKEN}" ]] || composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"' - - export PHP_MAJOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 1)" - - export PHP_MINOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 2)" - - export PHP_VERNUM="$(`phpenv which php-config` --vernum)" + - export PHP_MAJOR="$(php -r 'echo phpversion();' | cut -d '.' -f 1)" + - export PHP_MINOR="$(php -r 'echo phpversion();' | cut -d '.' -f 2)" + - export PHP_VERNUM="$(php-config --vernum)" - ./tests/_ci/pear-setup.sh - ./tests/_ci/setup-dbs.sh - - source "${TRAVIS_BUILD_DIR}/tests/_ci/environment" - - export $(cut -d= -f1 ${TRAVIS_BUILD_DIR}/tests/_ci/environment) + - source ./tests/_ci/environment + - export $(cut -d= -f1 ./tests/_ci/environment) install: - ./tests/_ci/install-prereqs.sh - - travis_retry composer install ${DEFAULT_COMPOSER_FLAGS} - - travis_retry composer global require "phalcon/zephir:${ZEPHIR_VERSION}" - - ( cd ${HOME}/.composer/vendor/phalcon/zephir; ./install-nosudo ) - ./tests/_ci/install-re2c.sh - - ./tests/_ci/install-zephir-parser.sh + - travis_retry composer install ${DEFAULT_COMPOSER_FLAGS} + - travis_retry composer global require ${DEFAULT_COMPOSER_FLAGS} "phalcon/zephir:${ZEPHIR_VERSION}" - zephir generate - ./tests/_ci/precompile-headers.sh - | - cd "${TRAVIS_BUILD_DIR}/ext" - $(phpenv which phpize) + cd ext + phpize ./configure --with-php-config=$(phpenv which php-config) --enable-phalcon - make -j"$(getconf _NPROCESSORS_ONLN)" > "${TRAVIS_BUILD_DIR}/compile.log" 2> "${TRAVIS_BUILD_DIR}/compile-errors.log" + make -j"$(getconf _NPROCESSORS_ONLN)" > /dev/null 2> ../compile-errors.log make install - cd "${TRAVIS_BUILD_DIR}" - - phpenv config-add "${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini" - - phpenv config-add "${TRAVIS_BUILD_DIR}/tests/_ci/ci.ini" + cd .. + - phpenv config-add ./tests/_ci/phalcon.ini + - phpenv config-add ./tests/_ci/ci.ini before_script: - ulimit -c unlimited -S || true diff --git a/tests/_ci/install-prereqs.sh b/tests/_ci/install-prereqs.sh index 85810f63f7c..e4014abce10 100755 --- a/tests/_ci/install-prereqs.sh +++ b/tests/_ci/install-prereqs.sh @@ -7,14 +7,13 @@ # For the full copyright and license information, please view the LICENSE.txt # file that was distributed with this source code. -PHP_MAJOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 1)" -PHP_MINOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 2)" PHP_VERNUM="$(`phpenv which php-config` --vernum)" printf "\n" | pecl install --force apcu_bc &> /dev/null printf "\n" | pecl install --force igbinary &> /dev/null printf "\n" | pecl install --force imagick &> /dev/null printf "\n" | pecl install --force psr &> /dev/null +printf "\n" | pecl install --force yaml-2.0.3 &> /dev/null # See https://pear.php.net/bugs/bug.php?id=21007 sed -i '1s/^/extension="apcu.so"\n/' "$(phpenv root)/versions/$(phpenv version-name)/etc/php.ini" @@ -74,10 +73,10 @@ install_ext_from_src () { echo "extension=${libdir}/${pkgname}.so" > "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/${pkgname}.ini" } +install_ext_from_src "zephir_parser" "https://github.com/phalcon/php-zephir-parser" "" + if [ "${PHP_VERNUM}" -ge 70300 ]; then install_ext_from_src "memcached" "https://github.com/php-memcached-dev/php-memcached" "--disable-memcached-sasl" - install_ext_from_src "yaml" "https://github.com/php/pecl-file_formats-yaml" "" else - printf "\n" | pecl install --force yaml-2.0.0 &> /dev/null - echo 'extension="memcached.so"' >> "$(phpenv root)/versions/$(phpenv version-name)/etc/php.ini" + echo 'extension="memcached.so"' > "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/memcached.ini" fi diff --git a/tests/_ci/install-zephir-parser.sh b/tests/_ci/install-zephir-parser.sh deleted file mode 100755 index a6d5f58da71..00000000000 --- a/tests/_ci/install-zephir-parser.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# -# This file is part of the Phalcon. -# -# (c) Phalcon Team <team@phalconphp.com> -# -# For the full copyright and license information, please view the LICENSE.txt -# file that was distributed with this source code. - -# Exit the script if any statement returns a non-true return value -set -e - -ZEPHIR_PARSER_VERSION=${ZEPHIR_PARSER_VERSION:-development} - -pushd /tmp - -git clone --depth=1 -v https://github.com/phalcon/php-zephir-parser.git -b ${ZEPHIR_PARSER_VERSION} -cd php-zephir-parser -phpize -./configure -make -make install - -popd - -echo "extension=zephir_parser.so" >> $(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/zephir-parser.ini - -php --ri 'Zephir Parser' diff --git a/tests/_ci/precompile-headers.sh b/tests/_ci/precompile-headers.sh index 158c5463f5c..e9ce90bd394 100755 --- a/tests/_ci/precompile-headers.sh +++ b/tests/_ci/precompile-headers.sh @@ -12,10 +12,6 @@ if [ -z "${CC}" ]; then exit 0 fi -PROJECT_ROOT=$(readlink -enq "$(dirname $0)/../../") - -cd ${PROJECT_ROOT} - echo "Creating precompiled headers..." if [ "${CC:0:5}" = "clang" ]; then _ext="pch" @@ -31,5 +27,5 @@ fi # will be used. For more see: http://en.wikipedia.org/wiki/Precompiled_header for file in `find ./ext/kernel -name "*.h"`; do printf "\t>>> ${file}\n\t<<< ${file}.ghc\n" - ${CC} ${_arg} "${file}" -I. -I${PROJECT_ROOT}/ext $(php-config --includes) ${_option} -o "${file}.${_ext}" + ${CC} ${_arg} "${file}" -I. -I./ext $(php-config --includes) ${_option} -o "${file}.${_ext}" done From 0bb519fd74da7e092d8e0066416d2b0aa0605d10 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Wed, 14 Nov 2018 01:52:42 +0200 Subject: [PATCH 10/23] Update build/test deps for AppVeyor --- appveyor.yml | 2 - tests/_ci/appveyor.psm1 | 89 ++++++++++++++++------------------------- 2 files changed, 34 insertions(+), 57 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f03bc1651d6..1e413728cfb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,7 +66,6 @@ branches: - 3.4.x install: - - git submodule update --init --recursive - ps: Import-Module .\tests\_ci\appveyor.psm1 - ps: AppendSessionPath - ps: SetupPhpVersionString @@ -78,7 +77,6 @@ install: - ps: InstallPsrExtension - ps: InstallStablePhalcon - ps: InstallParser - - ps: InstallZephir - ps: TuneUpPhp build_script: diff --git a/tests/_ci/appveyor.psm1 b/tests/_ci/appveyor.psm1 index d05cd16a248..0956240787b 100644 --- a/tests/_ci/appveyor.psm1 +++ b/tests/_ci/appveyor.psm1 @@ -51,53 +51,40 @@ Function FormatReleaseFiles { Set-Location "${Env:APPVEYOR_BUILD_FOLDER}" Get-ChildItem (Get-Item -Path ".\" -Verbose).FullName *.md | - ForEach-Object{ + ForEach-Object { $BaseName = $_.BaseName pandoc -f markdown -t html5 "${BaseName}.md" > "package/${BaseName}.html" } If (Test-Path -Path "package/CHANGELOG.html") { - (Get-Content "package/CHANGELOG.html") | ForEach-Object { $_ -replace ".md", ".html" } | Set-Content "package/CHANGELOG.html" + (Get-Content "package/CHANGELOG.html") | ForEach-Object { + $_ -replace ".md", ".html" + } | Set-Content "package/CHANGELOG.html" } Set-Location "${CurrentPath}" } Function InstallBuildDependencies { - EnsureChocolateyIsInstalled + EnsureChocolateyIsInstalled + EnsureComposerIsInstalled - $InstallProcess = Start-Process "choco" -WindowStyle Hidden -ArgumentList 'install', '-y --cache-location=C:\Downloads\Choco pandoc' -WorkingDirectory "${Env:APPVEYOR_BUILD_FOLDER}" + $InstallProcess = Start-Process "choco" ` + -WindowStyle Hidden ` + -ArgumentList 'install', '-y --cache-location=C:\Downloads\Choco pandoc' ` + -WorkingDirectory "${Env:APPVEYOR_BUILD_FOLDER}" - If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\package")) { - New-Item -ItemType Directory -Force -Path "${Env:APPVEYOR_BUILD_FOLDER}\package" | Out-Null - } - - $BuildFile = "${Env:APPVEYOR_BUILD_FOLDER}\install-php-deps.bat" - - If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\vendor")) { - $Php = "${Env:PHP_PATH}\php.exe" - $ComposerOptions = "--quiet --no-interaction --no-progress --optimize-autoloader --prefer-dist --no-suggest --ignore-platform-reqs" - - Write-Output "@echo off" | Out-File -Encoding "ASCII" -Append $BuildFile - Write-Output "${Php} -r `"readfile('https://getcomposer.org/installer');`" | ${Env:PHP_PATH}\php.exe" | Out-File -Encoding "ASCII" -Append $BuildFile - Write-Output "${Php} ${Env:APPVEYOR_BUILD_FOLDER}\composer.phar install ${ComposerOptions}" | Out-File -Encoding "ASCII" -Append $BuildFile - - Set-Location "${Env:APPVEYOR_BUILD_FOLDER}" - & cmd /c ".\install-php-deps.bat" - } - - $BuildFile = "${Env:ZEPHIR_PATH}\install-php-deps.bat" + If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\package")) { + New-Item -ItemType Directory -Force -Path "${Env:APPVEYOR_BUILD_FOLDER}\package" | Out-Null + } - If (-not (Test-Path "${Env:ZEPHIR_PATH}\vendor")) { + If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\vendor")) { $Php = "${Env:PHP_PATH}\php.exe" - $ComposerOptions = "--quiet --no-interaction --no-progress --optimize-autoloader --prefer-dist --no-suggest --ignore-platform-reqs" - - Write-Output "@echo off" | Out-File -Encoding "ASCII" -Append $BuildFile - Write-Output "${Php} -r `"readfile('https://getcomposer.org/installer');`" | ${Env:PHP_PATH}\php.exe" | Out-File -Encoding "ASCII" -Append $BuildFile - Write-Output "${Php} ${Env:APPVEYOR_BUILD_FOLDER}\composer.phar install ${ComposerOptions}" | Out-File -Encoding "ASCII" -Append $BuildFile + $ComposerOptions = "-q -n --no-progress -o --prefer-dist --no-suggest --ignore-platform-reqs" - Set-Location "${Env:ZEPHIR_PATH}" - & cmd /c ".\install-php-deps.bat" + Set-Location "${Env:APPVEYOR_BUILD_FOLDER}" + & cmd /c ".\composer.bat install ${ComposerOptions}" + & cmd /c ".\composer.bat require ${ComposerOptions} `"phalcon/zephir:${Env:ZEPHIR_VERSION}`"" } } @@ -380,28 +367,6 @@ Function InstallParser { } } -Function InstallZephir { - $BaseUri = "https://github.com/phalcon/zephir/archive" - $RemoteUrl = "${BaseUri}/${Env:ZEPHIR_VERSION}.zip" - - $DestinationPath = "C:\Downloads\zephir-${Env:ZEPHIR_VERSION}.zip" - - If (-not (Test-Path ${Env:ZEPHIR_PATH})) { - If (-not [System.IO.File]::Exists($DestinationPath)) { - Write-Host "Downloading Zephir: ${RemoteUrl} ..." - DownloadFile $RemoteUrl $DestinationPath - } - - $DestinationUnzipPath = "${Env:Temp}\zephir-${Env:ZEPHIR_VERSION}" - - If (-not (Test-Path "$DestinationUnzipPath")) { - Expand-Item7zip $DestinationPath $Env:Temp - } - - Move-Item -Path "$DestinationUnzipPath" -Destination "${Env:ZEPHIR_PATH}" - } -} - Function InstallPhp { Write-Host "Install PHP: ${Env:PHP_VERSION}" -foregroundcolor Cyan @@ -482,6 +447,20 @@ Function EnsureChocolateyIsInstalled { } } +Function EnsureComposerIsInstalled { + $ComposerBatch = "${Env:APPVEYOR_BUILD_FOLDER}\composer.bat" + + If (-not (Test-Path -Path $ComposerBatch)) { + $Php = "${Env:PHP_PATH}\php.exe" + $ComposerPhar = "${Env:APPVEYOR_BUILD_FOLDER}\composer.phar" + + DownloadFile "https://getcomposer.org/composer.phar" "${ComposerPhar}" + + Write-Output "@echo off" | Out-File -Encoding "ASCII" -Append $ComposerBatch + Write-Output "${Php} `"${ComposerPhar}`" %*" | Out-File -Encoding "ASCII" -Append $ComposerBatch + } +} + Function SetupPhpVersionString { $RemoteUrl = 'http://windows.php.net/downloads/releases/sha1sum.txt'; $DestinationPath = "${Env:Temp}\php-sha1sum.txt" @@ -509,7 +488,7 @@ Function AppendSessionPath { $PathsCollection += "${Env:PHP_SDK_PATH}\bin" $PathsCollection += "${Env:PHP_PATH}\bin" $PathsCollection += "${Env:PHP_PATH}" - $PathsCollection += "${Env:ZEPHIR_PATH}\bin" + $PathsCollection += "${Env:APPVEYOR_BUILD_FOLDER}" $CurrentPath = (Get-Item -Path ".\" -Verbose).FullName @@ -556,7 +535,7 @@ Function Expand-Item7zip { $7zipExitCode = $LASTEXITCODE If ($7zipExitCode -ne 0) { - Throw "An error occurred while unzipping [$Archive] to [$Destination]. 7Zip Exit Code was [$7zipExitCode]" + Throw "An error occurred while unzipping [$Archive] to [$Destination]. Exit code was [${7zipExitCode}]" } } From 0cbf0f77609e4db291963f3d70edba2a20220716 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Wed, 14 Nov 2018 02:25:44 +0200 Subject: [PATCH 11/23] Fixed AppVeyor build [skip travis] --- .editorconfig | 2 +- appveyor.yml | 6 +- tests/_ci/appveyor.psm1 | 138 ++++++++++++++++++++++++---------------- 3 files changed, 86 insertions(+), 60 deletions(-) diff --git a/.editorconfig b/.editorconfig index e9f14354140..02bb00a105a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ insert_final_newline = true indent_style = space indent_size = 4 -[*.{c,h,awk,w32,bat,mk,Makefile,frag,zep,lemon,re}] +[*.{c,h,awk,w32,bat,mk,Makefile,frag,zep,lemon,re,psm1}] charset = utf-8 end_of_line = lf indent_size = 4 diff --git a/appveyor.yml b/appveyor.yml index 1e413728cfb..0449b4af907 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,8 +29,8 @@ environment: PHP_PATH: C:\Projects\php PHP_SDK_PATH: C:\Projects\php-sdk PHP_DEVPACK: C:\Projects\php-devpack - ZEPHIR_PATH: C:\Projects\zephir TEST_PHP_EXECUTABLE: C:\Projects\php\php.exe + ZEPHIR_PATH: C:\Projects\zephir PHP_SDK_VERSION: 2.0.7 PACKAGE_PREFIX: phalcon EXTENSION_NAME: phalcon @@ -41,7 +41,7 @@ environment: PARSER_VERSION: 1.1.3 PARSER_RELEASE: 401 PHALCON_STABLE_VERSION: 3.3.2 - PSR_PECL_VERSION: 0.5.1 + PSR_PECL_VERSION: 0.6.1 ZEPHIR_VERSION: 0.10.12 matrix: @@ -77,6 +77,7 @@ install: - ps: InstallPsrExtension - ps: InstallStablePhalcon - ps: InstallParser + - ps: InstallZephir - ps: TuneUpPhp build_script: @@ -104,7 +105,6 @@ artifacts: name: Phalcon on_failure : - - ps: PrintLogs "${Env:APPVEYOR_BUILD_FOLDER}" - ps: PrintLogs "${Env:APPVEYOR_BUILD_FOLDER}\build\php7\safe" - ps: PrintVars - ps: PrintDirectoriesContent diff --git a/tests/_ci/appveyor.psm1 b/tests/_ci/appveyor.psm1 index 0956240787b..296b98b1f5a 100644 --- a/tests/_ci/appveyor.psm1 +++ b/tests/_ci/appveyor.psm1 @@ -58,34 +58,39 @@ Function FormatReleaseFiles { If (Test-Path -Path "package/CHANGELOG.html") { (Get-Content "package/CHANGELOG.html") | ForEach-Object { - $_ -replace ".md", ".html" - } | Set-Content "package/CHANGELOG.html" + $_ -replace ".md", ".html" + } | Set-Content "package/CHANGELOG.html" } Set-Location "${CurrentPath}" } Function InstallBuildDependencies { - EnsureChocolateyIsInstalled - EnsureComposerIsInstalled - - $InstallProcess = Start-Process "choco" ` - -WindowStyle Hidden ` - -ArgumentList 'install', '-y --cache-location=C:\Downloads\Choco pandoc' ` - -WorkingDirectory "${Env:APPVEYOR_BUILD_FOLDER}" - - If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\package")) { - New-Item -ItemType Directory -Force -Path "${Env:APPVEYOR_BUILD_FOLDER}\package" | Out-Null - } - - If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\vendor")) { - $Php = "${Env:PHP_PATH}\php.exe" - $ComposerOptions = "-q -n --no-progress -o --prefer-dist --no-suggest --ignore-platform-reqs" - - Set-Location "${Env:APPVEYOR_BUILD_FOLDER}" - & cmd /c ".\composer.bat install ${ComposerOptions}" - & cmd /c ".\composer.bat require ${ComposerOptions} `"phalcon/zephir:${Env:ZEPHIR_VERSION}`"" - } + EnsureChocolateyIsInstalled + EnsureComposerIsInstalled + + $InstallProcess = Start-Process "choco" ` + -WindowStyle Hidden ` + -ArgumentList 'install', '-y --cache-location=C:\Downloads\Choco pandoc' ` + -WorkingDirectory "${Env:APPVEYOR_BUILD_FOLDER}" + + If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\package")) { + New-Item -ItemType Directory -Force -Path "${Env:APPVEYOR_BUILD_FOLDER}\package" | Out-Null + } + + $ComposerOptions = "-q -n --no-progress -o --prefer-dist --no-suggest --ignore-platform-reqs" + + If (-not (Test-Path "${Env:APPVEYOR_BUILD_FOLDER}\vendor")) { + Set-Location "${Env:APPVEYOR_BUILD_FOLDER}" + + & cmd /c ".\composer.bat install ${ComposerOptions}" + } + + If (-not (Test-Path "${Env:ZEPHIR_PATH}\vendor")) { + Set-Location "${Env:ZEPHIR_PATH}" + + & cmd /c "${Env:APPVEYOR_BUILD_FOLDER}\composer.bat install ${ComposerOptions}" + } } Function EnsurePandocIsInstalled { @@ -152,16 +157,16 @@ Function InitializeReleaseVars { Function PrintLogs { Param([Parameter(Mandatory=$true)][System.String] $BasePath) - If (Test-Path -Path "${Env:BasePath}\compile-errors.log") { - Get-Content -Path "${Env:BasePath}\compile-errors.log" + If (Test-Path -Path "${BasePath}\compile-errors.log") { + Get-Content -Path "${BasePath}\compile-errors.log" } - If (Test-Path -Path "${Env:BasePath}\compile.log") { - Get-Content -Path "${Env:BasePath}\compile.log" + If (Test-Path -Path "${BasePath}\compile.log") { + Get-Content -Path "${BasePath}\compile.log" } - If (Test-Path -Path "${Env:BasePath}\configure.js") { - Get-Content -Path "${Env:BasePath}\configure.js" + If (Test-Path -Path "${BasePath}\configure.js") { + Get-Content -Path "${BasePath}\configure.js" } } @@ -196,9 +201,9 @@ Function PrintDirectoriesContent { Get-ChildItem -Path "${BuildPath}" } - If (Test-Path -Path "${Env:PHP_DEVPACK}") { - Get-ChildItem -Path "${Env:PHP_DEVPACK}" - } + If (Test-Path -Path "${Env:PHP_DEVPACK}") { + Get-ChildItem -Path "${Env:PHP_DEVPACK}" + } } Function PrintPhpInfo { @@ -296,27 +301,27 @@ Function InstallPhpDevPack { } Function InstallPsrExtension { - Write-Host "Install PSR extension: ${Env:PSR_PECL_VERSION}" -foregroundcolor Cyan + Write-Host "Install PSR extension: ${Env:PSR_PECL_VERSION}" -foregroundcolor Cyan - If ($Env:BUILD_TYPE -eq 'nts-Win32') { - $BuildType = 'nts' - } Else { - $BuildType = 'ts' - } + If ($Env:BUILD_TYPE -eq 'nts-Win32') { + $BuildType = 'nts' + } Else { + $BuildType = 'ts' + } - $FileName = "php_psr-${Env:PSR_PECL_VERSION}-${Env:PHP_MINOR}-${BuildType}-vc${Env:VC_VERSION}-${Env:PLATFORM}.zip" + $FileName = "php_psr-${Env:PSR_PECL_VERSION}-${Env:PHP_MINOR}-${BuildType}-vc${Env:VC_VERSION}-${Env:PLATFORM}.zip" - $RemoteUrl = "https://windows.php.net/downloads/pecl/releases/psr/${Env:PSR_PECL_VERSION}/${FileName}" - $DestinationPath = "C:\Downloads\${FileName}" + $RemoteUrl = "https://windows.php.net/downloads/pecl/releases/psr/${Env:PSR_PECL_VERSION}/${FileName}" + $DestinationPath = "C:\Downloads\${FileName}" - If (-not (Test-Path "${Env:PHP_PATH}\ext\php_psr.dll")) { - If (-not [System.IO.File]::Exists($DestinationPath)) { - Write-Host "Downloading PSR extension: ${RemoteUrl} ..." - DownloadFile $RemoteUrl $DestinationPath - } + If (-not (Test-Path "${Env:PHP_PATH}\ext\php_psr.dll")) { + If (-not [System.IO.File]::Exists($DestinationPath)) { + Write-Host "Downloading PSR extension: ${RemoteUrl} ..." + DownloadFile $RemoteUrl $DestinationPath + } - Expand-Item7zip $DestinationPath "${Env:PHP_PATH}\ext" - } + Expand-Item7zip $DestinationPath "${Env:PHP_PATH}\ext" + } } Function InstallStablePhalcon { @@ -367,6 +372,27 @@ Function InstallParser { } } +Function InstallZephir { + $BaseUri = "https://github.com/phalcon/zephir/archive" + $RemoteUrl = "${BaseUri}/${Env:ZEPHIR_VERSION}.zip" + + $DestinationPath = "C:\Downloads\zephir-${Env:ZEPHIR_VERSION}.zip" + If (-not (Test-Path ${Env:ZEPHIR_PATH})) { + If (-not [System.IO.File]::Exists($DestinationPath)) { + Write-Host "Downloading Zephir: ${RemoteUrl} ..." + DownloadFile $RemoteUrl $DestinationPath + } + + $DestinationUnzipPath = "${Env:Temp}\zephir-${Env:ZEPHIR_VERSION}" + + If (-not (Test-Path "$DestinationUnzipPath")) { + Expand-Item7zip $DestinationPath $Env:Temp + } + + Move-Item -Path "$DestinationUnzipPath" -Destination "${Env:ZEPHIR_PATH}" + } +} + Function InstallPhp { Write-Host "Install PHP: ${Env:PHP_VERSION}" -foregroundcolor Cyan @@ -448,17 +474,17 @@ Function EnsureChocolateyIsInstalled { } Function EnsureComposerIsInstalled { - $ComposerBatch = "${Env:APPVEYOR_BUILD_FOLDER}\composer.bat" + $ComposerBatch = "${Env:APPVEYOR_BUILD_FOLDER}\composer.bat" - If (-not (Test-Path -Path $ComposerBatch)) { - $Php = "${Env:PHP_PATH}\php.exe" - $ComposerPhar = "${Env:APPVEYOR_BUILD_FOLDER}\composer.phar" + If (-not (Test-Path -Path $ComposerBatch)) { + $Php = "${Env:PHP_PATH}\php.exe" + $ComposerPhar = "${Env:APPVEYOR_BUILD_FOLDER}\composer.phar" - DownloadFile "https://getcomposer.org/composer.phar" "${ComposerPhar}" + DownloadFile "https://getcomposer.org/composer.phar" "${ComposerPhar}" - Write-Output "@echo off" | Out-File -Encoding "ASCII" -Append $ComposerBatch - Write-Output "${Php} `"${ComposerPhar}`" %*" | Out-File -Encoding "ASCII" -Append $ComposerBatch - } + Write-Output "@echo off" | Out-File -Encoding "ASCII" -Append $ComposerBatch + Write-Output "${Php} `"${ComposerPhar}`" %*" | Out-File -Encoding "ASCII" -Append $ComposerBatch + } } Function SetupPhpVersionString { @@ -488,7 +514,7 @@ Function AppendSessionPath { $PathsCollection += "${Env:PHP_SDK_PATH}\bin" $PathsCollection += "${Env:PHP_PATH}\bin" $PathsCollection += "${Env:PHP_PATH}" - $PathsCollection += "${Env:APPVEYOR_BUILD_FOLDER}" + $PathsCollection += "${Env:APPVEYOR_BUILD_FOLDER}" $CurrentPath = (Get-Item -Path ".\" -Verbose).FullName From 64fd4cf28b60b5951d174282d5a31bf79aa5b7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Mon, 12 Nov 2018 14:13:46 +0800 Subject: [PATCH 12/23] Add `Phalcon\Http\Response\Cookies::getCookies`. --- phalcon/http/response/cookies.zep | 8 ++++ tests/unit/Http/Response/CookiesTest.php | 54 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/phalcon/http/response/cookies.zep b/phalcon/http/response/cookies.zep index 7c076aaa236..016a29cbcd5 100644 --- a/phalcon/http/response/cookies.zep +++ b/phalcon/http/response/cookies.zep @@ -283,6 +283,14 @@ class Cookies implements CookiesInterface, InjectionAwareInterface return cookie; } + /** + * Gets all cookies from the bag + */ + public function getCookies() -> array + { + return this->_cookies; + } + /** * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal */ diff --git a/tests/unit/Http/Response/CookiesTest.php b/tests/unit/Http/Response/CookiesTest.php index 16a5c4387b0..0a300e77493 100644 --- a/tests/unit/Http/Response/CookiesTest.php +++ b/tests/unit/Http/Response/CookiesTest.php @@ -2,8 +2,13 @@ namespace Phalcon\Test\Unit\Http\Response; +use Phalcon\Di; +use Phalcon\Http\Cookie; +use Phalcon\Http\CookieInterface; +use Phalcon\Http\Response; use Phalcon\Http\Response\Cookies; use Phalcon\Test\Unit\Http\Helper\HttpBase; +use Phalcon\Session\Adapter\Files as SessionAdapter; /** * Phalcon\Test\Unit\Http\Response\Http\CookiesTest @@ -41,4 +46,53 @@ function () { } ); } + + /** + * Tests getCookies is work. + * @author limx <715557344@qq.com> + */ + public function testGetCookies() + { + $cookies = new Cookies(); + + Di::reset(); + $di = new Di(); + $di->set('response', function () { + return new Response(); + }); + $di->set('session', function () { + return new SessionAdapter(); + }); + + $cookies->setDI($di); + + $cookies->set('x-token', '1bf0bc92ed7dcc80d337a5755f879878'); + $cookies->set('x-user-id', 1); + + $this->specify( + "The cookies is not a array.", + function () use ($cookies) { + expect(is_array($cookies->getCookies()))->true(); + } + ); + + $this->specify( + "The cookie is not instance of CookieInterface", + function () use ($cookies) { + $cookieArray = $cookies->getCookies(); + expect($cookieArray['x-token'] instanceof CookieInterface)->true(); + expect($cookieArray['x-user-id'] instanceof CookieInterface)->true(); + } + ); + + $this->specify( + "The cookie is not correct.", + function () use ($cookies) { + /** @var Cookie[] $cookieArray */ + $cookieArray = $cookies->getCookies(); + expect($cookieArray['x-token']->getValue())->equals('1bf0bc92ed7dcc80d337a5755f879878'); + expect($cookieArray['x-user-id']->getValue())->equals(1); + } + ); + } } From 2d8e22a565c2f720ac43397ceae6c24691b9cf8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Tue, 13 Nov 2018 13:08:25 +0800 Subject: [PATCH 13/23] Add `Phalcon\Http\Response\Cookies::getCookies`. --- CHANGELOG-4.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index c63bb96c763..303e2691b10 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -14,6 +14,7 @@ - Added `Phalcon\Tag::renderTitle()` that renders the title enclosed in `<title>` tags. [#13547](https://github.com/phalcon/cphalcon/issues/13547) - Added `hasHeader()` method to `Phalcon\Http\Response` to provide the ability to check if a header exists. [PR-12189](https://github.com/phalcon/cphalcon/pull/12189) - Added global setting `orm.case_insensitive_column_map` to attempt to find value in the column map case-insensitively. Can be also enabled by setting `caseInsensitiveColumnMap` key in `\Phalcon\Mvc\Model::setup()`. [#11802](https://github.com/phalcon/cphalcon/pull/11802) +- Added `Phalcon\Http\Response\Cookies::getCookies` [#13591](https://github.com/phalcon/cphalcon/pull/13591) ## Changed - By configuring `prefix` and `statsKey` the `Phalcon\Cache\Backend\Redis::queryKeys` no longer returns prefixed keys, now it returns original keys without prefix. [PR-13456](https://github.com/phalcon/cphalcon/pull/13456) From fc1006f2b47b68065e282717052fe663f3e3fe7e Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Fri, 16 Nov 2018 22:19:15 +0200 Subject: [PATCH 14/23] Add code coverage support [skip appveyor] --- .editorconfig | 4 +- .travis.yml | 49 +++++--------- tests/_ci/{ci.ini => 999-defaut.ini} | 0 tests/_ci/after-success.sh | 58 ++++++++++++++++ tests/_ci/build.sh | 99 ++++++++++++++++++++++++++++ tests/_ci/precompile-headers.sh | 4 +- tests/_ci/volt-tests.sh | 17 +++++ 7 files changed, 194 insertions(+), 37 deletions(-) rename tests/_ci/{ci.ini => 999-defaut.ini} (100%) create mode 100755 tests/_ci/after-success.sh create mode 100755 tests/_ci/build.sh create mode 100755 tests/_ci/volt-tests.sh diff --git a/.editorconfig b/.editorconfig index 02bb00a105a..b9bbf7559ad 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ insert_final_newline = true indent_style = space indent_size = 4 -[*.{c,h,awk,w32,bat,mk,Makefile,frag,zep,lemon,re,psm1}] +[*.{c,h,awk,w32,bat,mk,Makefile,frag,zep,lemon,re,psm1,sh}] charset = utf-8 end_of_line = lf indent_size = 4 @@ -19,7 +19,7 @@ tab_width = 4 trim_trailing_whitespace = true insert_final_newline = true -[*.{yml,m4,sh,json,xml}] +[*.{yml,m4,json,xml}] charset = utf-8 end_of_line = lf indent_size = 2 diff --git a/.travis.yml b/.travis.yml index 1557722d47d..b8b2bf20e30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,65 +50,48 @@ env: - ZEPHIR_VERSION="0.10.12" - RE2C_VERSION="1.1.1" - REPORT_EXIT_STATUS=1 + - REPORT_COVERAGE=1 - NO_INTERACTION=1 - TEST_PHP_ARGS="--show-diff" - - CFLAGS="-g -O0 -Wall -std=gnu90" - PATH="${HOME}/bin:${HOME}/.composer/vendor/bin:${PATH}" - DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest" before_install: - - '[[ -z "${GH_TOKEN}" ]] || composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"' + - if [ ! -z "${GITHUB_TOKEN}" ]; then composer config github-oauth.github.com ${GITHUB_TOKEN}; echo "Add Github token"; fi - export PHP_MAJOR="$(php -r 'echo phpversion();' | cut -d '.' -f 1)" - export PHP_MINOR="$(php -r 'echo phpversion();' | cut -d '.' -f 2)" - export PHP_VERNUM="$(php-config --vernum)" - - ./tests/_ci/pear-setup.sh - - ./tests/_ci/setup-dbs.sh - - source ./tests/_ci/environment - - export $(cut -d= -f1 ./tests/_ci/environment) + - tests/_ci/pear-setup.sh + - tests/_ci/setup-dbs.sh + - source tests/_ci/environment + - export $(cut -d= -f1 tests/_ci/environment) install: - - ./tests/_ci/install-prereqs.sh - - ./tests/_ci/install-re2c.sh + - tests/_ci/install-prereqs.sh + - tests/_ci/install-re2c.sh - travis_retry composer install ${DEFAULT_COMPOSER_FLAGS} - travis_retry composer global require ${DEFAULT_COMPOSER_FLAGS} "phalcon/zephir:${ZEPHIR_VERSION}" - - zephir generate - - ./tests/_ci/precompile-headers.sh - - | - cd ext - phpize - ./configure --with-php-config=$(phpenv which php-config) --enable-phalcon - make -j"$(getconf _NPROCESSORS_ONLN)" > /dev/null 2> ../compile-errors.log - make install - cd .. - - phpenv config-add ./tests/_ci/phalcon.ini - - phpenv config-add ./tests/_ci/ci.ini + - tests/_ci/build.sh before_script: - ulimit -c unlimited -S || true - # see: https://github.com/sebastianbergmann/phpunit/pull/3359 - - '[[ "${PHP_VERNUM}" -lt 70300 ]] || export USE_ZEND_ALLOC=1' + - phpenv config-add tests/_ci/999-default.ini script: - # To avoud this: - # sh: 1: /home/travis/build/phalcon/cphalcon/libtool: not found - - ln -s ${TRAVIS_BUILD_DIR}/ext/libtool ${TRAVIS_BUILD_DIR}/libtool - # Syntax recognize tests - - | - $(phpenv which php) "${TRAVIS_BUILD_DIR}/ext/run-tests.php" \ - -p $(phpenv which php) \ - -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" \ - --offline \ - --show-diff \ - --set-timeout 120 - vendor/bin/phpcs - vendor/bin/codecept build # TODO: Add `cli' suite and refactor current cli-tests - vendor/bin/codecept run -v -n tests/integration/ - vendor/bin/codecept run -v -n tests/unit/ # TODO: Refactor legacy unit tests from the "unit-tests" directory + - phpenv config-rm xdebug.ini || true + - tests/_ci/volt-tests.sh after_failure: - - ./tests/_ci/after-failure.sh + - tests/_ci/after-failure.sh + +after_success: + - tests/_ci/after-success.sh notifications: email: false diff --git a/tests/_ci/ci.ini b/tests/_ci/999-defaut.ini similarity index 100% rename from tests/_ci/ci.ini rename to tests/_ci/999-defaut.ini diff --git a/tests/_ci/after-success.sh b/tests/_ci/after-success.sh new file mode 100755 index 00000000000..3b54d32eb63 --- /dev/null +++ b/tests/_ci/after-success.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# +# This file is part of the Zephir. +# +# (c) Zephir Team <team@zephir-lang.com> +# +# For the full copyright and license information, please view the +# https://docs.zephir-lang.com/en/latest/license license. + +set -e +o pipefail + +PROJECT_ROOT=$(readlink -enq "$(dirname $0)/../../") +LCOV_REPORT=${PROJECT_ROOT}/tests/_output/lcov.info + +if [[ -z ${REPORT_COVERAGE+x} ]] || [[ "$REPORT_COVERAGE" != "1" ]]; then + echo -e "\nUploading coverage data is not enabled.\nSkip uploading reports to Codecov.\n" + exit 0 +fi + +if [[ $(command -v lcov 2>/dev/null) = "" ]]; then + echo -e "lcov does not exist.\nSkip capturing coverage data." +else + # Capture coverage data + lcov \ + --quiet \ + --no-checksum \ + --directory ext \ + --base-directory=${PROJECT_ROOT} \ + --capture \ + --compat-libtool \ + --output-file ${LCOV_REPORT} + + # Remove files matching non-project patterns + lcov \ + --quiet \ + --remove ${LCOV_REPORT} "/usr*" \ + --remove ${LCOV_REPORT} "${PROJECT_ROOT}/kernel/*" \ + --remove ${LCOV_REPORT} "${PROJECT_ROOT}/ext/kernel/*" \ + --remove ${LCOV_REPORT} "${HOME}/.phpenv/*" \ + --compat-libtool \ + --output-file ${LCOV_REPORT} +fi + +# Note: to upload a coverage report, set the CODECOV_TOKEN environment variable +# export CODECOV_TOKEN=<codecov token> + +if [[ -z ${CODECOV_TOKEN+x} ]]; then + echo -e "\nThe CODECOV_TOKEN variable is absent or empty.\nSkip uploading reports to Codecov.\n" + exit 0 +fi + +curl -sSl https://codecov.io/bash -o codecov.sh +chmod +x codecov.sh + +if [[ -f "${LCOV_REPORT}" ]]; then + echo -e "Uploading coverage report: ${LCOV_REPORT}...\n" + ./codecov.sh -f "${LCOV_REPORT}" +fi diff --git a/tests/_ci/build.sh b/tests/_ci/build.sh new file mode 100755 index 00000000000..3c411eb3ed6 --- /dev/null +++ b/tests/_ci/build.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +# +# This file is part of the Zephir. +# +# (c) Zephir Team <team@zephir-lang.com> +# +# For the full copyright and license information, please view the +# https://docs.zephir-lang.com/en/latest/license license. + +PROJECT_ROOT=$(readlink -enq "$(dirname $0)/../../") +LCOV_REPORT=${PROJECT_ROOT}/tests/_output/lcov.info + +shopt -s nullglob + +zephir clean 2>&1 +zephir fullclean 2>&1 +zephir generate 2>&1 + +if [[ -z ${CC+x} ]]; then + echo -e "The CC variable is unset or set to the empty string.\nSkip precompiling headers.\n" +else + echo "Creating precompiled headers..." + if [[ "${CC:0:5}" = "clang" ]]; then + _ext="pch" + _option="-emit-pch" + _arg="-cc1" + else + _ext="ghc" + _option= + _arg= + fi + + # If a `*.gch' (or a `*.pch') file is not found then the normal header files + # will be used. For more see: http://en.wikipedia.org/wiki/Precompiled_header + for file in `find ./ext/kernel -name "*.h"`; do + printf "\t>>> ${file}\n\t<<< ${file}.ghc\n" + ${CC} ${_arg} "${file}" -I. -I./ext $(php-config --includes) ${_option} -o "${file}.${_ext}" + done +fi + +cd ext + +phpize + +if [[ ! -z ${REPORT_COVERAGE+x} ]] && [[ "$REPORT_COVERAGE" = "1" ]]; then + # The ltmain.sh which bundled with PHP it's from libtool 1.5.26. + # However, the version of libtool that claims to no longer remove + # ".gcno" profiler information is libtool 2.2.6. The fix is probably + # in later libtool versions as well. + if [[ "$(uname -s 2>/dev/null)" = "Darwin" ]]; then + # macOS + LIBTOOLIZE_BIN=$(command -v glibtoolize 2>/dev/null) + else + # Linux, Gentoo, etc + LIBTOOLIZE_BIN=$(command -v libtoolize 2>/dev/null) + fi + + aclocal && ${LIBTOOLIZE_BIN} --copy --force && autoheader && autoconf + + CFLAGS=`echo "${CFLAGS}" | sed -e 's/-O[0-9s]*//g'` + CXXFLAGS=`echo "${CXXFLAGS}" | sed -e 's/-O[0-9s]*//g'` + LDFLAGS=`echo "${LDFLAGS}" | sed -e 's/--coverage//g'` + + LDFLAGS="${LDFLAGS} --coverage" + CFLAGS="${CFLAGS} -O0 -ggdb -fprofile-arcs -ftest-coverage" + CXXFLAGS="${CXXFLAGS} -O0 -ggdb -fprofile-arcs -ftest-coverage" +fi + +./configure --with-php-config=$(phpenv which php-config) --enable-phalcon CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" + +make -j"$(getconf _NPROCESSORS_ONLN)" > /dev/null 2> ${PROJECT_ROOT}/compile-errors.log +make install + +phpenv config-add ${PROJECT_ROOT}/tests/_ci/phalcon.ini + +cd .. + +if [[ ! -z ${REPORT_COVERAGE+x} ]] && [[ "$REPORT_COVERAGE" = "1" ]]; then + if [[ $(command -v lcov 2>/dev/null) = "" ]]; then + echo -e "lcov does not exist.\nSkip capturing coverage data.\n" + else + # Reset all execution counts to zero + lcov \ + --quiet \ + --directory ext \ + --base-directory=${PROJECT_ROOT} \ + --zerocounters + + # Capture coverage data + lcov \ + --quiet \ + --directory ext \ + --base-directory=${PROJECT_ROOT} \ + --capture \ + --compat-libtool \ + --initial \ + --output-file ${LCOV_REPORT} + fi +fi diff --git a/tests/_ci/precompile-headers.sh b/tests/_ci/precompile-headers.sh index e9ce90bd394..23fc5bc26ca 100755 --- a/tests/_ci/precompile-headers.sh +++ b/tests/_ci/precompile-headers.sh @@ -7,13 +7,13 @@ # For the full copyright and license information, please view the LICENSE.txt # file that was distributed with this source code. -if [ -z "${CC}" ]; then +if [[ -z "${CC}" ]]; then echo "The CC variable is unset or set to the empty string. Skip" exit 0 fi echo "Creating precompiled headers..." -if [ "${CC:0:5}" = "clang" ]; then +if [[ "${CC:0:5}" = "clang" ]]; then _ext="pch" _option="-emit-pch" _arg="-cc1" diff --git a/tests/_ci/volt-tests.sh b/tests/_ci/volt-tests.sh new file mode 100755 index 00000000000..0705d734913 --- /dev/null +++ b/tests/_ci/volt-tests.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# This file is part of the Phalcon. +# +# (c) Phalcon Team <team@phalconphp.com> +# +# For the full copyright and license information, please view the LICENSE.txt +# file that was distributed with this source code. + +php ext/run-tests.php \ + --offline \ + --show-diff \ + --set-timeout 120 \ + -n \ + -g "FAIL,XFAIL,SKIP,BORK,WARN,LEAK" \ + -p $(phpenv which php) \ + tests/syntax From c531d1d0844fa4f93d5333de0d71a992bbc3da15 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Fri, 16 Nov 2018 22:34:42 +0200 Subject: [PATCH 15/23] Fixed default PHP config filename [skip appveyor] --- tests/_ci/{999-defaut.ini => 999-default.ini} | 0 tests/_ci/build.sh | 38 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) rename tests/_ci/{999-defaut.ini => 999-default.ini} (100%) diff --git a/tests/_ci/999-defaut.ini b/tests/_ci/999-default.ini similarity index 100% rename from tests/_ci/999-defaut.ini rename to tests/_ci/999-default.ini diff --git a/tests/_ci/build.sh b/tests/_ci/build.sh index 3c411eb3ed6..5587b212229 100755 --- a/tests/_ci/build.sh +++ b/tests/_ci/build.sh @@ -19,23 +19,23 @@ zephir generate 2>&1 if [[ -z ${CC+x} ]]; then echo -e "The CC variable is unset or set to the empty string.\nSkip precompiling headers.\n" else - echo "Creating precompiled headers..." - if [[ "${CC:0:5}" = "clang" ]]; then - _ext="pch" - _option="-emit-pch" - _arg="-cc1" - else - _ext="ghc" - _option= - _arg= - fi - - # If a `*.gch' (or a `*.pch') file is not found then the normal header files - # will be used. For more see: http://en.wikipedia.org/wiki/Precompiled_header - for file in `find ./ext/kernel -name "*.h"`; do - printf "\t>>> ${file}\n\t<<< ${file}.ghc\n" - ${CC} ${_arg} "${file}" -I. -I./ext $(php-config --includes) ${_option} -o "${file}.${_ext}" - done + echo "Creating precompiled headers..." + if [[ "${CC:0:5}" = "clang" ]]; then + _ext="pch" + _option="-emit-pch" + _arg="-cc1" + else + _ext="ghc" + _option= + _arg= + fi + + # If a `*.gch' (or a `*.pch') file is not found then the normal header files + # will be used. For more see: http://en.wikipedia.org/wiki/Precompiled_header + for file in `find ./ext/kernel -name "*.h"`; do + printf "\t>>> ${file}\n\t<<< ${file}.ghc\n" + ${CC} ${_arg} "${file}" -I. -I./ext $(php-config --includes) ${_option} -o "${file}.${_ext}" + done fi cd ext @@ -84,7 +84,7 @@ if [[ ! -z ${REPORT_COVERAGE+x} ]] && [[ "$REPORT_COVERAGE" = "1" ]]; then --quiet \ --directory ext \ --base-directory=${PROJECT_ROOT} \ - --zerocounters + --zerocounters 2>&1 >/dev/null # Capture coverage data lcov \ @@ -94,6 +94,6 @@ if [[ ! -z ${REPORT_COVERAGE+x} ]] && [[ "$REPORT_COVERAGE" = "1" ]]; then --capture \ --compat-libtool \ --initial \ - --output-file ${LCOV_REPORT} + --output-file ${LCOV_REPORT} 2>&1 >/dev/null fi fi From fdea0ee9e807237faceb9d3e2a91b622941d60b1 Mon Sep 17 00:00:00 2001 From: Cameron Hall <chall@staff.ventraip.com> Date: Mon, 19 Nov 2018 11:36:23 +1100 Subject: [PATCH 16/23] Fixed #12725: Numeric INI config now builds properly --- phalcon/config/adapter/ini.zep | 2 +- tests/_data/config/config.ini | 11 ++++++- tests/_data/config/config.json | 39 ++++++++++++++++++++++- tests/_data/config/config.php | 41 +++++++++++++++++-------- tests/_data/config/config.yml | 12 ++++++++ tests/unit/Config/Helper/ConfigBase.php | 17 ++++++++++ 6 files changed, 107 insertions(+), 15 deletions(-) diff --git a/phalcon/config/adapter/ini.zep b/phalcon/config/adapter/ini.zep index 3ad497613dd..175818ebbbf 100644 --- a/phalcon/config/adapter/ini.zep +++ b/phalcon/config/adapter/ini.zep @@ -96,7 +96,7 @@ class Ini extends Config let sections[] = this->_parseIniString((string)path, lastValue); } if count(sections) { - let config[section] = call_user_func_array("array_merge_recursive", sections); + let config[section] = call_user_func_array("array_replace_recursive", sections); } } else { let config[section] = this->_cast(directives); diff --git a/tests/_data/config/config.ini b/tests/_data/config/config.ini index 9c2268c060b..368a3a71466 100644 --- a/tests/_data/config/config.ini +++ b/tests/_data/config/config.ini @@ -13,4 +13,13 @@ name = demo [test] parent.property = On -parent.property2 = "yeah" \ No newline at end of file +parent.property2 = "yeah" + +[issue-12725] +channel.handlers.0.name = stream +channel.handlers.0.level = debug +channel.handlers.0.fingersCrossed = info +channel.handlers.0.filename = channel.log +channel.handlers.1.name = redis +channel.handlers.1.level = debug +channel.handlers.1.fingersCrossed = info \ No newline at end of file diff --git a/tests/_data/config/config.json b/tests/_data/config/config.json index 938458e2c70..1251cece3cc 100644 --- a/tests/_data/config/config.json +++ b/tests/_data/config/config.json @@ -1 +1,38 @@ -{"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"},"database":{"adapter":"mysql","host":"localhost","username":"user","password":"passwd","name":"demo"},"test":{"parent":{"property":1,"property2":"yeah"}}} +{ + "phalcon": { + "baseuri": "/phalcon/" + }, + "models": { + "metadata": "memory" + }, + "database": { + "adapter": "mysql", + "host": "localhost", + "username": "user", + "password": "passwd", + "name": "demo" + }, + "test": { + "parent": { + "property": 1, + "property2": "yeah" + } + }, + "issue-12725": { + "channel": { + "handlers": [ + { + "name": "stream", + "level": "debug", + "fingersCrossed": "info", + "filename": "channel.log" + }, + { + "name": "redis", + "level": "debug", + "fingersCrossed": "info" + } + ] + } + } +} \ No newline at end of file diff --git a/tests/_data/config/config.php b/tests/_data/config/config.php index 9a8423abf1f..000314dc65e 100644 --- a/tests/_data/config/config.php +++ b/tests/_data/config/config.php @@ -1,23 +1,40 @@ <?php -return array( - "phalcon" => array( +return [ + "phalcon" => [ "baseuri" => "/phalcon/" - ), - "models" => array( + ], + "models" => [ "metadata" => "memory" - ), - "database" => array( + ], + "database" => [ "adapter" => "mysql", "host" => "localhost", "username" => "user", "password" => "passwd", "name" => "demo" - ), - "test" => array( - "parent" => array( + ], + "test" => [ + "parent" => [ "property" => 1, "property2" => "yeah" - ), - ) - ); + ], + ], + 'issue-12725' => [ + 'channel' => [ + 'handlers' => [ + 0 => [ + 'name' => 'stream', + 'level' => 'debug', + 'fingersCrossed' => 'info', + 'filename' => 'channel.log' + ], + 1 => [ + 'name' => 'redis', + 'level' => 'debug', + 'fingersCrossed' => 'info' + ] + ] + ] + ] + ]; diff --git a/tests/_data/config/config.yml b/tests/_data/config/config.yml index 1ecf03bb747..ee22c15da45 100644 --- a/tests/_data/config/config.yml +++ b/tests/_data/config/config.yml @@ -12,3 +12,15 @@ test: parent: property: 1 property2: yeah +issue-12725: + channel: + handlers: + 0: + name: stream + level: debug + fingersCrossed: info + filename: channel.log + 1: + name: redis + level: debug + fingersCrossed: info \ No newline at end of file diff --git a/tests/unit/Config/Helper/ConfigBase.php b/tests/unit/Config/Helper/ConfigBase.php index 15c35e9d883..91115e678ed 100644 --- a/tests/unit/Config/Helper/ConfigBase.php +++ b/tests/unit/Config/Helper/ConfigBase.php @@ -43,6 +43,23 @@ class ConfigBase extends UnitTest 'property2' => 'yeah' ], ], + 'issue-12725' => [ + 'channel' => [ + 'handlers' => [ + 0 => [ + 'name' => 'stream', + 'level' => 'debug', + 'fingersCrossed' => 'info', + 'filename' => 'channel.log' + ], + 1 => [ + 'name' => 'redis', + 'level' => 'debug', + 'fingersCrossed' => 'info' + ] + ] + ] + ] ]; protected function compareConfig(array $actual, Config $expected) From 52bf59288b29fd4f9df0254132e87e8c21adda01 Mon Sep 17 00:00:00 2001 From: Cameron Hall <chall@staff.ventraip.com> Date: Mon, 19 Nov 2018 20:59:19 +1100 Subject: [PATCH 17/23] Updated Changelog [ci skip] --- CHANGELOG-3.4.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index 11266abe520..59c82fcd3d2 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -10,6 +10,7 @@ - Fixed `Phalcon\Http\Request::getJsonRawBody` [#13501](https://github.com/phalcon/cphalcon/issues/13501). It will now return false when the body content is empty, as well as when it encounters an error whilst decoding the JSON content. - Fixed `Phalcon\Validation::preChecking` to allow use `Phalcon\Db\RawValue` as an empty container for `isAllowEmpty` option [#13549](https://github.com/phalcon/cphalcon/pull/13549), [#13573](https://github.com/phalcon/cphalcon/issues/13573), [#12519](https://github.com/phalcon/cphalcon/pull/12519) - Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058). +- Fixed `Phalcon\Config\Adapter\Ini` not building config objects properly for numerical keys [#12725](https://github.com/phalcon/cphalcon/issues/12725), [#13604](https://github.com/phalcon/cphalcon/issues/13604) # [3.4.1](https://github.com/phalcon/cphalcon/releases/tag/v3.4.1) (2018-08-04) - Changed `Phalcon\Cache\Backend\Redis` to support connection timeout parameter From 2761e0eb526963185ae3ee2c8758807ee8b88c35 Mon Sep 17 00:00:00 2001 From: Cameron Hall <me@chall.id.au> Date: Sat, 24 Nov 2018 13:36:20 +1100 Subject: [PATCH 18/23] Added method to check is a relationship is loaded Co-authored-by: Erik Wiesenthal <erikforo@hotmail.com> This commit also changes the way we cache relationships. For _some_ reason we only stored `hasOne` and `belongsTo` relationships (those that return a model. Now we store resultset as well, which enables caching for `hasMany`, `hasManyToMany` etc. --- CHANGELOG-4.0.md | 1 + phalcon/mvc/model.zep | 11 ++++++---- tests/_data/models/AlbumORama/Albums.php | 2 +- tests/_data/models/AlbumORama/Artists.php | 2 +- tests/unit/Mvc/Model/RelationsTest.php | 25 +++++++++++++++++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index b2ac3c9779a..4a003292d13 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -16,6 +16,7 @@ - Added global setting `orm.case_insensitive_column_map` to attempt to find value in the column map case-insensitively. Can be also enabled by setting `caseInsensitiveColumnMap` key in `\Phalcon\Mvc\Model::setup()`. [#11802](https://github.com/phalcon/cphalcon/pull/11802) - Added `Phalcon\Mvc\Model\Query\BuilderInterface::offset` [#13599](https://github.com/phalcon/cphalcon/pull/13599) - Added `Phalcon\Http\Response\Cookies::getCookies` [#13591](https://github.com/phalcon/cphalcon/pull/13591) +- Added `Phalcon\Mvc\Model::isRelationshipLoaded` to check if relationship is loaded ## Changed - By configuring `prefix` and `statsKey` the `Phalcon\Cache\Backend\Redis::queryKeys` no longer returns prefixed keys, now it returns original keys without prefix. [PR-13456](https://github.com/phalcon/cphalcon/pull/13456) diff --git a/phalcon/mvc/model.zep b/phalcon/mvc/model.zep index 644b18da464..516b5f12a3f 100644 --- a/phalcon/mvc/model.zep +++ b/phalcon/mvc/model.zep @@ -267,11 +267,9 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface let this->{lowerProperty} = result; /** - * For belongs-to relations we store the object in the related bag + * We store relationship objects in the related bag */ - if result instanceof ModelInterface { - let this->_related[lowerProperty] = result; - } + let this->_related[lowerProperty] = result; } return result; @@ -1569,6 +1567,11 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface return manager->getRelationRecords(relation, null, this, arguments); } + public function isRelationshipLoaded(string relationshipAlias) -> boolean + { + return isset this->_related[relationshipAlias]; + } + /** * Returns schema name where the mapped table is located */ diff --git a/tests/_data/models/AlbumORama/Albums.php b/tests/_data/models/AlbumORama/Albums.php index 00452a136e8..41dfa972da3 100644 --- a/tests/_data/models/AlbumORama/Albums.php +++ b/tests/_data/models/AlbumORama/Albums.php @@ -32,7 +32,7 @@ public function initialize() { $this->belongsTo( 'artists_id', - 'AlbumORama:Artists', + Artists::class, 'id', ['alias' => 'artist'] ); diff --git a/tests/_data/models/AlbumORama/Artists.php b/tests/_data/models/AlbumORama/Artists.php index c0a2d70e2ec..aed32febfad 100644 --- a/tests/_data/models/AlbumORama/Artists.php +++ b/tests/_data/models/AlbumORama/Artists.php @@ -28,7 +28,7 @@ public function initialize() { $this->hasMany( 'id', - 'AlbumORama:Albums', + Albums::class, 'artists_id', ['alias' => 'albums'] ); diff --git a/tests/unit/Mvc/Model/RelationsTest.php b/tests/unit/Mvc/Model/RelationsTest.php index 3930841bc32..fd043c70c17 100644 --- a/tests/unit/Mvc/Model/RelationsTest.php +++ b/tests/unit/Mvc/Model/RelationsTest.php @@ -9,6 +9,7 @@ use Phalcon\Test\Models\Language; use Phalcon\Test\Models\LanguageI18n; use Phalcon\Mvc\Model\Resultset\Simple; +use Phalcon\Test\Models\AlbumORama; class RelationsTest extends UnitTest { @@ -60,4 +61,28 @@ protected function setUpConnectionAwareModelsManager($connection) return $di->getShared('modelsManager'); } + + public function testRelationshipLoaded() + { + $this->specify( + 'Unable to test if "hasMany" relationship exist', + function () { + $hasManyModel = AlbumORama\Artists::findFirst(); + expect($hasManyModel->isRelationshipLoaded('albums'))->equals(false); + $hasManyModel->albums; + expect($hasManyModel->isRelationshipLoaded('albums'))->equals(true); + } + ); + + $this->specify( + 'Unable to test if "belongsTo" relationship exist', + function () { + + $belongsToModel = AlbumORama\Albums::findFirst(); + expect($belongsToModel->isRelationshipLoaded('artist'))->equals(false); + $belongsToModel->artist; + expect($belongsToModel->isRelationshipLoaded('artist'))->equals(true); + } + ); + } } From 02231d2a9300b459011dcdd9958af67d35d58181 Mon Sep 17 00:00:00 2001 From: "Zamrony P. Juhara" <zamronypj@yahoo.com> Date: Fri, 27 Apr 2018 06:05:24 +0800 Subject: [PATCH 19/23] fix issue 13351 merge config on non-zero-based numeric index --- CHANGELOG-3.4.md | 2 ++ phalcon/config.zep | 12 ++++++--- tests/unit/ConfigTest.php | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index 59c82fcd3d2..0cdde92640c 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -37,6 +37,8 @@ - Changed `Phalcon\Crypt::setCipher` so that IV length will be reconfigured during setting the cipher algorithm - Changed `Phalcon\Crypt::setCipher` so that method will throw `Phalcon\Crypt\Exception` if a cipher is unavailable - Fixed regression ([#13308](https://github.com/phalcon/cphalcon/pull/13308)) for `Phalcon\Debug\Dump::output` to correctly work with detailed mode [#13315](https://github.com/phalcon/cphalcon/issues/13315) +- Do not throw Exception when superglobal does not exist [#13252](https://github.com/phalcon/cphalcon/issues/13252), [#13254](https://github.com/phalcon/cphalcon/issues/13254), [#12918](https://github.com/phalcon/cphalcon/issues/12918), +[#13351](https://github.com/phalcon/cphalcon/issues/13351) - Fixed `Phalcon\Mvc\Model\Query\Builder::having` and `Phalcon\Mvc\Model\Query\Builder::where` to correctly merge the bind types [#11487](https://github.com/phalcon/cphalcon/issues/11487) - Fixed `Phalcon\Mvc\Model::setSnapshotData` to properly sets the old snapshot - Do not throw Exception when superglobal does not exist [#13252](https://github.com/phalcon/cphalcon/issues/13252), [#13254](https://github.com/phalcon/cphalcon/issues/13254), [#12918](https://github.com/phalcon/cphalcon/issues/12918) diff --git a/phalcon/config.zep b/phalcon/config.zep index a225ccb8e51..a55845bf6b9 100644 --- a/phalcon/config.zep +++ b/phalcon/config.zep @@ -297,7 +297,7 @@ class Config implements \ArrayAccess, \Countable */ protected final function _merge(<Config> config, <Config> instance = null) -> <Config> { - var key, value, number, localObject, property; + var key, originalKey, value, number, localObject, property; if typeof instance !== "object" { let instance = this; @@ -318,8 +318,14 @@ class Config implements \ArrayAccess, \Countable } if is_numeric(key) { - let key = strval(number), - number++; + let originalKey = key; + let key = strval(number); + if this->offsetExists(key) { + //@link https://github.com/phalcon/cphalcon/issues/13351 + //use originalKey to avoid overwriting incorrect key + let key = strval(originalKey); + } + let number++; } let instance->{key} = value; } diff --git a/tests/unit/ConfigTest.php b/tests/unit/ConfigTest.php index b6900773e9c..fb8e642b579 100644 --- a/tests/unit/ConfigTest.php +++ b/tests/unit/ConfigTest.php @@ -351,4 +351,61 @@ public function testIssue12779() ] ); } + + /** + * Tests issue 13351 + * + * @link https://github.com/phalcon/cphalcon/issues/13351 + * @author Zamrony P. Juhara <zamronypj@yahoo.com> + * @since 2018-04-27 + */ + public function testIssue13351MergeNonZeroBasedNumericKey() + { + $config = new Config([1 => 'Apple']); + $config2 = new Config([2 => 'Banana']); + $config->merge($config2); + expect($config->toArray())->equals( + [ + 1 => 'Apple', + 2 => 'Banana', + ] + ); + + $config = new Config([0 => 'Apple']); + $config2 = new Config([1 => 'Banana']); + $config->merge($config2); + expect($config->toArray())->equals( + [ + 0 => 'Apple', + 1 => 'Banana', + ] + ); + + $config = new Config([1 => 'Apple', 'p' => 'Pineapple']); + $config2 = new Config([2 => 'Banana']); + $config->merge($config2); + expect($config->toArray())->equals( + [ + 1 => 'Apple', + 'p' => 'Pineapple', + 2 => 'Banana', + ] + ); + + $config = new Config([ + 'One' => [1 => 'Apple', 'p' => 'Pineapple'], + 'Two' => [1 => 'Apple'], + ]); + $config2 = new Config([ + 'One' => [2 => 'Banana'], + 'Two' => [2 => 'Banana'], + ]); + $config->merge($config2); + expect($config->toArray())->equals( + [ + 'One' => [1 => 'Apple', 'p' => 'Pineapple', 2 => 'Banana'], + 'Two' => [1 => 'Apple', 2 => 'Banana'], + ] + ); + } } From 838b42aaff627fa139a231138bd1667af0fe3b6f Mon Sep 17 00:00:00 2001 From: Cameron Hall <chall@staff.ventraip.com> Date: Wed, 21 Nov 2018 22:41:34 +1100 Subject: [PATCH 20/23] Fixes #13351: Numeric config properties merge correctly now --- CHANGELOG-3.4.md | 10 ++++++++-- phalcon/config.zep | 16 +++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index 0cdde92640c..99fbf64e974 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -11,6 +11,14 @@ - Fixed `Phalcon\Validation::preChecking` to allow use `Phalcon\Db\RawValue` as an empty container for `isAllowEmpty` option [#13549](https://github.com/phalcon/cphalcon/pull/13549), [#13573](https://github.com/phalcon/cphalcon/issues/13573), [#12519](https://github.com/phalcon/cphalcon/pull/12519) - Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058). - Fixed `Phalcon\Config\Adapter\Ini` not building config objects properly for numerical keys [#12725](https://github.com/phalcon/cphalcon/issues/12725), [#13604](https://github.com/phalcon/cphalcon/issues/13604) +- Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058) +- Fixed incorrect scope of view variables + [#12176](https://github.com/phalcon/cphalcon/issues/12176), + [#12385](https://github.com/phalcon/cphalcon/issues/12385), + [#12648](https://github.com/phalcon/cphalcon/issues/12648), + [#12705](https://github.com/phalcon/cphalcon/issues/12705), + [#13288](https://github.com/phalcon/cphalcon/pull/13288) +- Fixed `Phalcon\Config::_merge` not merging config with numeric properties properly [#13351](https://github.com/phalcon/cphalcon/issues/13351). # [3.4.1](https://github.com/phalcon/cphalcon/releases/tag/v3.4.1) (2018-08-04) - Changed `Phalcon\Cache\Backend\Redis` to support connection timeout parameter @@ -37,8 +45,6 @@ - Changed `Phalcon\Crypt::setCipher` so that IV length will be reconfigured during setting the cipher algorithm - Changed `Phalcon\Crypt::setCipher` so that method will throw `Phalcon\Crypt\Exception` if a cipher is unavailable - Fixed regression ([#13308](https://github.com/phalcon/cphalcon/pull/13308)) for `Phalcon\Debug\Dump::output` to correctly work with detailed mode [#13315](https://github.com/phalcon/cphalcon/issues/13315) -- Do not throw Exception when superglobal does not exist [#13252](https://github.com/phalcon/cphalcon/issues/13252), [#13254](https://github.com/phalcon/cphalcon/issues/13254), [#12918](https://github.com/phalcon/cphalcon/issues/12918), -[#13351](https://github.com/phalcon/cphalcon/issues/13351) - Fixed `Phalcon\Mvc\Model\Query\Builder::having` and `Phalcon\Mvc\Model\Query\Builder::where` to correctly merge the bind types [#11487](https://github.com/phalcon/cphalcon/issues/11487) - Fixed `Phalcon\Mvc\Model::setSnapshotData` to properly sets the old snapshot - Do not throw Exception when superglobal does not exist [#13252](https://github.com/phalcon/cphalcon/issues/13252), [#13254](https://github.com/phalcon/cphalcon/issues/13254), [#12918](https://github.com/phalcon/cphalcon/issues/12918) diff --git a/phalcon/config.zep b/phalcon/config.zep index a55845bf6b9..664cb326245 100644 --- a/phalcon/config.zep +++ b/phalcon/config.zep @@ -297,7 +297,7 @@ class Config implements \ArrayAccess, \Countable */ protected final function _merge(<Config> config, <Config> instance = null) -> <Config> { - var key, originalKey, value, number, localObject, property; + var key, value, number, localObject, property; if typeof instance !== "object" { let instance = this; @@ -318,15 +318,13 @@ class Config implements \ArrayAccess, \Countable } if is_numeric(key) { - let originalKey = key; - let key = strval(number); - if this->offsetExists(key) { - //@link https://github.com/phalcon/cphalcon/issues/13351 - //use originalKey to avoid overwriting incorrect key - let key = strval(originalKey); + let key = strval(key); + while instance->offsetExists(key) { + // increment the number afterwards, because "number" starts at one not zero. + let key = strval(number); + let number++; } - let number++; - } + } let instance->{key} = value; } From abd891e2e3791dc4e63aeddd57c3fa27a9553b05 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Sun, 18 Nov 2018 23:31:17 +0200 Subject: [PATCH 21/23] Use latest Zephir from the 0.10.x branch [skip appveyor] Closes: - https://github.com/phalcon/cphalcon/pull/13288 - https://github.com/phalcon/cphalcon/issues/12176 - https://github.com/phalcon/cphalcon/issues/12385 - https://github.com/phalcon/cphalcon/issues/12648 - https://github.com/phalcon/cphalcon/issues/12705 - https://github.com/phalcon/cphalcon/issues/12648 --- .travis.yml | 3 +-- CHANGELOG-3.4.md | 8 ++++---- phalcon/mvc/view.zep | 4 +--- tests/_ci/install-prereqs.sh | 10 +++++----- tests/unit/Mvc/ViewTest.php | 4 +++- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index b8b2bf20e30..d61e6d934b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,6 @@ matrix: fast_finish: true allow_failures: - php: 'master' - - php: '7.3' cache: apt: true @@ -47,7 +46,7 @@ services: env: global: - CC="gcc" - - ZEPHIR_VERSION="0.10.12" + - ZEPHIR_VERSION="0.10.14" - RE2C_VERSION="1.1.1" - REPORT_EXIT_STATUS=1 - REPORT_COVERAGE=1 diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index 99fbf64e974..f1e24325d04 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -1,15 +1,15 @@ # [3.4.2](https://github.com/phalcon/cphalcon/releases/tag/v3.4.2) (2018-XX-XX) - Fixed `Phalcon\Validation\Validator\Numericality` to accept float numbers on locales with comma decimal point [#13450](https://github.com/phalcon/cphalcon/issues/13450) - Added missing Volt tags to array helper in `Phalcon\Mvc\View\Engine\Volt\Compiler::functionCall` [#13447](https://github.com/phalcon/cphalcon/issues/13447) -- Added the ability to explicitly define nullable columns (especially timestamp ones). [#13099](https://github.com/phalcon/cphalcon/issues/13099) -- Refactored `Phalcon\Db\Adapter\Pdo::query` to use PDO's prepare and execute. `Phalcon\Db\Adapter::fetchAll` to use PDO's fetchAll +- Added the ability to explicitly define nullable columns (especially timestamp ones) [#13099](https://github.com/phalcon/cphalcon/issues/13099) +- Refactored `Phalcon\Db\Adapter\Pdo::query` to use PDO's prepare and execute and `Phalcon\Db\Adapter::fetchAll` to use PDO's fetchAll - Fixed `Phalcon\Validation\Validator\Numericality` to accept float numbers on locales with comma decimal point [#13450](https://github.com/phalcon/cphalcon/issues/13450) - Fixed `Phalcon\Tag` so it unsets `parameters` before passing options array to `self::renderAttributes` - Fixed `Phalcon\Http\Response::setFileToSend` filename; when file downloaded it had an extra `_` - Fixed `Phalcon\Mvc\Model\Query::execute` to properly bind parameters to sub queries [#11605](https://github.com/phalcon/cphalcon/issues/11605) -- Fixed `Phalcon\Http\Request::getJsonRawBody` [#13501](https://github.com/phalcon/cphalcon/issues/13501). It will now return false when the body content is empty, as well as when it encounters an error whilst decoding the JSON content. +- Fixed `Phalcon\Http\Request::getJsonRawBody` [#13501](https://github.com/phalcon/cphalcon/issues/13501). It will now return false when the body content is empty, as well as when it encounters an error whilst decoding the JSON content - Fixed `Phalcon\Validation::preChecking` to allow use `Phalcon\Db\RawValue` as an empty container for `isAllowEmpty` option [#13549](https://github.com/phalcon/cphalcon/pull/13549), [#13573](https://github.com/phalcon/cphalcon/issues/13573), [#12519](https://github.com/phalcon/cphalcon/pull/12519) -- Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058). +- Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058) - Fixed `Phalcon\Config\Adapter\Ini` not building config objects properly for numerical keys [#12725](https://github.com/phalcon/cphalcon/issues/12725), [#13604](https://github.com/phalcon/cphalcon/issues/13604) - Fixed object binding and placeholder creation in `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058) - Fixed incorrect scope of view variables diff --git a/phalcon/mvc/view.zep b/phalcon/mvc/view.zep index e42d62fc7e8..4fb7c98612e 100644 --- a/phalcon/mvc/view.zep +++ b/phalcon/mvc/view.zep @@ -839,9 +839,7 @@ class View extends Injectable implements ViewInterface * Create a virtual symbol table. * Variables are shared across symbol tables in PHP5 */ - if PHP_MAJOR_VERSION == 5 { - create_symbol_table(); - } + create_symbol_table(); /** * Call beforeRender if there is an events manager diff --git a/tests/_ci/install-prereqs.sh b/tests/_ci/install-prereqs.sh index e4014abce10..37019c082bb 100755 --- a/tests/_ci/install-prereqs.sh +++ b/tests/_ci/install-prereqs.sh @@ -9,11 +9,11 @@ PHP_VERNUM="$(`phpenv which php-config` --vernum)" -printf "\n" | pecl install --force apcu_bc &> /dev/null -printf "\n" | pecl install --force igbinary &> /dev/null -printf "\n" | pecl install --force imagick &> /dev/null -printf "\n" | pecl install --force psr &> /dev/null -printf "\n" | pecl install --force yaml-2.0.3 &> /dev/null +printf "\n" | pecl install --force apcu_bc 1> /dev/null +printf "\n" | pecl install --force igbinary 1> /dev/null +printf "\n" | pecl install --force imagick 1> /dev/null +printf "\n" | pecl install --force psr 1> /dev/null +printf "\n" | pecl install --force yaml-2.0.3 1> /dev/null # See https://pear.php.net/bugs/bug.php?id=21007 sed -i '1s/^/extension="apcu.so"\n/' "$(phpenv root)/versions/$(phpenv version-name)/etc/php.ini" diff --git a/tests/unit/Mvc/ViewTest.php b/tests/unit/Mvc/ViewTest.php index 7bc5a53eca8..c0564af2c29 100644 --- a/tests/unit/Mvc/ViewTest.php +++ b/tests/unit/Mvc/ViewTest.php @@ -646,6 +646,7 @@ function () { * Tests params view scope * * @issue https://github.com/phalcon/cphalcon/issues/12648 + * @issue https://github.com/phalcon/cphalcon/pull/13288 * @author Wojciech Ĺšlawski <jurigag@gmail.com> * @since 2017-03-17 */ @@ -667,7 +668,8 @@ function () { // FIXME: This test need to be refactored to not use try/catch try { echo $a_cool_var; - } catch (PhpUnitException $e) { + $this->fail('Variable a_cool_var is defined and is set to "' . $a_cool_var . '"'); + } catch (\PHPUnit_Framework_Exception $e) { expect($e->getMessage())->contains("Undefined variable: a_cool_var"); } } From 0981a30d44d575d239c72bbfc1032769c7cd99a5 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev <serghei@phalconphp.com> Date: Wed, 21 Nov 2018 00:23:21 +0200 Subject: [PATCH 22/23] AppVeyor use latest Zephir --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 0449b4af907..33dc60dc16d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -42,7 +42,7 @@ environment: PARSER_RELEASE: 401 PHALCON_STABLE_VERSION: 3.3.2 PSR_PECL_VERSION: 0.6.1 - ZEPHIR_VERSION: 0.10.12 + ZEPHIR_VERSION: 0.10.14 matrix: fast_finish: true From 3eb50b388d65c1bd98bc082c3ad27c00c601b7b6 Mon Sep 17 00:00:00 2001 From: Cameron Hall <me@chall.id.au> Date: Wed, 28 Nov 2018 10:43:44 +1100 Subject: [PATCH 23/23] Fixed broken view test --- tests/unit/Mvc/ViewTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Mvc/ViewTest.php b/tests/unit/Mvc/ViewTest.php index c0564af2c29..79e2af9fca7 100644 --- a/tests/unit/Mvc/ViewTest.php +++ b/tests/unit/Mvc/ViewTest.php @@ -669,7 +669,7 @@ function () { try { echo $a_cool_var; $this->fail('Variable a_cool_var is defined and is set to "' . $a_cool_var . '"'); - } catch (\PHPUnit_Framework_Exception $e) { + } catch (\PHPUnit\Framework\Exception $e) { expect($e->getMessage())->contains("Undefined variable: a_cool_var"); } }