Skip to content

Commit

Permalink
Merge pull request #823 from phalcon/3.2.x
Browse files Browse the repository at this point in the history
v3.2.3
  • Loading branch information
Jurigag authored Sep 26, 2017
2 parents 52766a4 + 331c5e5 commit 34db963
Show file tree
Hide file tree
Showing 14 changed files with 839 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ before_install:
install:
- travis_retry composer install --prefer-dist --no-interaction --quiet --no-ansi --no-progress --optimize-autoloader --dev --no-suggest --ignore-platform-reqs
# See https://github.com/aerospike/aerospike-client-php/issues/127
- '[[ "$PHP_MAJOR" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh'
- '[[ "$PHP_MAJOR" == "5" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh'
- if [ ! -f $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so ]; then cd $HOME/cphalcon/$PHALCON_VERSION/build && bash ./install --phpize $(phpenv which phpize) --php-config $(phpenv which php-config) && mkdir -p $HOME/ext/$PHP_VERSION/$PHALCON_VERSION && cp $PHP_EXTENSION_DIR/phalcon.so $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so; fi;
- if [ -f $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so ]; then cp $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so $PHP_EXTENSION_DIR/phalcon.so; fi;
- phpenv config-add $HOME/cphalcon/$PHALCON_VERSION/tests/_ci/phalcon.ini
Expand All @@ -74,13 +74,13 @@ before_script:
- echo "GRANT ALL PRIVILEGES ON incubator.* TO 'incubator'@'%' WITH GRANT OPTION" | mysql -u root
- cat ${TRAVIS_BUILD_DIR}/tests/_data/dump.sql | mysql -u root incubator
# See https://github.com/aerospike/aerospike-client-php/issues/127
- '[[ "${PHP_MAJOR:0:1}" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aserver.sh'
- '[[ "${PHP_MAJOR:0:1}" == "5" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aserver.sh'

script:
- vendor/bin/phpcs
- vendor/bin/codecept build
- vendor/bin/codecept run -v tests/unit
- '[[ "$PHP_MAJOR" == "7" ]] || vendor/bin/codecept run -v tests/aerospike'
- '[[ "$PHP_MAJOR" == "5" ]] || vendor/bin/codecept run -v tests/aerospike'
- '[[ "$PHP_MAJOR" == "7" ]] || vendor/bin/codecept run -v tests/unit5x'

notifications:
Expand Down
24 changes: 24 additions & 0 deletions Library/Phalcon/Acl/Adapter/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public function addRole($role, $accessInherits = null)
/**
* {@inheritdoc}
*
* Example:
* //Administrator implicitly inherits all descendants of 'consultor' unless explicity set in an Array
* <code>$acl->addInherit('administrator', new Phalcon\Acl\Role('consultor'));</code>
* <code>$acl->addInherit('administrator', 'consultor');</code>
* <code>$acl->addInherit('administrator', ['consultor', 'poweruser']);</code>
*
* @param string $roleName
* @param \Phalcon\Acl\Role|string $roleToInherit
* @throws \Phalcon\Acl\Exception
Expand All @@ -119,6 +125,24 @@ public function addInherit($roleName, $roleToInherit)
$roleToInherit = $roleToInherit->getName();
}

/**
* Deep inherits Explicit tests array, Implicit recurs through inheritance chain
*/
if (is_array($roleToInherit)) {
foreach ($roleToInherit as $roleToInherit) {
$this->redis->sAdd("rolesInherits:$roleName", $roleToInherit);
}
return true;
}

if ($this->redis->exists("rolesInherits:$roleToInherit")) {
$deeperInherits = $this->redis->sGetMembers("rolesInherits:$roleToInherit");

foreach ($deeperInherits as $deeperInherit) {
$this->addInherit($roleName, $deeperInherit);
}
}

$this->redis->sAdd("rolesInherits:$roleName", $roleToInherit);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Phalcon/Db/Adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $di->setShared('mongo', function () {
$dsn = 'mongodb://' . $config->database->mongo->host;
} else {
$dsn = sprintf(
'mongodb://%s:%s@%s'
'mongodb://%s:%s@%s',
$config->database->mongo->username,
$config->database->mongo->password,
$config->database->mongo->host
Expand Down
80 changes: 80 additions & 0 deletions Library/Phalcon/Utils/ArrayUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| 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. |
| |
| 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 [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Sergii Svyrydenko <[email protected]> |
+------------------------------------------------------------------------+
*/

namespace Phalcon\Utils;

use Traversable;
use InvalidArgumentException;

/**
* Utility class for manipulation of PHP arrays.
*
* @package Phalcon\Utils
*/
class ArrayUtils
{
/**
* Convert an iterator to an array.
*
* Converts an iterator to an array. The $recursive flag, on by default,
* hints whether or not you want to do so recursively.
*
* @param array | Traversable $iterator The array or Traversable object to convert
* @param bool $recursive Recursively check all nested structures
* @throws InvalidArgumentException if $iterator is not an array or a Traversable object
* @return array
*/
public function iteratorToArray($iterator, $recursive = true)
{
if (!is_array($iterator) && !$iterator instanceof Traversable) {
throw new InvalidArgumentException(__METHOD__ . ' must be either an array or Traversable');
}

if (!$recursive) {
if (is_array($iterator)) {
return $iterator;
}
return iterator_to_array($iterator);
}

if (method_exists($iterator, 'toArray')) {
return $iterator->toArray();
}

$array = [];
foreach ($iterator as $key => $value) {
if (is_scalar($value)) {
$array[$key] = $value;
continue;
}
if ($value instanceof Traversable) {
$array[$key] = $this->iteratorToArray($value, $recursive);
continue;
}
if (is_array($value)) {
$array[$key] = $this->iteratorToArray($value, $recursive);
continue;
}

$array[$key] = $value;
}

return $array;
}
}
Loading

0 comments on commit 34db963

Please sign in to comment.