#013458: fetch numeric value from ini file

Description:

I am using the following to fetch a numeric value from ini file:


$cfg = ezcConfigurationManager::getInstance();
$cfg->init('ezcConfigurationIniReader', '../../config' );
var_dump($cfg->getNumberSetting('config', 'test', 'test_numeric'));

my ini file has the content:


[test]
test_numeric = 6507260348

And the result from var_dump is 2147483647
It should be 6507260348


Environment:

Operating System: Linux
PHP Version: (please be specific, like '4.4.3' or '5.1.5') 5.2
Database and version:
Browser (and version):


Steps to Reproduce:

see the description


- Attachments

No attachments for this issue.


- Comments

Are you running on a 32-bit platform? (Or have compiled PHP as 32-bit application?)

#257709 by Derick Rethans on August 5th, 2008 [Permanent Link]

"Are you running on a 32-bit platform?" - Yes.

#257769 by Simeon Goranov on August 8th, 2008 [Permanent Link]

Maybe is better to cast only when the variable is numeric and is less than 2147483647, else you can assume that it's string ? I thinks so, cause modified user data is worse than integer data which is presented like float or string.

#257791 by Simeon Goranov on August 13th, 2008 [Permanent Link]

Okay, this is not a "bug". If you ask for the configuration value as integer, the component will cast this value to a number. I can't very easily detect whether the number fits in range. Because you ask for a number (integer), the component returns this type. Unfortunately PHP does simply limit it to the highest value if it is out of range. If you request this setting as a string, or float, it should return you the correct value. (If that's not the case, please re-open this report).

#257921 by Derick Rethans on August 26th, 2008 [Permanent Link]

You are right, if it's possible to fetch big integer value like a string from ini file. Maybe there is a way to fetch the value like a string, but how ? I tried with:

$integer_1 = $cfg->getStringSetting('config', 'General', 'integer1');

The result was:

ezcConfigurationSettingWrongTypeException: The expected type for the setting 'General', 'integer1' is 'string'. The setting was of type 'integer'.

With getSetting() The value is casted automatically and it's not correct. Maybe getSetting() should returns the value like a string, no matter if it's an integer or something else ?

#258002 by Simeon Goranov on September 1st, 2008 [Permanent Link]

getSetting() returns casted integer value, not a string, when the value is too big integer

Code:
$cfg = ezcConfigurationManager::getInstance();
$cfg->init('ezcConfigurationIniReader', './' );
$integer_1 = $cfg->getSetting('config', 'General', 'integer1');

Ini file:
[General]
integer1 = 23213213123123123123

Result:
int 2147483647

#258003 by Simeon Goranov on September 1st, 2008 [Permanent Link]

Fixed in rev. 9029-9033 - it will now use a string if the integer is out of range.

#258391 by Derick Rethans on October 3rd, 2008 [Permanent Link]

- History
Properties
Type Bug
Priority Medium
Component Components » Configuration
Affects 1.3 - Configuration 1.3
Fix Version 2008.2alpha1 - eZ components 2008.2alpha1
Reporter Simeon Goranov
Responsible Derick Rethans
Status 0 Closed
Resolution Fixed
Created August 5th, 2008
Updated October 3rd, 2008
Resolved October 3rd, 2008
 
Navigation [Permanent Link]
Previous Issue
Back to Issues List
Next Issue: #015537
  Graph shows to small and truncated rotated axis labels