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

Fix broken boolean types on IniFileLoader (propelorm/Propel2#1355) #1356

Merged
merged 1 commit into from
May 26, 2017

Conversation

gboddin
Copy link
Contributor

@gboddin gboddin commented Mar 12, 2017

Hello,

I'm using master, and I was trying to configure the following in propel.properties (or propel.ini) :

propel.generator.recursive = true
propel.generator.namespaceAutoPackage = false
propel.generator.packageObjectModel = true

but it triggers the following :

  [Symfony\Component\Config\Definition\Exception\InvalidTypeException]                    
  Invalid type for path "namespaceAutoPackage". Expected boolean, but got integer.

Tested with PHP 5.6.21 and php 7.0.14.

@@ -58,7 +59,7 @@ public function supports($resource, $type = null)
*/
public function load($file, $type = null)
{
$ini = parse_ini_file($this->getPath($file), true);
$ini = parse_ini_file($this->getPath($file), true, INI_SCANNER_RAW);
Copy link
Contributor Author

@gboddin gboddin Mar 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse_ini_file()'s normal operation mode is parsing true or false to a string containing "0" or "1".

This ensure, we get "true" or "false" so it's not confused with an integerer,

However, with INI_SCANNER_RAW, integers and floats are also casted to strings, this is fixed in parseKey().

parse_ini_file could use INI_SCANNER_TYPED to fix all of this safer, but it would have broke compatibility with PHP 5.5

@marcj
Copy link
Member

marcj commented May 26, 2017

Good catch, thanks! :)

@marcj marcj merged commit 1ab6786 into propelorm:master May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants