Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Request #16656 New 'linebreak' option for IniCommented container
Submitted: 2009-09-29 14:42 UTC
From: wiesemann Assigned: cweiske
Status: Closed Package: Config (version 1.10.11)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2009-09-29 14:42 UTC] wiesemann (Mark Wiesemann)
Description: ------------ The attached patch adds a new 'linebreak' option (default value: "\n") to the IniCommented container. The patch also adds error handling for a failure of the file() call.

Comments

 [2009-09-29 15:09 UTC] wiesemann (Mark Wiesemann)
Patch upload is currently broken ... Index: . =================================================================== --- . (revision 288931) +++ . (working copy) @@ -26,12 +26,12 @@ class Config_Container_IniCommented { /** - * This class options - * Not used at the moment + * Class options + * linebreak: char used for linebreak * * @var array */ - var $options = array(); + var $options = array('linebreak' => "\n"); /** * Constructor @@ -59,6 +59,9 @@ return PEAR::raiseError("Datasource file does not exist.", null, PEAR_ERROR_RETURN); } $lines = file($datasrc); + if ($lines === false) { + return PEAR::raiseError('File could not be read', null, PEAR_ERROR_RETURN); + } $n = 0; $lastline = ''; $currentSection =& $obj->container; @@ -268,10 +271,10 @@ } switch ($obj->type) { case 'blank': - $string = "\n"; + $string = $this->options['linebreak']; break; case 'comment': - $string = ';'.$obj->content."\n"; + $string = ';'.$obj->content . $this->options['linebreak']; break; case 'directive': $count = $obj->parent->countChildren('directive', $obj->name); @@ -305,19 +308,19 @@ } if ($childrenCount[$obj->name] == $count-1) { // Clean the static for future calls to toString - $string .= $commaString[$obj->name].$content."\n"; + $string .= $commaString[$obj->name] . $content . $this->options['linebreak']; unset($childrenCount[$obj->name]); unset($commaString[$obj->name]); } else { $commaString[$obj->name] .= $content.', '; } } else { - $string = $obj->name.' = '.$content."\n"; + $string = $obj->name . ' = ' . $content . $this->options['linebreak']; } break; case 'section': if (!$obj->isRoot()) { - $string = '['.$obj->name."]\n"; + $string = '[' . $obj->name . "]" . $this->options['linebreak']; } if (count($obj->children) > 0) { for ($i = 0; $i < count($obj->children); $i++) {
 [2010-12-22 02:06 UTC] cweiske (Christian Weiske)
-Status: Open +Status: Closed -Assigned To: +Assigned To: cweiske
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.