Skip to content

Commit

Permalink
Merge pull request #537 from phalcon/2.0.x
Browse files Browse the repository at this point in the history
2.0.10
  • Loading branch information
sergeyklay committed Feb 5, 2016
2 parents f376f57 + e040517 commit 1fbe375
Show file tree
Hide file tree
Showing 100 changed files with 1,882 additions and 573 deletions.
51 changes: 42 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ php:
- 5.5
- 5.6

sudo:
false
sudo: required
dist: precise
group: edge

services:
- memcached
Expand All @@ -15,8 +16,20 @@ services:

env:
global:
- TEST_BT_HOST=127.0.0.1 TEST_BT_PORT=11300 TEST_MC_HOST=127.0.0.1 TEST_MC_PORT=11211
- TEST_BT_HOST="127.0.0.1"
- TEST_BT_PORT="11300"
- TEST_MC_HOST="127.0.0.1"
- TEST_MC_PORT="11211"
- TEST_AS_HOST="127.0.0.1"
- TEST_AS_PORT="3000"
- TEST_DB_HOST="127.0.0.1"
- TEST_DB_PORT="3306"
- TEST_DB_USER="root"
- TEST_DB_PASSWD=""
- TEST_DB_NAME="incubator_tests"
- TEST_DB_CHARSET="utf8"
matrix:
- PHALCON_VERSION="2.0.10"
- PHALCON_VERSION="2.0.9"
- PHALCON_VERSION="2.0.8"
- PHALCON_VERSION="2.0.7"
Expand All @@ -25,37 +38,57 @@ env:
- PHALCON_VERSION="2.0.4"

before_install:
- phpenv config-rm xdebug.ini
- bash tests/_ci/setup_beanstalkd.sh
- beanstalkd -v
- beanstalkd -l ${TEST_BT_HOST} -p ${TEST_BT_PORT} & # start queue listener
- sleep 5 # give server some time to boot
- sleep 5
- cd $TRAVIS_BUILD_DIR
- pecl channel-update pecl.php.net
- (CFLAGS="-O1 -g3 -fno-strict-aliasing"; pecl install yaml < /dev/null &)
- phpenv config-add tests/_ci/yaml.ini
- pecl install mongo < /dev/null &
- phpenv config-add tests/_ci/mongo.ini
- phpenv config-add tests/_ci/memcached.ini
- php -m
- wget -O aerospike.tgz 'http://aerospike.com/download/server/latest/artifact/ubuntu12'
- tar -xvf aerospike.tgz
- cd aerospike-server-community-*-ubuntu12*
- sudo ./asinstall
- sudo service aerospike start
- sudo service aerospike status
- sleep 5
- cd $TRAVIS_BUILD_DIR

install:
- composer self-update
- git clone -q --depth=1 https://github.com/phalcon/cphalcon.git -b phalcon-v${PHALCON_VERSION}
- (cd cphalcon/ext; export CFLAGS="-g3 -O1 -fno-delete-null-pointer-checks -Wall"; phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j4 > /dev/null && make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini &> /dev/null)
- php -r 'echo \Phalcon\Version::get()."\n";'
- (cd cphalcon/ext; export CFLAGS="-g0 -O0 -std=gnu90"; phpize &> /dev/null && ./configure --silent --enable-phalcon &> /dev/null && make --silent -j2 &> /dev/null && make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini &> /dev/null)
- php --ri phalcon
- travis_retry composer require aerospike/aerospike-client-php "*"
- find vendor/aerospike/aerospike-client-php/ -name "*.sh" -exec chmod +x {} \;
- cd vendor/aerospike/aerospike-client-php
- sudo $(which composer) run-script -q post-install-cmd
- cd $TRAVIS_BUILD_DIR
- echo "extension=${TRAVIS_BUILD_DIR}/vendor/aerospike/aerospike-client-php/src/aerospike/modules/aerospike.so" | tee -a tests/_ci/aerospike.ini
- phpenv config-add tests/_ci/aerospike.ini
- php -m
- travis_retry composer install --prefer-source --no-interaction
- travis_retry composer require "duncan3dc/fork-helper":"*"

before_script:
- stty cols 160
- mysql -e 'create database incubator_tests charset=utf8mb4 collate=utf8mb4_unicode_ci;'

script:
- vendor/bin/phpcs --standard=PSR2 --colors --extensions=php --encoding=utf-8 Library/
- vendor/bin/codecept build
- vendor/bin/codecept run --coverage-text
- vendor/bin/codecept run

addons:
apt:
packages:
- libyaml-dev
- libssl-dev
- autoconf

notifications:
email:
Expand Down
47 changes: 27 additions & 20 deletions Library/Phalcon/Acl/Adapter/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com) |
| Copyright (c) 2011-2016 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
Expand All @@ -22,17 +22,17 @@
use Phalcon\Db;
use Phalcon\Db\AdapterInterface as DbAdapter;
use Phalcon\Acl\Adapter;
use Phalcon\Acl\AdapterInterface;
use Phalcon\Acl\Exception;
use Phalcon\Acl\Resource;
use Phalcon\Acl;
use Phalcon\Acl\Role;
use Phalcon\Acl\RoleInterface;

/**
* Phalcon\Acl\Adapter\Database
* Manages ACL lists in memory
* Manages ACL lists in database tables
*/
class Database extends Adapter implements AdapterInterface
class Database extends Adapter
{
/**
* @var DbAdapter
Expand Down Expand Up @@ -96,18 +96,24 @@ public function __construct(array $options)

/**
* {@inheritdoc}
*
* Example:
* <code>$acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultor');</code>
* <code>$acl->addRole('administrator', 'consultor');</code>
*
* @param \Phalcon\Acl\Role|string $role
* @param string $accessInherits
* @return boolean
* @throws \Phalcon\Acl\Exception
*/
public function addRole($role, $accessInherits = null)
{
if (!is_object($role)) {
$role = new Role($role);
if (is_string($role)) {
$role = new Role($role, ucwords($role) . ' Role');
}

if (!$role instanceof RoleInterface) {
throw new Exception('Role must be either an string or implement RoleInterface');
}

$exists = $this->connection->fetchOne(
Expand Down Expand Up @@ -138,8 +144,8 @@ public function addRole($role, $accessInherits = null)
/**
* {@inheritdoc}
*
* @param string $roleName
* @param string $roleToInherit
* @param string $roleName
* @param string $roleToInherit
* @throws \Phalcon\Acl\Exception
*/
public function addInherit($roleName, $roleToInherit)
Expand Down Expand Up @@ -243,8 +249,8 @@ public function addResource($resource, $accessList = null)
/**
* {@inheritdoc}
*
* @param string $resourceName
* @param array|string $accessList
* @param string $resourceName
* @param array|string $accessList
* @return boolean
* @throws \Phalcon\Acl\Exception
*/
Expand Down Expand Up @@ -293,7 +299,7 @@ public function getResources()
/**
* {@inheritdoc}
*
* @return \Phalcon\Acl\Role[]
* @return RoleInterface[]
*/
public function getRoles()
{
Expand All @@ -315,6 +321,7 @@ public function getRoles()
*/
public function dropResourceAccess($resourceName, $accessList)
{
throw new \BadMethodCallException('Not implemented yet.');
}

/**
Expand Down Expand Up @@ -385,7 +392,7 @@ public function deny($roleName, $resourceName, $access)
public function isAllowed($role, $resource, $access)
{
$sql = implode(' ', [
"SELECT 'allowed' FROM {$this->accessList} AS a",
"SELECT " . $this->connection->escapeIdentifier('allowed') . " FROM {$this->accessList} AS a",
// role_name in:
'WHERE roles_name IN (',
// given 'role'-parameter
Expand Down Expand Up @@ -421,10 +428,10 @@ public function isAllowed($role, $resource, $access)
/**
* Inserts/Updates a permission in the access list
*
* @param string $roleName
* @param string $resourceName
* @param string $accessName
* @param integer $action
* @param string $roleName
* @param string $resourceName
* @param string $accessName
* @param integer $action
* @return boolean
* @throws \Phalcon\Acl\Exception
*/
Expand Down Expand Up @@ -475,10 +482,10 @@ protected function insertOrUpdateAccess($roleName, $resourceName, $accessName, $
/**
* Inserts/Updates a permission in the access list
*
* @param string $roleName
* @param string $resourceName
* @param array|string $access
* @param integer $action
* @param string $roleName
* @param string $resourceName
* @param array|string $access
* @param integer $action
* @throws \Phalcon\Acl\Exception
*/
protected function allowOrDeny($roleName, $resourceName, $access, $action)
Expand Down
Loading

0 comments on commit 1fbe375

Please sign in to comment.