Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue 14756 - File not found if path contains . #14757

Merged
merged 6 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed `Phalcon\Storage\Adapter\Stream::getKeys()` bug in the absence of a directory with a prefix name [#14725](https://github.com/phalcon/cphalcon/issues/14725), [#14721](https://github.com/phalcon/cphalcon/pull/14721)
- Fixed `Phalcon\Debug::onUncaughtException` Should accept `\Throwable` instead of `\Exception` as an argument [#14738](https://github.com/phalcon/cphalcon/pull/14738)
- Fixed `Phalcon\Mvc\Model\Binder` to now correctly call `has` and `set` on the cache object [#14743](https://github.com/phalcon/cphalcon/pull/14743)
- Fixed `Phalcon\Config\ConfigFactory` to always add the correct extension [#14756](https://github.com/phalcon/cphalcon/issues/14756)

# [4.0.2](https://github.com/phalcon/cphalcon/releases/tag/v4.0.1) (2020-01-12)
## Fixed
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Config/ConfigFactory.zep
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ConfigFactory extends AbstractFactory
first = config["filePath"],
second = null;

if !strpos(first, ".") {
if (empty(pathinfo(first, PATHINFO_EXTENSION))) {
let first = first . "." . lcfirst(adapter);
}

Expand Down
58 changes: 58 additions & 0 deletions tests/_data/assets/config/config-with.in-file.name.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[annotations]
adapter = apcu
options.prefix = annotations
options.lifetime = 3600

[cache]
adapter = libmemcached
options.prefix = app-data

[config]
adapter = ini
filePath = PATH_DATA"assets/config/config-with.in-file.name.ini"
filePathExtension = PATH_DATA"assets/config/config-with.in-file.name.ini"

[database]
adapter = mysql
options.host = DATA_MYSQL_HOST
options.username = DATA_MYSQL_USER
options.password = DATA_MYSQL_PASS
options.dbname = DATA_MYSQL_NAME
options.port = DATA_MYSQL_PORT
options.charset = DATA_MYSQL_CHARSET

[image]
adapter = imagick
file = PATH_DATA"assets/images/phalconphp.jpg"

[logger]
name = "my-logger"
options.adapters.0.adapter = stream
options.adapters.0.options.name = PATH_OUTPUT"tests/logs/factory.log"
options.adapters.1.adapter = stream
options.adapters.1.options.name = PATH_OUTPUT"tests/logs/factory2.log"

[paginator]
adapter = queryBuilder
options.limit = 20
options.page = 1

[translate]
adapter = gettext
options.locale = en_US.utf8
options.defaultDomain = messages
options.directory = PATH_DATA"assets/translation/gettext"
options.category = LC_MESSAGES




[session]
uniqueId = my-private-app
host = 127.0.0.1
port = 11211
persistent = true
lifetime = 3600
prefix = my_
adapter = Files

16 changes: 16 additions & 0 deletions tests/unit/Config/ConfigFactory/LoadCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ public function configFactoryLoadConfig(UnitTester $I)
Ini::class,
$ini
);

//Issue 14756
$configFile = dataDir('assets/config/config-with.in-file.name.ini');
$ini = new Ini($configFile, INI_SCANNER_NORMAL);
$I->assertInstanceOf(
Ini::class,
$ini
);

/** @var Ini $ini */
$ini = (new ConfigFactory())->load($ini->config->toArray());

$I->assertInstanceOf(
Ini::class,
$ini
);
}

/**
Expand Down