Skip to content

Commit

Permalink
Merge branch '4.0.x' into issue_11999
Browse files Browse the repository at this point in the history
  • Loading branch information
ogarbe authored Nov 28, 2018
2 parents e72d503 + 3eb50b3 commit 8ef4730
Show file tree
Hide file tree
Showing 43 changed files with 707 additions and 273 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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,sh}]
charset = utf-8
end_of_line = lf
indent_size = 4
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
70 changes: 23 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php

dist: trusty
sudo: false

language: php
php:
- 'master'
- '7.3'
Expand All @@ -29,7 +27,6 @@ matrix:
fast_finish: true
allow_failures:
- php: 'master'
- php: '7.3'

cache:
apt: true
Expand All @@ -39,7 +36,6 @@ cache:
- ${HOME}/.composer/cache
- ${HOME}/pear
- ${HOME}/.local/opt
- ${HOME}/.cache/composer

services:
- beanstalkd
Expand All @@ -50,71 +46,51 @@ services:
env:
global:
- CC="gcc"
- ZEPHIR_PARSER_VERSION="v1.1.2"
- ZEPHIR_VERSION="0.10.12"
- ZEPHIR_VERSION="0.10.14"
- 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:${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)"
- ./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)
- 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)

install:
- ./tests/_ci/install-prereqs.sh
- tests/_ci/install-prereqs.sh
- tests/_ci/install-re2c.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
- zephir generate
- ./tests/_ci/precompile-headers.sh
- |
cd "${TRAVIS_BUILD_DIR}/ext"
$(phpenv which 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 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"
- travis_retry composer global require ${DEFAULT_COMPOSER_FLAGS} "phalcon/zephir:${ZEPHIR_VERSION}"
- 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
19 changes: 19 additions & 0 deletions CHANGELOG-3.4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# [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 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\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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- 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 the ability to use FrontendInterface to serialize Model and ResultSet - Inject a `serializer` object which implements `FrontendInterface` in DI to use it. [#12808] (https://github.com/phalcon/cphalcon/pull/12888)
- 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)
Expand All @@ -35,6 +38,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
Expand Down
12 changes: 5 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ 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
EXTENSION_FILE: php_phalcon.dll
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
PSR_PECL_VERSION: 0.6.1
ZEPHIR_VERSION: 0.10.14

matrix:
fast_finish: true
Expand All @@ -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
Expand Down Expand Up @@ -106,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
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 7 additions & 3 deletions phalcon/config.zep
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ class Config implements \ArrayAccess, \Countable
}

if is_numeric(key) {
let key = strval(number),
number++;
}
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 instance->{key} = value;
}

Expand Down
2 changes: 1 addition & 1 deletion phalcon/config/adapter/ini.zep
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 11 additions & 4 deletions phalcon/db/adapter.zep
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 9 additions & 4 deletions phalcon/di.zep
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,7 +128,7 @@ class Di implements DiInterface
public function set(string! name, var definition, boolean shared = false) -> <ServiceInterface>
{
var service;
let service = new Service(name, definition, shared),
let service = new Service(definition, shared),
this->_services[name] = service;
return service;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = <ManagerInterface> this->_eventsManager;

Expand All @@ -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
Expand Down
26 changes: 26 additions & 0 deletions phalcon/di/exception/serviceresolutionexception.zep
Original file line number Diff line number Diff line change
@@ -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
{
}
Loading

0 comments on commit 8ef4730

Please sign in to comment.