From beac8867179137fc01a872f073b99dda9fb114d8 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Sat, 27 Oct 2018 11:55:05 -0400 Subject: [PATCH] v2.0.4 --- public/.htaccess | 7 +++---- src/core/Directus/Application/Application.php | 2 +- .../Directus/Database/Schema/SchemaManager.php | 3 +-- .../Database/Schema/Sources/MySQLSchema.php | 12 ++++++++++-- .../Database/Schema/Sources/SchemaInterface.php | 2 +- src/core/Directus/Services/TablesService.php | 11 ++++++++++- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++++------- vendor/composer/autoload_static.php | 10 +++++----- 9 files changed, 39 insertions(+), 24 deletions(-) diff --git a/public/.htaccess b/public/.htaccess index 7ac810d4d3..61e62d0117 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -7,13 +7,12 @@ Options +SymLinksIfOwnerMatch RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - # Map all admin endpoints to the admin app + # Map all admin endpoints to the admin app (except static files) + RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^admin/(.*) admin/index.html [NC,L] - # Yield static media + # Map all other requests to invoke the API router (except static files) RewriteCond %{REQUEST_FILENAME} !-f - - # Map all other requests to the main front controller, invoking the API router RewriteRule !^admin index.php?%{QUERY_STRING} [L] diff --git a/src/core/Directus/Application/Application.php b/src/core/Directus/Application/Application.php index 9a8d13695e..11d1ecf6fa 100644 --- a/src/core/Directus/Application/Application.php +++ b/src/core/Directus/Application/Application.php @@ -13,7 +13,7 @@ class Application extends App * * @var string */ - const DIRECTUS_VERSION = '2.0.3'; + const DIRECTUS_VERSION = '2.0.4'; /** * NOT USED diff --git a/src/core/Directus/Database/Schema/SchemaManager.php b/src/core/Directus/Database/Schema/SchemaManager.php index 26075d3324..57df6d9ffc 100644 --- a/src/core/Directus/Database/Schema/SchemaManager.php +++ b/src/core/Directus/Database/Schema/SchemaManager.php @@ -162,8 +162,7 @@ public function getField($tableName, $columnName, $skipCache = false) if (!$columnSchema || $skipCache) { // Get the column schema data from the source - $columnResult = $this->source->getFields($tableName, ['column_name' => $columnName]); - $columnData = $columnResult->current(); + $columnData = $this->source->getField($tableName, $columnName); // Create a column object based of the table schema data $columnSchema = $this->createFieldFromArray($columnData); diff --git a/src/core/Directus/Database/Schema/Sources/MySQLSchema.php b/src/core/Directus/Database/Schema/Sources/MySQLSchema.php index d5f6ecaf34..0ff55e81b1 100644 --- a/src/core/Directus/Database/Schema/Sources/MySQLSchema.php +++ b/src/core/Directus/Database/Schema/Sources/MySQLSchema.php @@ -136,9 +136,9 @@ public function getCollection($collectionName) /** * @inheritDoc */ - public function getFields($tableName, $params = null) + public function getFields($tableName, array $params = []) { - return $this->getAllFields(['collection' => $tableName]); + return $this->getAllFields(array_merge($params, ['collection' => $tableName])); } /** @@ -202,6 +202,14 @@ public function getAllFields(array $params = []) ]); } + if (isset($params['field'])) { + $where = $selectOne->where->nest(); + $where->equalTo('DF.field', $params['field']); + $where->or; + $where->equalTo('SF.COLUMN_NAME', $params['field']); + $where->unnest(); + } + $selectOne->order(['collection' => 'ASC', 'SF.ORDINAL_POSITION' => 'ASC']); $selectTwo = new Select(); diff --git a/src/core/Directus/Database/Schema/Sources/SchemaInterface.php b/src/core/Directus/Database/Schema/Sources/SchemaInterface.php index adc4634b2f..d96bd4d231 100644 --- a/src/core/Directus/Database/Schema/Sources/SchemaInterface.php +++ b/src/core/Directus/Database/Schema/Sources/SchemaInterface.php @@ -53,7 +53,7 @@ public function getCollection($collectionName); * * @return ResultSet */ - public function getFields($tableName, $params = null); + public function getFields($tableName, array $params = []); /** * Gets all columns in the current schema diff --git a/src/core/Directus/Services/TablesService.php b/src/core/Directus/Services/TablesService.php index 9e6e201f87..e85be80dfb 100644 --- a/src/core/Directus/Services/TablesService.php +++ b/src/core/Directus/Services/TablesService.php @@ -588,7 +588,7 @@ public function changeColumn($collectionName, $fieldName, array $data, array $pa $this->validateFieldPayload($data, array_keys($data), $params); // Remove field from data - ArrayUtils::pull($data, 'field'); + ArrayUtils::remove($data, 'field'); // ---------------------------------------------------------------------------- @@ -813,6 +813,15 @@ protected function addFieldInfo($collection, $field, array $data) 'field' => $field ]); + // Get the Directus based on the source type + if (ArrayUtils::get($data, 'type') === null) { + $fieldObject = $this->getSchemaManager()->getField($collection, $field); + + if ($fieldObject) { + $data['type'] = $this->getSchemaManager()->getSource()->getTypeFromSource($fieldObject->getDataType()); + } + } + $collectionObject = $this->getSchemaManager()->getCollection('directus_fields'); return $this->getFieldsTableGateway()->createRecord( diff --git a/vendor/autoload.php b/vendor/autoload.php index 936813dce6..6148dced40 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit03fd323c8f999d61dfaf5f19e934938c::getLoader(); +return ComposerAutoloaderInit2c883ca79e89c0b0037789721d7a9e1b::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 2e8e96bef8..b3820227a0 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit03fd323c8f999d61dfaf5f19e934938c +class ComposerAutoloaderInit2c883ca79e89c0b0037789721d7a9e1b { private static $loader; @@ -19,15 +19,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit03fd323c8f999d61dfaf5f19e934938c', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit2c883ca79e89c0b0037789721d7a9e1b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit03fd323c8f999d61dfaf5f19e934938c', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit2c883ca79e89c0b0037789721d7a9e1b', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -39,19 +39,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire03fd323c8f999d61dfaf5f19e934938c($fileIdentifier, $file); + composerRequire2c883ca79e89c0b0037789721d7a9e1b($fileIdentifier, $file); } return $loader; } } -function composerRequire03fd323c8f999d61dfaf5f19e934938c($fileIdentifier, $file) +function composerRequire2c883ca79e89c0b0037789721d7a9e1b($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index f99dcb7cc1..4bfa18cd93 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c +class ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b { public static $files = array ( '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', @@ -2963,10 +2963,10 @@ class ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c::$prefixesPsr0; - $loader->classMap = ComposerStaticInit03fd323c8f999d61dfaf5f19e934938c::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b::$prefixesPsr0; + $loader->classMap = ComposerStaticInit2c883ca79e89c0b0037789721d7a9e1b::$classMap; }, null, ClassLoader::class); }