diff --git a/api/core/Directus/Application/Application.php b/api/core/Directus/Application/Application.php index 493bd00b71bce..dc49fc6e1eb30 100644 --- a/api/core/Directus/Application/Application.php +++ b/api/core/Directus/Application/Application.php @@ -42,6 +42,10 @@ public function __construct(array $userSettings) { parent::__construct($userSettings); + $this->container->singleton('environment', function () { + return Environment::getInstance(); + }); + $this->container->singleton('response', function () { return new BaseResponse(); }); diff --git a/api/core/Directus/Application/Environment.php b/api/core/Directus/Application/Environment.php new file mode 100644 index 0000000000000..dd8dc8ff7e88b --- /dev/null +++ b/api/core/Directus/Application/Environment.php @@ -0,0 +1,74 @@ + + * + * @link The canonical repository – + * @copyright Copyright 2006-2017 RANGER Studio, LLC – + * @license GNU General Public License (v3) – + */ + +namespace Directus\Application; + +/** + * Application Environment variables + * + * This class was created to fix an issue in Slim 2.x + * the query string from the request differ from the query string in $_SERVER + * missing the run_api_router set in api/.htaccess + * + * @author Welling Guzmán + */ +class Environment extends \Slim\Environment +{ + /** + * Gets the instance + * + * @param bool $refresh + * + * @return \Slim\Environment + */ + public static function getInstance($refresh = false) + { + $newInstance = false; + if (is_null(self::$environment) || $refresh) { + $newInstance = true; + } + + $instance = parent::getInstance($refresh); + + // ---------------------------------------------------------------------------- + // Fix the path info + // ---------------------------------------------------------------------------- + // When a new instance was created we re-created the PATH_INFO value + // By removing everything after "?" in the REQUEST_URI + // The query string is removed. + // + // Also we remove the physical path out of the REQUEST_URI + // ---------------------------------------------------------------------------- + if ($newInstance) { + $requestUri = $_SERVER['REQUEST_URI']; + $scriptName = $_SERVER['SCRIPT_NAME']; + + // Physical path + if (strpos($requestUri, $scriptName) !== false) { + // Without rewriting + $physicalPath = $scriptName; + } else { + // With rewriting + $physicalPath = str_replace('\\', '', dirname($scriptName)); + } + + // if Virtual path, starts with physical path + // Remove the physical path from request + if (substr($requestUri, 0, strlen($physicalPath)) == $physicalPath) { + $requestUri = substr($requestUri, strlen($physicalPath)); + } + + $instance['PATH_INFO'] = substr_replace($requestUri, '', strpos($requestUri, '?')); + } + + return $instance; + } + +} diff --git a/composer.json b/composer.json index fa60f67d7cea3..6b136a08a88e0 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "require": { "php": ">=5.6.0", - "slim/slim": "2.3.2", - "slim/extras": "dev-develop", + "slim/slim": "2.6.2", + "slim/extras": "dev-master", "twig/twig": "1.*", "zendframework/zend-db": "dev-directus", "directus/migrations": "dev-master", diff --git a/composer.lock b/composer.lock index 6e97f1d3fff8d..1bc9595c750d7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a9134d2f4135bf1d1015e2e9af24307e", + "content-hash": "afd3d8e8a7035aaf64adcd452797fda4", "packages": [ { "name": "directus/migrations", @@ -59,39 +59,34 @@ }, { "name": "eloquent/phony", - "version": "0.14.6", + "version": "0.14.7", "source": { "type": "git", "url": "https://github.com/eloquent/phony.git", - "reference": "1ef22360a48abc2d8d9ede2db67112240cddac06" + "reference": "d72aa17ac008fb8b595679eeafad832a340f06aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/eloquent/phony/zipball/1ef22360a48abc2d8d9ede2db67112240cddac06", - "reference": "1ef22360a48abc2d8d9ede2db67112240cddac06", + "url": "https://api.github.com/repos/eloquent/phony/zipball/d72aa17ac008fb8b595679eeafad832a340f06aa", + "reference": "d72aa17ac008fb8b595679eeafad832a340f06aa", "shasum": "" }, "require": { "php": ">=5.3" }, "require-dev": { - "athletic/athletic": "^0.1", "counterpart/counterpart": "^1", "danielstjules/pho": "^1", - "errors/exceptions": "dev-master", + "errors/exceptions": "^0.1", "ext-pdo": "*", - "friendsofphp/php-cs-fixer": "1.11.4", "hamcrest/hamcrest-php": "^2", - "icecave/isolator": "^3", "icecave/semver": "^3", "mockery/mockery": "^0.9", "peridot-php/leo": "^1", "peridot-php/peridot": "^1", "phake/phake": "^2", - "phpdocumentor/reflection-docblock": "^2", "phpspec/prophecy": "^1", - "phpunit/php-code-coverage": "^2", - "phpunit/phpunit": "^4", + "phpunit/phpunit": "^4|^5|^6", "simpletest/simpletest": "^1" }, "type": "library", @@ -130,7 +125,7 @@ "stubbing", "test" ], - "time": "2017-01-03T03:48:40+00:00" + "time": "2017-04-22T10:50:55+00:00" }, { "name": "guzzlehttp/guzzle", @@ -247,16 +242,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855" + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/0d6c7ca039329247e4f0f8f8f6506810e8248855", - "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", "shasum": "" }, "require": { @@ -308,20 +303,20 @@ "uri", "url" ], - "time": "2017-02-27T10:51:17+00:00" + "time": "2017-03-20T17:10:46+00:00" }, { "name": "league/flysystem", - "version": "1.0.35", + "version": "1.0.39", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "dda7f3ab94158a002d9846a97dc18ebfb7acc062" + "reference": "2474325ee924134bb05848663b12531f6f2e9fbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/dda7f3ab94158a002d9846a97dc18ebfb7acc062", - "reference": "dda7f3ab94158a002d9846a97dc18ebfb7acc062", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/2474325ee924134bb05848663b12531f6f2e9fbe", + "reference": "2474325ee924134bb05848663b12531f6f2e9fbe", "shasum": "" }, "require": { @@ -343,12 +338,12 @@ "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", "league/flysystem-copy": "Allows you to use Copy.com storage", - "league/flysystem-dropbox": "Allows you to use Dropbox storage", "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", "league/flysystem-webdav": "Allows you to use WebDAV storage", - "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter" + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage" }, "type": "library", "extra": { @@ -391,7 +386,7 @@ "sftp", "storage" ], - "time": "2017-02-09T11:33:58+00:00" + "time": "2017-04-25T15:24:43+00:00" }, { "name": "league/oauth1-client", @@ -458,21 +453,21 @@ }, { "name": "league/oauth2-client", - "version": "2.2.0", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth2-client.git", - "reference": "5f57366c99ac013ee9d78670c1fc0b9ca7871d95" + "reference": "313250eab923e673a5c0c8f463f443ee79f4383f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/5f57366c99ac013ee9d78670c1fc0b9ca7871d95", - "reference": "5f57366c99ac013ee9d78670c1fc0b9ca7871d95", + "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/313250eab923e673a5c0c8f463f443ee79f4383f", + "reference": "313250eab923e673a5c0c8f463f443ee79f4383f", "shasum": "" }, "require": { "guzzlehttp/guzzle": "^6.0", - "paragonie/random_compat": "^2.0", + "paragonie/random_compat": "^1|^2", "php": ">=5.6.0" }, "require-dev": { @@ -521,7 +516,7 @@ "oauth2", "single sign on" ], - "time": "2017-02-02T04:08:45+00:00" + "time": "2017-04-25T14:43:14+00:00" }, { "name": "league/oauth2-facebook", @@ -681,16 +676,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.9", + "version": "v2.0.10", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "6968531206671f94377b01dc7888d5d1b858a01b" + "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/6968531206671f94377b01dc7888d5d1b858a01b", - "reference": "6968531206671f94377b01dc7888d5d1b858a01b", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/634bae8e911eefa89c1abfbf1b66da679ac8f54d", + "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d", "shasum": "" }, "require": { @@ -725,7 +720,7 @@ "pseudorandom", "random" ], - "time": "2017-03-03T20:43:42+00:00" + "time": "2017-03-13T16:27:32+00:00" }, { "name": "psr/http-message", @@ -779,12 +774,12 @@ }, { "name": "slim/extras", - "version": "dev-develop", + "version": "dev-master", "target-dir": "Slim/Extras", "source": { "type": "git", "url": "https://github.com/WellingGuzman/Slim-Extras.git", - "reference": "e087c60dee9b933f8df5b4454230bba303152f91" + "reference": "06ecb8d5bf49f44a9c01b470264265683f582227" }, "require": { "php": ">=5.3.0", @@ -818,26 +813,28 @@ "middleware", "templating" ], - "time": "2016-07-30 16:37:23" + "time": "2017-04-23 00:33:13" }, { "name": "slim/slim", - "version": "2.3.2", + "version": "2.6.2", "source": { "type": "git", "url": "https://github.com/slimphp/Slim.git", - "reference": "a9abd36d53d9c1f7732f490f8e809e55045307b3" + "reference": "20a02782f76830b67ae56a5c08eb1f563c351a37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim/zipball/a9abd36d53d9c1f7732f490f8e809e55045307b3", - "reference": "a9abd36d53d9c1f7732f490f8e809e55045307b3", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/20a02782f76830b67ae56a5c08eb1f563c351a37", + "reference": "20a02782f76830b67ae56a5c08eb1f563c351a37", "shasum": "" }, "require": { - "ext-mcrypt": "*", "php": ">=5.3.0" }, + "suggest": { + "ext-mcrypt": "Required for HTTP cookie encryption" + }, "type": "library", "autoload": { "psr-0": { @@ -862,20 +859,20 @@ "rest", "router" ], - "time": "2013-09-29T19:46:31+00:00" + "time": "2015-03-08T18:41:17+00:00" }, { "name": "swiftmailer/swiftmailer", - "version": "v5.4.6", + "version": "v5.4.7", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "81fdccfaf8bdc5d5d7a1ef6bb3a61bbb1a6c4a3e" + "reference": "56db4ed32a6d5c9824c3ecc1d2e538f663f47eb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/81fdccfaf8bdc5d5d7a1ef6bb3a61bbb1a6c4a3e", - "reference": "81fdccfaf8bdc5d5d7a1ef6bb3a61bbb1a6c4a3e", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/56db4ed32a6d5c9824c3ecc1d2e538f663f47eb4", + "reference": "56db4ed32a6d5c9824c3ecc1d2e538f663f47eb4", "shasum": "" }, "require": { @@ -916,20 +913,20 @@ "mail", "mailer" ], - "time": "2017-02-13T07:52:53+00:00" + "time": "2017-04-20T17:32:18+00:00" }, { "name": "twig/twig", - "version": "v1.32.0", + "version": "v1.33.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9935b662e24d6e634da88901ab534cc12e8c728f" + "reference": "dd6ca96227917e1e85b41c7c3cc6507b411e0927" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9935b662e24d6e634da88901ab534cc12e8c728f", - "reference": "9935b662e24d6e634da88901ab534cc12e8c728f", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/dd6ca96227917e1e85b41c7c3cc6507b411e0927", + "reference": "dd6ca96227917e1e85b41c7c3cc6507b411e0927", "shasum": "" }, "require": { @@ -938,12 +935,12 @@ "require-dev": { "psr/container": "^1.0", "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.2" + "symfony/phpunit-bridge": "~3.3@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.32-dev" + "dev-master": "1.33-dev" } }, "autoload": { @@ -978,7 +975,7 @@ "keywords": [ "templating" ], - "time": "2017-02-27T00:07:03+00:00" + "time": "2017-04-20T17:39:48+00:00" }, { "name": "zendframework/zend-db", @@ -1455,16 +1452,16 @@ }, { "name": "symfony/yaml", - "version": "v2.8.17", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153" + "reference": "286d84891690b0e2515874717e49360d1c98a703" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/322a8c2dfbca15ad6b1b27e182899f98ec0e0153", - "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153", + "url": "https://api.github.com/repos/symfony/yaml/zipball/286d84891690b0e2515874717e49360d1c98a703", + "reference": "286d84891690b0e2515874717e49360d1c98a703", "shasum": "" }, "require": { @@ -1500,7 +1497,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-01-21T16:40:50+00:00" + "time": "2017-03-20T09:41:44+00:00" } ], "aliases": [],