From 77ec891ea7ac14f96dd7ad59fa66fb5466c81877 Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Fri, 23 Dec 2016 23:06:29 +0700 Subject: [PATCH 01/38] Fixing #718 : Dialect Oracle not working --- Library/Phalcon/Db/Dialect/Oracle.php | 50 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index 7f2288c18..e73f208bf 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -50,7 +50,7 @@ class Oracle extends Dialect { // @codingStandardsIgnoreStart - protected $_escapeChar = "'"; + protected $_escapeChar = ""; // @codingStandardsIgnoreEnd /** @@ -65,13 +65,15 @@ public function limit($sqlQuery, $number) $offset = 0; if (is_array($number)) { - if (isset($number[1])) { - $offset = intval(trim($number[1], $this->_escapeChar)); - } + //if (isset($number[1])) { + //$offset = intval(trim($number[1], $this->_escapeChar)); + $offset = $number[1] !=NULL? $number[1]:0; + //} - $limit = intval(trim($number[0], $this->_escapeChar)) + $offset; + //$limit = intval(trim($number[0], $this->_escapeChar)) + $offset; + $limit = $number[0]; } else { - $limit = intval(trim($number, $this->_escapeChar)); + $limit = $number; } $sqlQuery = sprintf( @@ -80,16 +82,15 @@ public function limit($sqlQuery, $number) $sqlQuery ); - if (0 != $limit) { - $sqlQuery .= sprintf(' WHERE ROWNUM <= %d', $limit); - } + //if (0 != $limit) { + $sqlQuery .= sprintf(' WHERE ROWNUM <= %s', $limit); + //} $sqlQuery .= ')'; - if (0 != $offset) { - $sqlQuery .= sprintf(' WHERE PHALCON_RN >= %d', $offset); - } - + //if (0 != $offset) { + $sqlQuery .= sprintf(' WHERE PHALCON_RN >= %s', $offset); + //} return $sqlQuery; } @@ -365,6 +366,9 @@ public function listTables($schemaName = null) */ public function tableExists($tableName, $schemaName = null) { + + $oldEscapeChar=$this->_escapeChar; + $this->_escapeChar = "'"; $tableName = $this->escape(Text::upper($tableName)); $baseQuery = sprintf( /** @lang text */ @@ -375,8 +379,9 @@ public function tableExists($tableName, $schemaName = null) if (!empty($schemaName)) { $schemaName = $this->escapeSchema($schemaName); - return sprintf("%s AND OWNER = %s", $baseQuery, Text::upper($schemaName)); + $baseQuery=sprintf("%s AND OWNER = %s", $baseQuery, Text::upper($schemaName)); } + $this->_escapeChar = $oldEscapeChar; return $baseQuery; } @@ -428,7 +433,7 @@ public function dropView($viewName, $schemaName = null, $ifExists = true) ); } - $this->_escapeChar = "'"; + //$this->_escapeChar = "'"; return $sql; } @@ -488,21 +493,26 @@ public function listViews($schemaName = null) */ public function describeColumns($table, $schema = null) { + $oldEscapeChar= $this->_escapeChar; + $this->_escapeChar = "'"; $table = $this->escape($table); $sql = 'SELECT TC.COLUMN_NAME, TC.DATA_TYPE, TC.DATA_LENGTH, TC.DATA_PRECISION, TC.DATA_SCALE, TC.NULLABLE, ' . 'C.CONSTRAINT_TYPE, TC.DATA_DEFAULT, CC.POSITION FROM ALL_TAB_COLUMNS TC LEFT JOIN ' . '(ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND ' . "CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P')) ON " . - 'TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE TC.TABLE_NAME = %s %s '. + 'TC.OWNER=CC.OWNER AND TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE TC.TABLE_NAME = %s %s '. 'ORDER BY TC.COLUMN_ID'; + if (!empty($schema)) { $schema = $this->escapeSchema($schema); - return sprintf($sql, Text::upper($table), 'AND TC.OWNER = ' . Text::upper($schema)); - } - - return sprintf($sql, Text::upper($table), ''); + $queryBase=sprintf($sql, Text::upper($table), 'AND TC.OWNER = ' . Text::upper($schema)); + }else { + $queryBase=sprintf($sql, Text::upper($table), ''); + } + $this->_escapeChar = $oldEscapeChar; + return $queryBase; } /** From 4326f767f726920f52c477b6cebf53473de741ef Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 24 Dec 2016 22:45:07 +0200 Subject: [PATCH 02/38] Used latest Phalcon --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2aa812ed6..a5c655cb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ env: - ZEND_DONT_UNLOAD_MODULES=1 - CC="ccache gcc" - PATH="$PATH:~/bin" - - PHALCON_VERSION="v3.0.2" + - PHALCON_VERSION="v3.0.3" before_install: - phpenv config-rm xdebug.ini || true From 93085adfe7814f0a499db47f530281187eeecae5 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 24 Dec 2016 23:08:26 +0200 Subject: [PATCH 03/38] Install Imagick --- .travis.yml | 2 +- tests/_ci/imagick.ini | 1 + tests/_ci/install_prereqs_5.5.sh | 3 +++ tests/_ci/install_prereqs_5.6.sh | 3 +++ tests/_ci/install_prereqs_7.0.sh | 3 +++ 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/_ci/imagick.ini diff --git a/.travis.yml b/.travis.yml index a5c655cb2..bb2a7b0ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,7 @@ install: - git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} - ln -s ${TRAVIS_BUILD_DIR}/.temp ${TRAVIS_BUILD_DIR}/cphalcon/.temp - ( cd cphalcon; zephir fullclean && zephir generate $ZEND_BACKEND ) - - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j3 &> /dev/null && make --silent install ) + - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j2 &> /dev/null && make --silent install ) - ( bash tests/_ci/install_prereqs_$PHP_MAJOR.sh ) before_script: diff --git a/tests/_ci/imagick.ini b/tests/_ci/imagick.ini new file mode 100644 index 000000000..d7513f1c8 --- /dev/null +++ b/tests/_ci/imagick.ini @@ -0,0 +1 @@ +extension=imagick.so diff --git a/tests/_ci/install_prereqs_5.5.sh b/tests/_ci/install_prereqs_5.5.sh index 7976782e9..b65eff798 100755 --- a/tests/_ci/install_prereqs_5.5.sh +++ b/tests/_ci/install_prereqs_5.5.sh @@ -27,3 +27,6 @@ phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini + +printf "\n" | pecl upgrade imagick &> /dev/null +phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/imagick.ini diff --git a/tests/_ci/install_prereqs_5.6.sh b/tests/_ci/install_prereqs_5.6.sh index 7976782e9..b65eff798 100755 --- a/tests/_ci/install_prereqs_5.6.sh +++ b/tests/_ci/install_prereqs_5.6.sh @@ -27,3 +27,6 @@ phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini + +printf "\n" | pecl upgrade imagick &> /dev/null +phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/imagick.ini diff --git a/tests/_ci/install_prereqs_7.0.sh b/tests/_ci/install_prereqs_7.0.sh index d604e41a1..5a63c3b74 100755 --- a/tests/_ci/install_prereqs_7.0.sh +++ b/tests/_ci/install_prereqs_7.0.sh @@ -52,3 +52,6 @@ phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini + +printf "\n" | pecl install imagick &> /dev/null +phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/imagick.ini From 5007552850c8cf4966563bc8c6f2851d4971d266 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 24 Dec 2016 23:13:29 +0200 Subject: [PATCH 04/38] Fixed Travis CI build --- .travis.yml | 3 ++- tests/_ci/install_prereqs_5.5.sh | 1 - tests/_ci/install_prereqs_5.6.sh | 1 - tests/_ci/install_prereqs_7.0.sh | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb2a7b0ce..9dba73bbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,13 +62,14 @@ before_install: install: - ( bash tests/_ci/install_zephir.sh ) + - ( bash tests/_ci/install_prereqs_$PHP_MAJOR.sh ) # See https://github.com/aerospike/aerospike-client-php/issues/127 - '[[ "${PHP_MAJOR:0:1}" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh' - git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} - ln -s ${TRAVIS_BUILD_DIR}/.temp ${TRAVIS_BUILD_DIR}/cphalcon/.temp - ( cd cphalcon; zephir fullclean && zephir generate $ZEND_BACKEND ) - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j2 &> /dev/null && make --silent install ) - - ( bash tests/_ci/install_prereqs_$PHP_MAJOR.sh ) + - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini before_script: - stty cols 160 diff --git a/tests/_ci/install_prereqs_5.5.sh b/tests/_ci/install_prereqs_5.5.sh index b65eff798..ffe5e6b48 100755 --- a/tests/_ci/install_prereqs_5.5.sh +++ b/tests/_ci/install_prereqs_5.5.sh @@ -23,7 +23,6 @@ echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.in printf "\n" | pecl install yaml > /dev/null 2>&1 phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini diff --git a/tests/_ci/install_prereqs_5.6.sh b/tests/_ci/install_prereqs_5.6.sh index b65eff798..ffe5e6b48 100755 --- a/tests/_ci/install_prereqs_5.6.sh +++ b/tests/_ci/install_prereqs_5.6.sh @@ -23,7 +23,6 @@ echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.in printf "\n" | pecl install yaml > /dev/null 2>&1 phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini diff --git a/tests/_ci/install_prereqs_7.0.sh b/tests/_ci/install_prereqs_7.0.sh index 5a63c3b74..07fe17c26 100755 --- a/tests/_ci/install_prereqs_7.0.sh +++ b/tests/_ci/install_prereqs_7.0.sh @@ -49,7 +49,6 @@ phpenv config-add "${TRAVIS_BUILD_DIR}/tests/_ci/apc_bc.ini" printf "\n" | pecl install yaml-2.0.0 >/dev/null 2>&1 phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini From 2f6fca92f0201f11e24b9c9b7ef65cfd9803e107 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 24 Dec 2016 23:22:22 +0200 Subject: [PATCH 05/38] Fixed install_prereqs --- .travis.yml | 1 + tests/_ci/install_aerospike.sh | 4 ++-- tests/_ci/install_prereqs_5.5.sh | 2 -- tests/_ci/install_prereqs_5.6.sh | 2 -- tests/_ci/install_prereqs_7.0.sh | 4 +--- tests/_ci/phalcon.ini | 2 +- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9dba73bbc..80c726e42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,7 @@ install: - ( cd cphalcon; zephir fullclean && zephir generate $ZEND_BACKEND ) - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j2 &> /dev/null && make --silent install ) - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini + - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini before_script: - stty cols 160 diff --git a/tests/_ci/install_aerospike.sh b/tests/_ci/install_aerospike.sh index 3f06ac18b..263597bdc 100755 --- a/tests/_ci/install_aerospike.sh +++ b/tests/_ci/install_aerospike.sh @@ -21,8 +21,8 @@ mkdir -p /tmp/aerospike-ext sudo mkdir -p /usr/local/aerospike/{lua,usr-lua} sudo chmod -R ugoa+rwx /usr/local/aerospike -ln -sf /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/local/lib/libcrypto.so -ln -sf /usr/lib/x86_64-linux-gnu/libcrypto.a /usr/local/lib/libcrypto.a +sudo ln -sf /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/local/lib/libcrypto.so +sudo ln -sf /usr/lib/x86_64-linux-gnu/libcrypto.a /usr/local/lib/libcrypto.a cd /tmp/aerospike-ext wget -O aerospike.zip https://github.com/aerospike/aerospike-client-php/archive/master.zip diff --git a/tests/_ci/install_prereqs_5.5.sh b/tests/_ci/install_prereqs_5.5.sh index ffe5e6b48..126f8b058 100755 --- a/tests/_ci/install_prereqs_5.5.sh +++ b/tests/_ci/install_prereqs_5.5.sh @@ -22,10 +22,8 @@ echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.in printf "\n" | pecl install yaml > /dev/null 2>&1 -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini printf "\n" | pecl upgrade imagick &> /dev/null -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/imagick.ini diff --git a/tests/_ci/install_prereqs_5.6.sh b/tests/_ci/install_prereqs_5.6.sh index ffe5e6b48..126f8b058 100755 --- a/tests/_ci/install_prereqs_5.6.sh +++ b/tests/_ci/install_prereqs_5.6.sh @@ -22,10 +22,8 @@ echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.in printf "\n" | pecl install yaml > /dev/null 2>&1 -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini printf "\n" | pecl upgrade imagick &> /dev/null -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/imagick.ini diff --git a/tests/_ci/install_prereqs_7.0.sh b/tests/_ci/install_prereqs_7.0.sh index 07fe17c26..42aae46e9 100755 --- a/tests/_ci/install_prereqs_7.0.sh +++ b/tests/_ci/install_prereqs_7.0.sh @@ -48,9 +48,7 @@ phpenv config-add "${TRAVIS_BUILD_DIR}/tests/_ci/apc_bc.ini" printf "\n" | pecl install yaml-2.0.0 >/dev/null 2>&1 -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini -printf "\n" | pecl install imagick &> /dev/null -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/imagick.ini +printf "\n" | pecl update imagick &> /dev/null diff --git a/tests/_ci/phalcon.ini b/tests/_ci/phalcon.ini index 2cd8583cd..bc2ac725f 100644 --- a/tests/_ci/phalcon.ini +++ b/tests/_ci/phalcon.ini @@ -10,7 +10,7 @@ ; to license@phalconphp.com so we can send you a copy immediately. [phalcon] -extension = phalcon.so +extension=phalcon.so ; phalcon.db.escape_identifiers = On ; phalcon.db.force_casting = Off From b59d6c2367ce6c0b766a4f0dbd4578afa5a320ca Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 24 Dec 2016 23:39:34 +0200 Subject: [PATCH 06/38] Introduced install_common.sh --- tests/_ci/install_common.sh | 60 ++++++++++++++++++++++++++++++++ tests/_ci/install_prereqs_5.5.sh | 17 ++++----- tests/_ci/install_prereqs_5.6.sh | 17 ++++----- tests/_ci/install_prereqs_7.0.sh | 37 +++----------------- 4 files changed, 79 insertions(+), 52 deletions(-) create mode 100644 tests/_ci/install_common.sh diff --git a/tests/_ci/install_common.sh b/tests/_ci/install_common.sh new file mode 100644 index 000000000..5852884ff --- /dev/null +++ b/tests/_ci/install_common.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# +# Phalcon Framework +# +# Copyright (c) 2011-2016 Phalcon Team (https://www.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. + +CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" + +CFLAGS="-O2 -g3 -fno-strict-aliasing -std=gnu90" + +pecl channel-update pecl.php.net || true + +enable_extension() { + if [ -z $(php -m | grep "${1}") ] && [ -f "${TRAVIS_BUILD_DIR}/tests/_ci/${1}.ini" ]; then + phpenv config-add "${TRAVIS_BUILD_DIR}/tests/_ci/${1}.ini" + fi +} + +install_extension() { + INSTALLED=$(pecl list "${1}" | grep 'not installed') + + if [ -z "${INSTALLED}" ]; then + printf "\n" | pecl upgrade "${1}" &> /dev/null + else + printf "\n" | pecl install "${1}" &> /dev/null + fi + + enable_extension "${1}" +} + +install_apcu() { + # See https://github.com/krakjoe/apcu/issues/203 + git clone -q https://github.com/krakjoe/apcu -b v5.1.7 /tmp/apcu + cd /tmp/apcu + + phpize &> /dev/null + ./configure &> /dev/null + + make --silent -j4 &> /dev/null + make --silent install +} + +install_apcu_bc() { + git clone -q https://github.com/krakjoe/apcu-bc /tmp/apcu-bc + cd /tmp/apcu-bc + + phpize &> /dev/null + ./configure &> /dev/null + + make --silent -j4 &> /dev/null + make --silent install +} diff --git a/tests/_ci/install_prereqs_5.5.sh b/tests/_ci/install_prereqs_5.5.sh index 126f8b058..ceef7eaae 100755 --- a/tests/_ci/install_prereqs_5.5.sh +++ b/tests/_ci/install_prereqs_5.5.sh @@ -14,16 +14,13 @@ CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" -pecl channel-update pecl.php.net +source ${TRAVIS_BUILD_DIR}/tests/_ci/install_common.sh -printf "\n" | pecl install apcu-4.0.11 &> /dev/null +install_extension imagick +install_extension yaml +enable_extension memcached +enable_extension mongo +enable_extension mongodb +printf "\n" | pecl install apcu-4.0.11 &> /dev/null echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - -printf "\n" | pecl install yaml > /dev/null 2>&1 - -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini - -printf "\n" | pecl upgrade imagick &> /dev/null diff --git a/tests/_ci/install_prereqs_5.6.sh b/tests/_ci/install_prereqs_5.6.sh index 126f8b058..ceef7eaae 100755 --- a/tests/_ci/install_prereqs_5.6.sh +++ b/tests/_ci/install_prereqs_5.6.sh @@ -14,16 +14,13 @@ CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" -pecl channel-update pecl.php.net +source ${TRAVIS_BUILD_DIR}/tests/_ci/install_common.sh -printf "\n" | pecl install apcu-4.0.11 &> /dev/null +install_extension imagick +install_extension yaml +enable_extension memcached +enable_extension mongo +enable_extension mongodb +printf "\n" | pecl install apcu-4.0.11 &> /dev/null echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - -printf "\n" | pecl install yaml > /dev/null 2>&1 - -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongo.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini - -printf "\n" | pecl upgrade imagick &> /dev/null diff --git a/tests/_ci/install_prereqs_7.0.sh b/tests/_ci/install_prereqs_7.0.sh index 42aae46e9..46bfdf887 100755 --- a/tests/_ci/install_prereqs_7.0.sh +++ b/tests/_ci/install_prereqs_7.0.sh @@ -14,41 +14,14 @@ CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}" -CFLAGS="-O2 -g3 -fno-strict-aliasing -std=gnu90"; - -pecl channel-update pecl.php.net - -install_apcu() { - # See https://github.com/krakjoe/apcu/issues/203 - git clone -q https://github.com/krakjoe/apcu -b v5.1.7 /tmp/apcu - cd /tmp/apcu - - phpize &> /dev/null - ./configure &> /dev/null - - make --silent -j4 &> /dev/null - make --silent install -} - -install_apcu_bc() { - git clone -q https://github.com/krakjoe/apcu-bc /tmp/apcu-bc - cd /tmp/apcu-bc - - phpize &> /dev/null - ./configure &> /dev/null - - make --silent -j4 &> /dev/null - make --silent install -} +source ${TRAVIS_BUILD_DIR}/tests/_ci/install_common.sh install_apcu install_apcu_bc -phpenv config-add "${TRAVIS_BUILD_DIR}/tests/_ci/apc_bc.ini" +enable_extension apc_bc +enable_extension mongodb +enable_extension memcached +install_extension imagick printf "\n" | pecl install yaml-2.0.0 >/dev/null 2>&1 - -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/mongodb.ini -phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/memcached.ini - -printf "\n" | pecl update imagick &> /dev/null From 34bbcedfc685907035f01afbbd91788ab82845d4 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 24 Dec 2016 23:45:58 +0200 Subject: [PATCH 07/38] Speed up Travis CI build --- .travis.yml | 5 ++++- tests/_ci/install_common.sh | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80c726e42..8b2500835 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,12 +65,15 @@ install: - ( bash tests/_ci/install_prereqs_$PHP_MAJOR.sh ) # See https://github.com/aerospike/aerospike-client-php/issues/127 - '[[ "${PHP_MAJOR:0:1}" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh' - - git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} + - git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} >/dev/null 2>&1 - ln -s ${TRAVIS_BUILD_DIR}/.temp ${TRAVIS_BUILD_DIR}/cphalcon/.temp - ( cd cphalcon; zephir fullclean && zephir generate $ZEND_BACKEND ) - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j2 &> /dev/null && make --silent install ) - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini + # Debug + - php -m + - pecl list before_script: - stty cols 160 diff --git a/tests/_ci/install_common.sh b/tests/_ci/install_common.sh index 5852884ff..6e37168e5 100644 --- a/tests/_ci/install_common.sh +++ b/tests/_ci/install_common.sh @@ -38,23 +38,23 @@ install_extension() { install_apcu() { # See https://github.com/krakjoe/apcu/issues/203 - git clone -q https://github.com/krakjoe/apcu -b v5.1.7 /tmp/apcu + git clone -q https://github.com/krakjoe/apcu -b v5.1.7 /tmp/apcu >/dev/null 2>&1 cd /tmp/apcu phpize &> /dev/null ./configure &> /dev/null - make --silent -j4 &> /dev/null + make --silent -j2 &> /dev/null make --silent install } install_apcu_bc() { - git clone -q https://github.com/krakjoe/apcu-bc /tmp/apcu-bc + git clone -q https://github.com/krakjoe/apcu-bc /tmp/apcu-bc >/dev/null 2>&1 cd /tmp/apcu-bc phpize &> /dev/null ./configure &> /dev/null - make --silent -j4 &> /dev/null + make --silent -j2 &> /dev/null make --silent install } From f8be862a08738153e50fd07efe2e33073a86897c Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 17:27:27 +0700 Subject: [PATCH 08/38] Remove commented code --- Library/Phalcon/Db/Dialect/Oracle.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index e73f208bf..75d1f61ac 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -65,12 +65,7 @@ public function limit($sqlQuery, $number) $offset = 0; if (is_array($number)) { - //if (isset($number[1])) { - //$offset = intval(trim($number[1], $this->_escapeChar)); - $offset = $number[1] !=NULL? $number[1]:0; - //} - - //$limit = intval(trim($number[0], $this->_escapeChar)) + $offset; + $offset = $number[1] !=NULL? $number[1]:0; $limit = $number[0]; } else { $limit = $number; @@ -82,15 +77,11 @@ public function limit($sqlQuery, $number) $sqlQuery ); - //if (0 != $limit) { - $sqlQuery .= sprintf(' WHERE ROWNUM <= %s', $limit); - //} + $sqlQuery .= sprintf(' WHERE ROWNUM <= %s', $limit); $sqlQuery .= ')'; - //if (0 != $offset) { - $sqlQuery .= sprintf(' WHERE PHALCON_RN >= %s', $offset); - //} + $sqlQuery .= sprintf(' WHERE PHALCON_RN >= %s', $offset); return $sqlQuery; } @@ -433,8 +424,6 @@ public function dropView($viewName, $schemaName = null, $ifExists = true) ); } - //$this->_escapeChar = "'"; - return $sql; } From a7d2f3a3711601379efb5ea5a341a865c88b0c4f Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 17:54:52 +0700 Subject: [PATCH 09/38] Fix Travis CI build --- Library/Phalcon/Db/Dialect/Oracle.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index 75d1f61ac..2b3e158bd 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -65,7 +65,7 @@ public function limit($sqlQuery, $number) $offset = 0; if (is_array($number)) { - $offset = $number[1] !=NULL? $number[1]:0; + $offset = $number[1] !=null? $number[1]:0; $limit = $number[0]; } else { $limit = $number; @@ -497,11 +497,11 @@ public function describeColumns($table, $schema = null) $schema = $this->escapeSchema($schema); $queryBase=sprintf($sql, Text::upper($table), 'AND TC.OWNER = ' . Text::upper($schema)); - }else { + } else { $queryBase=sprintf($sql, Text::upper($table), ''); - } + } $this->_escapeChar = $oldEscapeChar; - return $queryBase; + return $queryBase; } /** From ab1fadd2492a74289133b75ab72698374b53dd85 Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 18:04:03 +0700 Subject: [PATCH 10/38] Fix Travis Build #1546 --- Library/Phalcon/Db/Dialect/Oracle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index 2b3e158bd..e72a349c8 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -489,7 +489,7 @@ public function describeColumns($table, $schema = null) 'C.CONSTRAINT_TYPE, TC.DATA_DEFAULT, CC.POSITION FROM ALL_TAB_COLUMNS TC LEFT JOIN ' . '(ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND ' . "CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P')) ON " . - 'TC.OWNER=CC.OWNER AND TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE TC.TABLE_NAME = %s %s '. + 'TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE TC.TABLE_NAME = %s %s '. 'ORDER BY TC.COLUMN_ID'; From 7748745a30f5afbd49cae3f89c6ff7baecf281d6 Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 18:12:39 +0700 Subject: [PATCH 11/38] Rebuild Travis --- Library/Phalcon/Db/Dialect/Oracle.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index e72a349c8..6b9bbd341 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -578,6 +578,7 @@ public function supportsReleaseSavepoints() return false; } + /** * Prepares table for this RDBMS. * From 9d4a205fb4de01f7b849a3d272f70c187927a7e2 Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 18:23:18 +0700 Subject: [PATCH 12/38] Rebuild Travis --- Library/Phalcon/Db/Dialect/Oracle.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index 6b9bbd341..e72a349c8 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -578,7 +578,6 @@ public function supportsReleaseSavepoints() return false; } - /** * Prepares table for this RDBMS. * From 321d2237bc2efce196becaf3d60bcdcf9839911a Mon Sep 17 00:00:00 2001 From: cottton Date: Fri, 20 Jan 2017 13:09:40 +0100 Subject: [PATCH 13/38] ::initPostFields checks for \CURLFile Should check each param is is a `\CURLFile` f.e. created via `curl_file_create($file)`. Example: $provider = \Phalcon\Http\Client\Request::getProvider(); // POST a file $file = '/home/mine/myimage.jpg'; $response = $provider->post('me/upload', [ 'access_token' => 1234, 'file' => curl_file_create(realpath($file)), ]); echo $response->header->statusCode; Reason: See `CURLOPT_SAFE_UPLOAD` http://php.net/manual/en/function.curl-setopt.php `Added in PHP 5.5.0 with FALSE as the default value. PHP 5.6.0 changes the default value to TRUE.` _and disabled with PHP 7_ --- Library/Phalcon/Http/Client/Provider/Curl.php | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index d54bff07f..1171a277d 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -168,20 +168,15 @@ protected function send(array $customHeader = [], $fullResponse = false) * * @param mixed $params Data to send. * @param boolean $useEncoding Whether to url-encode params. Defaults to true. + * Will not use encoding if a value in params + * is a file. * * @return void */ protected function initPostFields($params, $useEncoding = true) { if (is_array($params)) { - foreach ($params as $param) { - if (is_string($param) && strpos($param, '@') === 0) { - $useEncoding = false; - break; - } - } - - if ($useEncoding) { + if ($useEncoding and $this->canUseEncoding($params)) { $params = http_build_query($params); } } @@ -190,6 +185,29 @@ protected function initPostFields($params, $useEncoding = true) $this->setOption(CURLOPT_POSTFIELDS, $params); } } + + /** + * Returns if can url-encode params. + * + * @param array $params + * + * @return bool + */ + private function canUseEncoding(array $params) + { + $classCurlFile = class_exists('\CURLFile') + ? '\CURLFile' + : null; + foreach ($params as $value) { + if ( + (is_string($value) and strpos($value, '@') === 0) + or ($classCurlFile and is_a($value, $classCurlFile)) + ) { + return false; + } + } + return true; + } /** * Setup authentication From a5a264a50a9cdf255b1df4376780cd5718b898e5 Mon Sep 17 00:00:00 2001 From: cottton Date: Mon, 23 Jan 2017 11:44:09 +0100 Subject: [PATCH 14/38] fixed stuff =) --- Library/Phalcon/Http/Client/Provider/Curl.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index 1171a277d..adb437d6c 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -176,7 +176,7 @@ protected function send(array $customHeader = [], $fullResponse = false) protected function initPostFields($params, $useEncoding = true) { if (is_array($params)) { - if ($useEncoding and $this->canUseEncoding($params)) { + if ($useEncoding && $this->canUseEncoding($params)) { $params = http_build_query($params); } } @@ -185,7 +185,7 @@ protected function initPostFields($params, $useEncoding = true) $this->setOption(CURLOPT_POSTFIELDS, $params); } } - + /** * Returns if can url-encode params. * @@ -200,14 +200,14 @@ private function canUseEncoding(array $params) : null; foreach ($params as $value) { if ( - (is_string($value) and strpos($value, '@') === 0) - or ($classCurlFile and is_a($value, $classCurlFile)) + (is_string($value) && strpos($value, '@') === 0) + or ($classCurlFile && $value instanceof $classCurlFile) ) { return false; } } return true; - } + } /** * Setup authentication From aa197021f7c47d85d62d26ecb28d0eca4c879ddd Mon Sep 17 00:00:00 2001 From: cottton Date: Mon, 23 Jan 2017 12:53:25 +0100 Subject: [PATCH 15/38] fixed || instead of or --- Library/Phalcon/Http/Client/Provider/Curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index adb437d6c..805e90be7 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -201,7 +201,7 @@ private function canUseEncoding(array $params) foreach ($params as $value) { if ( (is_string($value) && strpos($value, '@') === 0) - or ($classCurlFile && $value instanceof $classCurlFile) + || ($classCurlFile && $value instanceof $classCurlFile) ) { return false; } From 178d8fab93ea9152598d8b6ad257340f5f5b95bd Mon Sep 17 00:00:00 2001 From: cottton Date: Wed, 25 Jan 2017 13:36:13 +0100 Subject: [PATCH 16/38] ::canUseEncoding to protected --- Library/Phalcon/Http/Client/Provider/Curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index 805e90be7..638a68b05 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -193,7 +193,7 @@ protected function initPostFields($params, $useEncoding = true) * * @return bool */ - private function canUseEncoding(array $params) + protected function canUseEncoding(array $params) { $classCurlFile = class_exists('\CURLFile') ? '\CURLFile' From 1d0497b1f872e81263ef0dd0de2447b0a842750c Mon Sep 17 00:00:00 2001 From: cottton Date: Fri, 27 Jan 2017 13:47:08 +0100 Subject: [PATCH 17/38] fixed new line / white spaces --- Library/Phalcon/Http/Client/Provider/Curl.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index 638a68b05..1d7f71ea7 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -199,15 +199,14 @@ protected function canUseEncoding(array $params) ? '\CURLFile' : null; foreach ($params as $value) { - if ( - (is_string($value) && strpos($value, '@') === 0) + if ((is_string($value) && strpos($value, '@') === 0) || ($classCurlFile && $value instanceof $classCurlFile) ) { return false; } } return true; - } + } /** * Setup authentication From 7bc3ae96b2d1bda66be153faf4929620e6a74daf Mon Sep 17 00:00:00 2001 From: cottton Date: Tue, 14 Feb 2017 14:00:24 +0100 Subject: [PATCH 18/38] Added ::setOption ::setOptions CURLOPT_XXX alias (#730) * Added ::setOption ::setOptions CURLOPT_XXX alias Addded simple check if given option key is a curlopt_xxx string * Fixed no space found after comma * Fixed no space found after comma --- .../MongoDB/Operation/FindOneAndReplace.php | 2 +- .../MongoDB/Operation/FindOneAndUpdate.php | 2 +- Library/Phalcon/Http/Client/Provider/Curl.php | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndReplace.php b/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndReplace.php index a1eb26fda..d9656c93a 100644 --- a/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndReplace.php +++ b/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndReplace.php @@ -122,7 +122,7 @@ public function __construct($databaseName, $collectionName, $filter, $replacemen $options['new']=$options['returnDocument']===self::RETURN_DOCUMENT_AFTER; - unset($options['projection'],$options['returnDocument']); + unset($options['projection'], $options['returnDocument']); $this->findAndModify=new FindAndModify($databaseName, $collectionName, ['query' =>$filter, 'update'=>$replacement diff --git a/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndUpdate.php b/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndUpdate.php index effaa2048..def38cc98 100644 --- a/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndUpdate.php +++ b/Library/Phalcon/Db/Adapter/MongoDB/Operation/FindOneAndUpdate.php @@ -122,7 +122,7 @@ public function __construct($databaseName, $collectionName, $filter, $update, ar $options['new']=$options['returnDocument']===self::RETURN_DOCUMENT_AFTER; - unset($options['projection'],$options['returnDocument']); + unset($options['projection'], $options['returnDocument']); $this->findAndModify=new FindAndModify($databaseName, $collectionName, ['query' =>$filter, 'update'=>$update diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index 1d7f71ea7..ad01611a2 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -86,16 +86,56 @@ private function initOptions() ]); } + /** + * Sets an option. + * + * @param string|int $option + * @param mixed $value + * + * @return bool + */ public function setOption($option, $value) { + if ($this->isCurlOptString($option)) { + $option = constant(strtoupper($option)); + } return curl_setopt($this->handle, $option, $value); } + /** + * Sets multiple options at once. + * + * @param array $options + * + * @return bool + */ public function setOptions($options) { + foreach ($options as $option => $value) { + if ($this->isCurlOptString($option)) { + $options[constant(strtoupper($option))] = $value; + unset($options[$option]); + } + } return curl_setopt_array($this->handle, $options); } + /** + * Returns if the given string is an alias for a CURLOPT_XXX option. + * + * Example: "curlopt_header" === CURLOPT_HEADER + * + * @param mixed $option + * + * @return bool + */ + protected function isCurlOptString($option) + { + return (is_string($option) + && strpos(strtoupper($option), 'CURLOPT_') === 0 + && defined(strtoupper($option))); + } + public function setTimeout($timeout) { $this->setOption(CURLOPT_TIMEOUT, $timeout); From 5e77047268b5a280ca3b1663d9f30fe242505f31 Mon Sep 17 00:00:00 2001 From: cottton Date: Wed, 15 Feb 2017 21:27:02 +0100 Subject: [PATCH 19/38] Fixed lost curl error (#726) * Fixed lost curl error Moving __destruct -fix ("release" Curl instance from header function) to bottom -- before return. * Fixed no space found after comma * Fixed no space found after comma --- Library/Phalcon/Http/Client/Provider/Curl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Phalcon/Http/Client/Provider/Curl.php b/Library/Phalcon/Http/Client/Provider/Curl.php index ad01611a2..5848aa49f 100644 --- a/Library/Phalcon/Http/Client/Provider/Curl.php +++ b/Library/Phalcon/Http/Client/Provider/Curl.php @@ -189,8 +189,6 @@ protected function send(array $customHeader = [], $fullResponse = false) $content = curl_exec($this->handle); - $this->setOption(CURLOPT_HEADERFUNCTION, null); - if ($errno = curl_errno($this->handle)) { throw new HttpException(curl_error($this->handle), $errno); } @@ -200,6 +198,8 @@ protected function send(array $customHeader = [], $fullResponse = false) $response->body = $content; + $this->setOption(CURLOPT_HEADERFUNCTION, null); + return $response; } From bce53a03210aa055a3d4cabb75cf2b56244b72f1 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 1 Mar 2017 00:16:49 +0200 Subject: [PATCH 20/38] Use latest Phalcon --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8b2500835..7bb11a895 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ env: - ZEND_DONT_UNLOAD_MODULES=1 - CC="ccache gcc" - PATH="$PATH:~/bin" - - PHALCON_VERSION="v3.0.3" + - PHALCON_VERSION="v3.0.4" before_install: - phpenv config-rm xdebug.ini || true @@ -68,7 +68,7 @@ install: - git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} >/dev/null 2>&1 - ln -s ${TRAVIS_BUILD_DIR}/.temp ${TRAVIS_BUILD_DIR}/cphalcon/.temp - ( cd cphalcon; zephir fullclean && zephir generate $ZEND_BACKEND ) - - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j2 &> /dev/null && make --silent install ) + - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j"$(getconf _NPROCESSORS_ONLN)" &> /dev/null && make --silent install ) - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini # Debug From 442879abe50197e599361d392e03553d9d627f1d Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 1 Mar 2017 08:20:34 +0200 Subject: [PATCH 21/38] Improved Phalcon\Tests\Queue\Beanstalk\ExtendedTest --- .travis.yml | 4 ++++ tests/unit/Queue/Beanstalk/ExtendedTest.php | 24 ++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bb11a895..7c94c7319 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,6 +74,7 @@ install: # Debug - php -m - pecl list + - ipcs -m before_script: - stty cols 160 @@ -90,6 +91,9 @@ script: - vendor/bin/codecept build - vendor/bin/codecept run +after_failure: + - ipcs -m + notifications: email: recipients: diff --git a/tests/unit/Queue/Beanstalk/ExtendedTest.php b/tests/unit/Queue/Beanstalk/ExtendedTest.php index a088ce510..3e5a96e2c 100644 --- a/tests/unit/Queue/Beanstalk/ExtendedTest.php +++ b/tests/unit/Queue/Beanstalk/ExtendedTest.php @@ -1,17 +1,18 @@ * @package Phalcon\Tests\Queue\Beanstalk * @group Beanstalk @@ -26,7 +27,7 @@ class ExtendedTest extends Test { const TUBE_NAME = 'test-tube'; - const JOB_CLASS = 'Phalcon\Queue\Beanstalk\Job'; + const JOB_CLASS = Job::class; /** * UnitTester Object @@ -35,7 +36,7 @@ class ExtendedTest extends Test protected $tester; /** - * @var \Phalcon\Queue\Beanstalk\Extended + * @var Extended */ protected $client = null; @@ -188,8 +189,15 @@ public function testShouldDoWork() $actual = explode("\n", trim($output)); - // Compare number of items in expected list with lines in shared memory - $this->assertEquals(count($expected), count($actual)); + $this->assertEquals( + count($expected), + count($actual), + sprintf( + "Compare number of items in expected list with lines in shared memory failed.\nExpected: %s\nActual: %s\n", + json_encode($expected, JSON_PRETTY_PRINT), + json_encode($actual, JSON_PRETTY_PRINT) + ) + ); foreach ($actual as $value) { $this->assertArrayHasKey($value, $expected); From ac3d8c1abe92b56899a6b72c5f902ac25af616ab Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 1 Mar 2017 22:38:13 +0200 Subject: [PATCH 22/38] Fixed tests (#741) * Small cleanup * Be verbose on tests * Cleaned Beanstalk ExtendedTest --- .travis.yml | 2 +- phpcs.xml | 4 ++-- tests/unit/Queue/Beanstalk/ExtendedTest.php | 20 +++++++------------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c94c7319..2a639d033 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,7 +89,7 @@ before_script: script: - vendor/bin/phpcs - vendor/bin/codecept build - - vendor/bin/codecept run + - vendor/bin/codecept run -v after_failure: - ipcs -m diff --git a/phpcs.xml b/phpcs.xml index f7582ce68..649e2a973 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,5 +1,6 @@ - + + - Phalcon Incubator Coding Standards diff --git a/tests/unit/Queue/Beanstalk/ExtendedTest.php b/tests/unit/Queue/Beanstalk/ExtendedTest.php index 3e5a96e2c..9a8073e96 100644 --- a/tests/unit/Queue/Beanstalk/ExtendedTest.php +++ b/tests/unit/Queue/Beanstalk/ExtendedTest.php @@ -27,7 +27,6 @@ class ExtendedTest extends Test { const TUBE_NAME = 'test-tube'; - const JOB_CLASS = Job::class; /** * UnitTester Object @@ -66,13 +65,6 @@ protected function _before() $this->shmKey = round(microtime(true) * 1000); } - /** - * executed after each test - */ - protected function _after() - { - } - public function testShouldPutAndReserve() { $jobId = $this->client->putInTube(self::TUBE_NAME, 'testPutInTube'); @@ -82,7 +74,7 @@ public function testShouldPutAndReserve() $job = $this->client->reserveFromTube(self::TUBE_NAME); $this->assertNotEmpty($job); - $this->assertInstanceOf(self::JOB_CLASS, $job); + $this->assertInstanceOf(Job::class, $job); $this->assertEquals($jobId, $job->getId()); $this->assertTrue($job->delete()); } @@ -148,9 +140,11 @@ public function testShouldDoWork() $fork = new \duncan3dc\Forker\Fork; } - $fork->call(function () use ($expected) { + $that = $this; + + $fork->call(function () use ($expected, $that) { foreach ($expected as $tube => $value) { - $this->client->addWorker($tube, function (Job $job) { + $that->client->addWorker($tube, function (Job $job) { // Store string "test-tube-%JOB_BODY%" in a shared memory $memory = shmop_open($this->shmKey, 'c', 0644, $this->shmLimit); $output = trim(shmop_read($memory, 0, $this->shmLimit)); @@ -162,10 +156,10 @@ public function testShouldDoWork() throw new \RuntimeException('Forced exception to stop worker'); }); - $this->assertNotEquals(false, $this->client->putInTube($tube, $value)); + $that->assertNotEquals(false, $that->client->putInTube($tube, $value)); } - $this->client->doWork(); + $that->client->doWork(); exit(0); }); From 4e43e64024a705699137e760c41c909283f634a6 Mon Sep 17 00:00:00 2001 From: kdays Date: Tue, 28 Feb 2017 18:10:25 +0800 Subject: [PATCH 23/38] Fix MongoCollection::find missing $base class --- Library/Phalcon/Mvc/MongoCollection.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Library/Phalcon/Mvc/MongoCollection.php b/Library/Phalcon/Mvc/MongoCollection.php index d32119546..fe6afc942 100644 --- a/Library/Phalcon/Mvc/MongoCollection.php +++ b/Library/Phalcon/Mvc/MongoCollection.php @@ -209,14 +209,13 @@ protected static function _getResultset($params, CollectionInterface $collection */ if (isset($params['class'])) { $classname = $params['class']; - $base = new $classname(); - + if (!$base instanceof CollectionInterface || $base instanceof Document) { throw new Exception( sprintf( 'Object of class "%s" must be an implementation of %s or an instance of %s', - get_class($classname), + get_class($base), CollectionInterface::class, Document::class ) @@ -300,7 +299,8 @@ protected static function _getResultset($params, CollectionInterface $collection */ $cursor = $mongoCollection->find($conditions, $options); - $cursor->setTypeMap(['root'=>get_called_class(),'document'=>'object']); + + $cursor->setTypeMap(['root' => get_class($base), 'document' => 'array']); if (true === $unique) { /** @@ -313,8 +313,6 @@ protected static function _getResultset($params, CollectionInterface $collection * Requesting a complete resultset */ $collections = []; - - foreach ($cursor as $document) { /** * Assign the values to the base object From fab56222fdcf112b2597b1fa14af4ae05c07c260 Mon Sep 17 00:00:00 2001 From: Julien Turbide Date: Mon, 27 Feb 2017 14:27:19 -0500 Subject: [PATCH 24/38] Update Slug.php fix attempt for Warning: setlocale(): Specified locale name is too long needs to be tested deeper --- Library/Phalcon/Utils/Slug.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Phalcon/Utils/Slug.php b/Library/Phalcon/Utils/Slug.php index d381b4d00..234cd76a8 100644 --- a/Library/Phalcon/Utils/Slug.php +++ b/Library/Phalcon/Utils/Slug.php @@ -73,7 +73,8 @@ public static function generate($string, $replace = [], $delimiter = '-') $clean = trim($clean, $delimiter); // Revert back to the old locale - setlocale(LC_ALL, $oldLocale); + parse_str(str_replace(';', '&', $oldLocale), $loc); + setlocale(LC_ALL, $loc); return $clean; } From 86518443d8688ef5eefdf8c117355d54cd2b2ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20Valher?= Date: Fri, 10 Feb 2017 10:21:09 +0100 Subject: [PATCH 25/38] Use new PHPUnit class autoloader, increase PHPUnit version to ^5, #727 --- Library/Phalcon/Test/FunctionalTestCase.php | 26 ++++++++++----------- Library/Phalcon/Test/UnitTestCase.php | 2 +- composer.json | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Library/Phalcon/Test/FunctionalTestCase.php b/Library/Phalcon/Test/FunctionalTestCase.php index 3ab941eca..a6da090ec 100644 --- a/Library/Phalcon/Test/FunctionalTestCase.php +++ b/Library/Phalcon/Test/FunctionalTestCase.php @@ -93,13 +93,13 @@ protected function dispatch($url) * Assert that the last dispatched controller matches the given controller class name * * @param string $expected The expected controller name - * @throws \PHPUnit_Framework_ExpectationFailedException + * @throws \PHPUnit\Framework\ExpectationFailedException */ public function assertController($expected) { $actual = $this->di->getShared('dispatcher')->getControllerName(); if ($actual != $expected) { - throw new \PHPUnit_Framework_ExpectationFailedException( + throw new \PHPUnit\Framework\ExpectationFailedException( sprintf( 'Failed asserting Controller name "%s", actual Controller name is "%s"', $expected, @@ -115,13 +115,13 @@ public function assertController($expected) * Assert that the last dispatched action matches the given action name * * @param string $expected The expected action name - * @throws \PHPUnit_Framework_ExpectationFailedException + * @throws \PHPUnit\Framework\ExpectationFailedException */ public function assertAction($expected) { $actual = $this->di->getShared('dispatcher')->getActionName(); if ($actual != $expected) { - throw new \PHPUnit_Framework_ExpectationFailedException( + throw new \PHPUnit\Framework\ExpectationFailedException( sprintf( 'Failed asserting Action name "%s", actual Action name is "%s"', $expected, @@ -139,14 +139,14 @@ public function assertAction($expected) * * * @param array $expected The expected headers - * @throws \PHPUnit_Framework_ExpectationFailedException + * @throws \PHPUnit\Framework\ExpectationFailedException */ public function assertHeader(array $expected) { foreach ($expected as $expectedField => $expectedValue) { $actualValue = $this->di->getShared('response')->getHeaders()->get($expectedField); if ($actualValue != $expectedValue) { - throw new \PHPUnit_Framework_ExpectationFailedException( + throw new \PHPUnit\Framework\ExpectationFailedException( sprintf( 'Failed asserting "%s" has a value of "%s", actual "%s" header value is "%s"', $expectedField, @@ -164,7 +164,7 @@ public function assertHeader(array $expected) * Asserts that the response code matches the given one * * @param string $expected the expected response code - * @throws \PHPUnit_Framework_ExpectationFailedException + * @throws \PHPUnit\Framework\ExpectationFailedException */ public function assertResponseCode($expected) { @@ -176,7 +176,7 @@ public function assertResponseCode($expected) $actualValue = $this->di->getShared('response')->getHeaders()->get('Status'); if (empty($actualValue) || stristr($actualValue, $expected) === false) { - throw new \PHPUnit_Framework_ExpectationFailedException( + throw new \PHPUnit\Framework\ExpectationFailedException( sprintf( 'Failed asserting response code is "%s", actual response status is "%s"', $expected, @@ -191,7 +191,7 @@ public function assertResponseCode($expected) /** * Asserts that the dispatch is forwarded * - * @throws \PHPUnit_Framework_ExpectationFailedException + * @throws \PHPUnit\Framework\ExpectationFailedException */ public function assertDispatchIsForwarded() { @@ -200,7 +200,7 @@ public function assertDispatchIsForwarded() $actual = $dispatcher->wasForwarded(); if (!$actual) { - throw new \PHPUnit_Framework_ExpectationFailedException('Failed asserting dispatch was forwarded'); + throw new \PHPUnit\Framework\ExpectationFailedException('Failed asserting dispatch was forwarded'); } $this->assertTrue($actual); @@ -210,18 +210,18 @@ public function assertDispatchIsForwarded() * Assert location redirect * * @param string $location - * @throws \PHPUnit_Framework_ExpectationFailedException + * @throws \PHPUnit\Framework\ExpectationFailedException */ public function assertRedirectTo($location) { $actualLocation = $this->di->getShared('response')->getHeaders()->get('Location'); if (!$actualLocation) { - throw new \PHPUnit_Framework_ExpectationFailedException('Failed asserting response caused a redirect'); + throw new \PHPUnit\Framework\ExpectationFailedException('Failed asserting response caused a redirect'); } if ($actualLocation !== $location) { - throw new \PHPUnit_Framework_ExpectationFailedException(sprintf( + throw new \PHPUnit\Framework\ExpectationFailedException(sprintf( 'Failed asserting response redirects to "%s". It redirects to "%s".', $location, $actualLocation diff --git a/Library/Phalcon/Test/UnitTestCase.php b/Library/Phalcon/Test/UnitTestCase.php index ebe7e213a..2d91d158b 100644 --- a/Library/Phalcon/Test/UnitTestCase.php +++ b/Library/Phalcon/Test/UnitTestCase.php @@ -20,7 +20,7 @@ namespace Phalcon\Test; use Phalcon\Di\InjectionAwareInterface; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase as TestCase; use Phalcon\Config; use Phalcon\Di\FactoryDefault; use Phalcon\Di; diff --git a/composer.json b/composer.json index 88dd39715..a36d7b8b3 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", - "phpunit/phpunit": "^4.8", + "phpunit/phpunit": "^5", "squizlabs/php_codesniffer": "^2.7", "codeception/codeception": "^2.2", "codeception/mockery-module": "^0.2", From 3cc50bc3bade89caa43f2b19deaecd9ff6e1da4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20Valher?= Date: Fri, 10 Feb 2017 11:14:08 +0100 Subject: [PATCH 26/38] Revert increasing of PHPUnit version, #727 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a36d7b8b3..88dd39715 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", - "phpunit/phpunit": "^5", + "phpunit/phpunit": "^4.8", "squizlabs/php_codesniffer": "^2.7", "codeception/codeception": "^2.2", "codeception/mockery-module": "^0.2", From d8962d80a5d0fc537ad197fdedde70a966990912 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 1 Mar 2017 22:12:15 +0200 Subject: [PATCH 27/38] Be verbose on tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2a639d033..ed3c8bd20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,7 +89,7 @@ before_script: script: - vendor/bin/phpcs - vendor/bin/codecept build - - vendor/bin/codecept run -v + - vendor/bin/codecept run -vvv after_failure: - ipcs -m From f8290cd046d50549c953b987b92830f944cf3b22 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 1 Mar 2017 22:13:08 +0200 Subject: [PATCH 28/38] Cleaned Beanstalk ExtendedTest --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ed3c8bd20..2a639d033 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,7 +89,7 @@ before_script: script: - vendor/bin/phpcs - vendor/bin/codecept build - - vendor/bin/codecept run -vvv + - vendor/bin/codecept run -v after_failure: - ipcs -m From 06d9016c4c36f073333e12948a2821ac3f515685 Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 18:12:39 +0700 Subject: [PATCH 29/38] Rebuild Travis --- Library/Phalcon/Db/Dialect/Oracle.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index e72a349c8..6b9bbd341 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -578,6 +578,7 @@ public function supportsReleaseSavepoints() return false; } + /** * Prepares table for this RDBMS. * From 33909d95345756e172afa657f5c5c680531a3dd1 Mon Sep 17 00:00:00 2001 From: "Achmad Ulfi M.S" Date: Sun, 25 Dec 2016 18:23:18 +0700 Subject: [PATCH 30/38] Rebuild Travis --- Library/Phalcon/Db/Dialect/Oracle.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Phalcon/Db/Dialect/Oracle.php b/Library/Phalcon/Db/Dialect/Oracle.php index 6b9bbd341..e72a349c8 100644 --- a/Library/Phalcon/Db/Dialect/Oracle.php +++ b/Library/Phalcon/Db/Dialect/Oracle.php @@ -578,7 +578,6 @@ public function supportsReleaseSavepoints() return false; } - /** * Prepares table for this RDBMS. * From de9ecc77199d259e0b069e249b137b05a7374355 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 1 Mar 2017 08:20:34 +0200 Subject: [PATCH 31/38] Improved Phalcon\Tests\Queue\Beanstalk\ExtendedTest --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2a639d033..971f63c70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,6 +94,9 @@ script: after_failure: - ipcs -m +after_failure: + - ipcs -m + notifications: email: recipients: From 29e6cb8c723fa6d2ad0823a1a5c11f3b2ba6ebf9 Mon Sep 17 00:00:00 2001 From: Julien Turbide Date: Thu, 9 Mar 2017 18:56:10 -0500 Subject: [PATCH 32/38] Allow a traversable object in normalizeEmail Fix for: Warning: preg_match() expects parameter 2 to be string, object given Allow a traversable object for the $email parameter for the normalizeEmail function --- Library/Phalcon/Mailer/Message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Phalcon/Mailer/Message.php b/Library/Phalcon/Mailer/Message.php index 9a07fab79..f50c7e69e 100644 --- a/Library/Phalcon/Mailer/Message.php +++ b/Library/Phalcon/Mailer/Message.php @@ -773,7 +773,7 @@ protected function createEmbedViaData($data, $name = null) */ protected function normalizeEmail($email) { - if (is_array($email)) { + if (is_array($email) || $email instanceof \Traversable) { $emails = []; foreach ($email as $k => $v) { From 691bd90a6e8fea575f3192430da011e99868b119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20=C5=9Alawski?= Date: Thu, 9 Mar 2017 17:15:26 +0100 Subject: [PATCH 33/38] Add MongoCollection Uniqueness compatibility --- .travis.yml | 2 +- Library/Phalcon/Mvc/MongoCollection.php | 21 +- .../Validation/Validator/CardNumber.php | 4 +- .../Validation/Validator/ConfirmationOf.php | 4 +- .../Phalcon/Validation/Validator/Decimal.php | 4 +- .../Phalcon/Validation/Validator/MongoId.php | 4 +- composer.json | 2 +- tests/_data/collections/Robots.php | 25 +++ tests/_data/collections/Users.php | 33 +++ tests/_support/Helper/CollectionTrait.php | 38 ++++ .../Collection/Helpers/UniquenessTrait.php | 204 +++++++++++++++++ .../Mvc/Collection/Helpers/ValidationBase.php | 210 ++++++++++++++++++ tests/unit/Mvc/Collection/ValidationCest.php | 108 +++++++++ 13 files changed, 648 insertions(+), 11 deletions(-) create mode 100644 tests/_data/collections/Robots.php create mode 100644 tests/_data/collections/Users.php create mode 100644 tests/_support/Helper/CollectionTrait.php create mode 100644 tests/unit/Mvc/Collection/Helpers/UniquenessTrait.php create mode 100644 tests/unit/Mvc/Collection/Helpers/ValidationBase.php create mode 100644 tests/unit/Mvc/Collection/ValidationCest.php diff --git a/.travis.yml b/.travis.yml index 971f63c70..0c4f012b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ env: - ZEND_DONT_UNLOAD_MODULES=1 - CC="ccache gcc" - PATH="$PATH:~/bin" - - PHALCON_VERSION="v3.0.4" + - PHALCON_VERSION="3.1.x" before_install: - phpenv config-rm xdebug.ini || true diff --git a/Library/Phalcon/Mvc/MongoCollection.php b/Library/Phalcon/Mvc/MongoCollection.php index fe6afc942..6859da69c 100644 --- a/Library/Phalcon/Mvc/MongoCollection.php +++ b/Library/Phalcon/Mvc/MongoCollection.php @@ -136,6 +136,7 @@ public function save() if (false === $exists) { $this->_id = $status->getInsertedId(); + $this->_dirtyState = self::DIRTY_STATE_PERSISTENT; } } @@ -225,6 +226,10 @@ protected static function _getResultset($params, CollectionInterface $collection $base = $collection; } + if ($base instanceof PhalconCollection) { + $base->setDirtyState(PhalconCollection::DIRTY_STATE_PERSISTENT); + } + $source = $collection->getSource(); if (empty($source)) { @@ -388,6 +393,7 @@ public function delete() $success = true; $this->fireEvent("afterDelete"); + $this->_dirtyState = self::DIRTY_STATE_DETACHED; } return $success; @@ -407,6 +413,10 @@ protected function _exists($collection) return false; } + if (!$this->_dirtyState) { + return true; + } + if (is_object($id)) { $mongoId = $id; } else { @@ -423,7 +433,15 @@ protected function _exists($collection) /** * Perform the count using the function provided by the driver */ - return $collection->count(["_id"=>$mongoId])>0; + $exists = $collection->count(["_id" => $mongoId]) > 0; + + if ($exists) { + $this->_dirtyState = self::DIRTY_STATE_PERSISTENT; + } else { + $this->_dirtyState = self::DIRTY_STATE_TRANSIENT; + } + + return $exists; } /** @@ -505,6 +523,7 @@ public function create() $result = $collection->insert($data, ['writeConcern' => new WriteConcern(1)]); if ($result instanceof InsertOneResult && $result->getInsertedId()) { $success = true; + $this->_dirtyState = self::DIRTY_STATE_PERSISTENT; $this->_id = $result->getInsertedId(); } diff --git a/Library/Phalcon/Validation/Validator/CardNumber.php b/Library/Phalcon/Validation/Validator/CardNumber.php index 5cc70877f..d31837279 100644 --- a/Library/Phalcon/Validation/Validator/CardNumber.php +++ b/Library/Phalcon/Validation/Validator/CardNumber.php @@ -22,7 +22,7 @@ use Phalcon\Validation; use Phalcon\Validation\Message; use Phalcon\Validation\Validator; -use Phalcon\Validation\Exception; +use Phalcon\Validation\Exception as ValidationException; /** * Phalcon\Mvc\Model\Validator\CardNumber @@ -75,7 +75,7 @@ public function validate(Validation $validation, $attribute) $result = ($issuer == 4); break; default: - throw new Exception('Incorrect type specifier'); + throw new ValidationException('Incorrect type specifier'); } if (false === $result) { diff --git a/Library/Phalcon/Validation/Validator/ConfirmationOf.php b/Library/Phalcon/Validation/Validator/ConfirmationOf.php index 9f1d5083c..d015ea917 100644 --- a/Library/Phalcon/Validation/Validator/ConfirmationOf.php +++ b/Library/Phalcon/Validation/Validator/ConfirmationOf.php @@ -21,7 +21,7 @@ use Phalcon\Validation; use Phalcon\Validation\Validator; -use Phalcon\Validation\Exception; +use Phalcon\Validation\Exception as ValidationException; /** * Validates confirmation of other field value @@ -50,7 +50,7 @@ class ConfirmationOf extends Validator public function validate(Validation $validation, $attribute) { if (!$this->hasOption('origField')) { - throw new Exception('Original field must be set'); + throw new ValidationException('Original field must be set'); } $allowEmpty = $this->getOption('allowEmpty'); diff --git a/Library/Phalcon/Validation/Validator/Decimal.php b/Library/Phalcon/Validation/Validator/Decimal.php index 8dc27077d..6f6ba589b 100644 --- a/Library/Phalcon/Validation/Validator/Decimal.php +++ b/Library/Phalcon/Validation/Validator/Decimal.php @@ -5,7 +5,7 @@ use Phalcon\Validation; use Phalcon\Validation\Message; use Phalcon\Validation\Validator; -use Phalcon\Validation\Exception; +use Phalcon\Validation\Exception as ValidationException; /** * Phalcon\Validation\Validator\Decimal @@ -47,7 +47,7 @@ public function validate(Validation $validation, $attribute) } if (false === $this->hasOption('places')) { - throw new Exception('A number of decimal places must be set'); + throw new ValidationException('A number of decimal places must be set'); } if ($this->hasOption('digits')) { diff --git a/Library/Phalcon/Validation/Validator/MongoId.php b/Library/Phalcon/Validation/Validator/MongoId.php index ea2689554..f59483743 100644 --- a/Library/Phalcon/Validation/Validator/MongoId.php +++ b/Library/Phalcon/Validation/Validator/MongoId.php @@ -23,7 +23,7 @@ use Phalcon\Validation; use Phalcon\Validation\Validator; use Phalcon\Validation\Message; -use Phalcon\Validation\Exception; +use Phalcon\Validation\Exception as ValidationException; /** * MongoId validator @@ -41,7 +41,7 @@ class MongoId extends Validator public function validate(Validation $validation, $attribute) { if (!extension_loaded('mongo')) { - throw new Exception('Mongo extension is not available'); + throw new ValidationException('Mongo extension is not available'); } $value = $validation->getValue($attribute); diff --git a/composer.json b/composer.json index 88dd39715..059853e0c 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ }, "require": { "php": ">=5.5", - "ext-phalcon": "^3.0", + "ext-phalcon": "^3.1", "swiftmailer/swiftmailer": "~5.2" }, "require-dev": { diff --git a/tests/_data/collections/Robots.php b/tests/_data/collections/Robots.php new file mode 100644 index 000000000..1ca9d13f9 --- /dev/null +++ b/tests/_data/collections/Robots.php @@ -0,0 +1,25 @@ +add('created_at', new PresenceOf()) + + ->add('email', new StringLength(['min' => '7', 'max' => '50'])) + ->add('email', new Email()) + ->add('email', new Uniqueness()) + + ->add('status', new ExclusionIn(['domain' => ['P', 'I', 'w']])) + ->add('status', new InclusionIn(['domain' => ['A', 'y', 'Z']])) + ->add('status', new Regex(['pattern' => '/[A-Z]/'])); + + return $this->validate($validator); + } +} \ No newline at end of file diff --git a/tests/_support/Helper/CollectionTrait.php b/tests/_support/Helper/CollectionTrait.php new file mode 100644 index 000000000..ae43da327 --- /dev/null +++ b/tests/_support/Helper/CollectionTrait.php @@ -0,0 +1,38 @@ +markTestSkipped('mongodb extension not loaded'); + } + + Di::reset(); + + $di = new Di(); + $di->set('mongo', function() { + $dsn = 'mongodb://' . env('TEST_MONGODB_HOST', '127.0.0.1') . ':' . env('TEST_MONGODB_PORT', 27017); + $mongo = new Client($dsn); + + return $mongo->selectDatabase(env('TEST_MONGODB_NAME', 'incubator')); + }); + + $di->set('collectionManager', Manager::class); + } +} diff --git a/tests/unit/Mvc/Collection/Helpers/UniquenessTrait.php b/tests/unit/Mvc/Collection/Helpers/UniquenessTrait.php new file mode 100644 index 000000000..97b479c5a --- /dev/null +++ b/tests/unit/Mvc/Collection/Helpers/UniquenessTrait.php @@ -0,0 +1,204 @@ +add('type', new Uniqueness()); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $I->assertTrue($this->robot->save()); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->anotherRobot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(1, $messages); + } + + private function testSingleFieldConvert(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + 'type', + new Uniqueness( + [ + 'convert' => function (array $values) { + $values['type'] = 'hydraulic'; // mechanical -> hydraulic + return $values; + }, + ] + ) + ); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(0, $messages); + } + + private function testSingleFieldWithNull(UnitTester $I) + { + $validation = new Validation(); + $validation->add('deleted', new Uniqueness()); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->anotherRobot); + $I->assertCount(1, $messages); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(0, $messages); + } + + private function testMultipleFields(UnitTester $I) + { + $validation = new Validation(); + $validation->add(['name', 'type'], new Uniqueness()); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->anotherRobot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(1, $messages); + } + + private function testMultipleFieldsConvert(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + ['name', 'type'], + new Uniqueness( + [ + 'convert' => function (array $values) { + $values['type'] = 'hydraulic'; // mechanical -> hydraulic + return $values; + }, + ] + ) + ); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(0, $messages); + } + + private function testMultipleFieldsWithNull(UnitTester $I) + { + $validation = new Validation(); + $validation->add(['type', 'deleted'], new Uniqueness()); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->anotherRobot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(0, $messages); + $this->deletedRobot->deleted = null; + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(1, $messages); + $this->deletedRobot->deleted = (new DateTime())->format('Y-m-d H:i:s'); + } + + private function testExceptSingleFieldSingleExcept(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + 'year', + new Uniqueness( + [ + 'except' => 1972, + ] + ) + ); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $I->assertTrue($this->anotherRobot->save()); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(1, $messages); + } + + private function testExceptSingleFieldMultipleExcept(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + 'year', + new Uniqueness( + [ + 'except' => [1972, 1952], + ] + ) + ); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->anotherRobot); + $I->assertCount(0, $messages); + } + + private function testExceptMultipleFieldSingleExcept(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + ['type', 'year'], + new Uniqueness( + [ + 'except' => [ + 'type' => 'hydraulic', + 'year' => 1952, + ], + ] + ) + ); + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(0, $messages); + $this->deletedRobot->type = 'mechanical'; + $this->deletedRobot->year = 1972; + $messages = $validation->validate(null, $this->deletedRobot); + $I->assertCount(1, $messages); + $this->deletedRobot->type = 'hydraulic'; + $this->deletedRobot->year = 1952; + } + + private function testExceptMultipleFieldMultipleExcept(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + ['year', 'type'], + new Uniqueness( + [ + 'except' => [ + 'year' => [1942, 1972], + 'type' => ['hydraulic', 'cyborg'], + ], + ] + ) + ); + $messages = $validation->validate(null, $this->robot); + $I->assertCount(0, $messages); + $messages = $validation->validate(null, $this->anotherRobot); + $I->assertCount(0, $messages); + } + + private function testConvertArrayReturnsArray(UnitTester $I) + { + $validation = new Validation(); + $validation->add( + 'type', + new Uniqueness( + [ + 'convert' => function (array $values) { + ($values); + + return null; + }, + ] + ) + ); + try { + $validation->validate(null, $this->robot); + $I->assertTrue(false); + } catch (\Exception $e) { + $I->assertTrue(true); + } + } +} \ No newline at end of file diff --git a/tests/unit/Mvc/Collection/Helpers/ValidationBase.php b/tests/unit/Mvc/Collection/Helpers/ValidationBase.php new file mode 100644 index 000000000..769a87828 --- /dev/null +++ b/tests/unit/Mvc/Collection/Helpers/ValidationBase.php @@ -0,0 +1,210 @@ +email = 'fuego@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'A'; + $I->assertTrue($collection->save()); + } + + protected function presenceOf(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'diego@hotmail.com'; + $collection->created_at = null; + $collection->status = 'A'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field created_at is required', + '_field' => 'created_at', + '_type' => 'PresenceOf', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function email(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'fuego?='; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'A'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field email must be an email address', + '_field' => 'email', + '_type' => 'Email', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function exclusionIn(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'serghei@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'P'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field status must not be a part of list: P, I, w', + '_field' => 'status', + '_type' => 'ExclusionIn', + '_code' => 0, + ] + ), + Message::__set_state( + [ + '_message' => 'Field status must be a part of list: A, y, Z', + '_field' => 'status', + '_type' => 'InclusionIn', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function inclusionIn(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'serghei@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'R'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field status must be a part of list: A, y, Z', + '_field' => 'status', + '_type' => 'InclusionIn', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function uniqueness1(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'jurigag@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'A'; + $I->assertTrue($collection->save()); + + $collection = new Users(); + $collection->email = 'jurigag@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'A'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field email must be unique', + '_field' => 'email', + '_type' => 'Uniqueness', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function regex(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'andres@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'y'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field status does not match the required format', + '_field' => 'status', + '_type' => 'Regex', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function tooLong(UnitTester $I) + { + $collection = new Users(); + $collection->email = str_repeat('a', 50).'@hotmail.com'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'A'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field email must not exceed 50 characters long', + '_field' => 'email', + '_type' => 'TooLong', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } + + protected function tooShort(UnitTester $I) + { + $collection = new Users(); + $collection->email = 'a@b.c'; + $collection->created_at = (new DateTime())->format('Y-m-d H:i:s'); + $collection->status = 'A'; + $I->assertFalse($collection->save()); + + $expected = [ + Message::__set_state( + [ + '_message' => 'Field email must be at least 7 characters long', + '_field' => 'email', + '_type' => 'TooShort', + '_code' => 0, + ] + ), + ]; + + $I->assertEquals($expected, $collection->getMessages()); + } +} diff --git a/tests/unit/Mvc/Collection/ValidationCest.php b/tests/unit/Mvc/Collection/ValidationCest.php new file mode 100644 index 000000000..672ff8bd0 --- /dev/null +++ b/tests/unit/Mvc/Collection/ValidationCest.php @@ -0,0 +1,108 @@ + + * @package Phalcon\Test\Mvc\Collection + * @group Db + * + * The contents of this file are 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 that we can send you a copy immediately. + */ +class ValidationCest extends ValidationBase +{ + /** + * @var Robots + */ + private $robot; + + /** + * @var Robots + */ + private $anotherRobot; + + /** + * @var Robots + */ + private $deletedRobot; + + use CollectionTrait; + use UniquenessTrait; + + public function mongo(UnitTester $I) + { + $I->wantToTest("Collection validation"); + + $this->setupMongo($I); + + $this->success($I); + $this->presenceOf($I); + $this->email($I); + $this->exclusionIn($I); + $this->inclusionIn($I); + $this->uniqueness1($I); + $this->regex($I); + $this->tooLong($I); + $this->tooShort($I); + } + + public function mongoUniqueness(UnitTester $I) + { + $I->wantToTest("Collection Uniqueness validation"); + + $this->setupMongo($I); + + $this->robot = new Robots(); + $this->robot->name = 'Robotina'; + $this->robot->type = 'mechanical'; + $this->robot->year = 1972; + $this->robot->datetime = (new DateTime())->format('Y-m-d H:i:s'); + $this->robot->deleted = null; + $this->robot->text = 'text'; + + $this->anotherRobot = new Robots(); + $this->anotherRobot->name = 'Robotina'; + $this->anotherRobot->type = 'hydraulic'; + $this->anotherRobot->year = 1952; + $this->anotherRobot->datetime = (new DateTime())->format('Y-m-d H:i:s'); + $this->anotherRobot->deleted = null; + $this->anotherRobot->text = 'text'; + + $this->deletedRobot = new Robots(); + $this->deletedRobot->name = 'Robotina'; + $this->deletedRobot->type = 'mechanical'; + $this->deletedRobot->year = 1952; + $this->deletedRobot->datetime = (new DateTime())->format('Y-m-d H:i:s'); + $this->deletedRobot->deleted = (new DateTime())->format('Y-m-d H:i:s'); + $this->deletedRobot->text = 'text'; + + $this->testSingleField($I); + $this->testSingleFieldConvert($I); + $this->testSingleFieldWithNull($I); + $this->testMultipleFields($I); + $this->testMultipleFieldsConvert($I); + $this->testMultipleFieldsWithNull($I); + $this->testExceptSingleFieldSingleExcept($I); + $this->testExceptSingleFieldMultipleExcept($I); + $this->testExceptMultipleFieldSingleExcept($I); + $this->testExceptMultipleFieldMultipleExcept($I); + $this->testConvertArrayReturnsArray($I); + } +} \ No newline at end of file From 8be210ba6a3e1fa63c9ed2f38dc837f26c54e591 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 25 Mar 2017 17:35:19 +0200 Subject: [PATCH 34/38] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 265b48e04..448732d88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ env: - ZEND_DONT_UNLOAD_MODULES=1 - CC="ccache gcc" - PATH="$PATH:~/bin" - - PHALCON_VERSION="v3.1.1" + - PHALCON_VERSION="v3.1.0" before_install: - phpenv config-rm xdebug.ini || true From 7a82021f2bfad0f00f308703f153607ba6abdb0b Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 28 Mar 2017 23:06:07 +0300 Subject: [PATCH 35/38] We have to test Incubator but not Phalcon --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 448732d88..3674014fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ env: - ZEND_DONT_UNLOAD_MODULES=1 - CC="ccache gcc" - PATH="$PATH:~/bin" - - PHALCON_VERSION="v3.1.0" + - PHALCON_VERSION="v3.1.1" before_install: - phpenv config-rm xdebug.ini || true @@ -61,14 +61,11 @@ before_install: - travis_retry composer require duncan3dc/fork-helper:$(if [[ "${PHP_MAJOR:0:1}" = "7" ]]; then echo "^2.0"; else echo "^1.0"; fi) --ignore-platform-reqs install: - - ( bash tests/_ci/install_zephir.sh ) - ( bash tests/_ci/install_prereqs_$PHP_MAJOR.sh ) # See https://github.com/aerospike/aerospike-client-php/issues/127 - '[[ "${PHP_MAJOR:0:1}" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh' - git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} >/dev/null 2>&1 - - ln -s ${TRAVIS_BUILD_DIR}/.temp ${TRAVIS_BUILD_DIR}/cphalcon/.temp - - ( cd cphalcon; zephir fullclean && zephir generate $ZEND_BACKEND ) - - ( cd cphalcon/ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; /usr/bin/phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j"$(getconf _NPROCESSORS_ONLN)" &> /dev/null && make --silent install ) + - (cd cphalcon/build; bash ./install --phpize $(phpenv which phpize) --php-config $(phpenv which php-config)) - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/redis.ini - phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/phalcon.ini # Debug From f3a7e16f0d8e1c857e62778617e93d36471a473c Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 28 Mar 2017 23:18:45 +0300 Subject: [PATCH 36/38] Small improvements and docs changes --- .github/PULL_REQUEST_TEMPLATE.md | 7 ------- .travis.yml | 17 ++--------------- README.md | 2 +- composer.json | 6 +++--- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bf4fdcc44..f47b32c67 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,13 +3,6 @@ Hello! * Type: bug fix | new feature | code quality | documentation * Link to issue: -This pull request affects the following components: **(please check boxes)** - -* [ ] Library -* [ ] Code Style -* [ ] Documentation -* [ ] Testing - **In raising this pull request, I confirm the following (please check boxes):** - [ ] I have read and understood the [Contributing Guidelines](https://github.com/phalcon/incubator/blob/master/CONTRIBUTING.md)? diff --git a/.travis.yml b/.travis.yml index 3674014fc..4ebcfcc0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ # Phalcon Framework # -# Copyright (c) 2011-2016 Phalcon Team (https://www.phalconphp.com) +# Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) # # This source file is subject to the New BSD License that is bundled # with this package in the file LICENSE.txt. @@ -17,11 +17,7 @@ sudo: required php: - 5.5 - 5.6 - -matrix: - include: - - php: 7.0 - env: ZEND_BACKEND="--backend=ZendEngine3" + - 7.0 services: - memcached @@ -37,15 +33,11 @@ cache: ccache: true timeout: 691200 directories: - - .temp - vendor - - $HOME/.ccache - $HOME/.composer/cache env: global: - - ZEND_DONT_UNLOAD_MODULES=1 - - CC="ccache gcc" - PATH="$PATH:~/bin" - PHALCON_VERSION="v3.1.1" @@ -71,7 +63,6 @@ install: # Debug - php -m - pecl list - - ipcs -m before_script: - stty cols 160 @@ -88,10 +79,6 @@ script: - vendor/bin/codecept build - vendor/bin/codecept run -v - -after_failure: - - ipcs -m - notifications: email: recipients: diff --git a/README.md b/README.md index 98188212f..36135105e 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Then create the `composer.json` file as follows: ```json { "require": { - "phalcon/incubator": "^3.0" + "phalcon/incubator": "^3.1" } } ``` diff --git a/composer.json b/composer.json index 059853e0c..7456509a2 100644 --- a/composer.json +++ b/composer.json @@ -3,13 +3,13 @@ "type": "library", "description": "Adapters, prototypes or functionality that can be potentially incorporated to the C-framework.", "keywords": ["framework", "phalcon", "incubator"], - "homepage": "http://phalconphp.com", + "homepage": "https://phalconphp.com", "license": "BSD-3-Clause", "authors": [ { "name": "Phalcon Team", "email": "team@phalconphp.com", - "homepage": "http://phalconphp.com/en/team" + "homepage": "https://phalconphp.com/en/team" }, { "name": "Contributors", @@ -29,7 +29,7 @@ "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", "phpunit/phpunit": "^4.8", - "squizlabs/php_codesniffer": "^2.7", + "squizlabs/php_codesniffer": "^2.8", "codeception/codeception": "^2.2", "codeception/mockery-module": "^0.2", "codeception/aerospike-module": "^1.0", From 38047f2ca6d4196bed4499f016e6fbaf72172012 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 28 Mar 2017 23:20:56 +0300 Subject: [PATCH 37/38] Do not get Zephir for test PHP --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4ebcfcc0f..6c1cf26e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,6 @@ before_install: - if [[ ! -z "${GH_TOKEN}" ]]; then composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"; fi; # Install dev-dependencies - travis_retry composer install --prefer-dist --no-interaction --ignore-platform-reqs - - travis_retry composer require "phalcon/zephir:dev-master" --ignore-platform-reqs - travis_retry composer require duncan3dc/fork-helper:$(if [[ "${PHP_MAJOR:0:1}" = "7" ]]; then echo "^2.0"; else echo "^1.0"; fi) --ignore-platform-reqs install: From 9ccde9b72459e20110883e8929ae7a3bef1d28eb Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 28 Mar 2017 23:30:15 +0300 Subject: [PATCH 38/38] Do not use the Fork Helper for tests For nearly six months, the tests are falling regularly. Fork is the only dependence, which is constantly fails tests In the future we will deprecate the Fork Helper in favor of ReactPHP, Promises, etc. Cc: @duncan3dc --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c1cf26e1..b1ad1fbea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,9 +47,7 @@ before_install: - sudo ln -s /home/travis/.phpenv/versions/$(phpenv version-name)/bin/php-config /usr/bin/ - export PHP_MAJOR="$(echo $TRAVIS_PHP_VERSION | cut -d '.' -f 1,2)" - if [[ ! -z "${GH_TOKEN}" ]]; then composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"; fi; - # Install dev-dependencies - travis_retry composer install --prefer-dist --no-interaction --ignore-platform-reqs - - travis_retry composer require duncan3dc/fork-helper:$(if [[ "${PHP_MAJOR:0:1}" = "7" ]]; then echo "^2.0"; else echo "^1.0"; fi) --ignore-platform-reqs install: - ( bash tests/_ci/install_prereqs_$PHP_MAJOR.sh )