Skip to content

Commit

Permalink
Merge pull request #14757 from ruudboon/fix-14756-ini
Browse files Browse the repository at this point in the history
Fixed issue 14756 - File not found if path contains .
  • Loading branch information
ruudboon authored Jan 23, 2020
2 parents 3d633fa + dec638c commit 4519643
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fixed `Phalcon\Debug::onUncaughtException` Should accept `\Throwable` instead of `\Exception` as an argument [#14738](https://github.com/phalcon/cphalcon/pull/14738)
- Fixed `Phalcon\Validation\ValidatorFactory` Should return Phalcon\Validation\ValidatorInterface [14749](https://github.com/phalcon/cphalcon/pull/14749)
- 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

0 comments on commit 4519643

Please sign in to comment.