PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Console » Console_Table » Bug #3587

_calculateCelLengths triggers error on first call

Details

Submitted2005-02-25 01:01 UTC
Fromconstab dot 3 dot wiseowl at spamgourmet dot com
Assignedyunosh
StatusClosed
PackageConsole_Table
PHP Version4.3.10
OSn/a
Roadmaps(Not assigned)

Comments

[2005-02-25 01:01 UTC] constab dot 3 dot wiseowl at spamgourmet dot com

Description:
------------
Console_Table version 1.0.1

_calculateCellLengths method triggers undefined offset errors because _cell_lengths array doesn't have any elements on the first call to this function.

Putting the @ before the variables doesn't supress warnings about undefined offsets when using a custom error handling function (I believe that's the case) so therefore it would be nice to have this changed.

Patch below initialises the _cell_lengths array before calling _calculateCellLengths. Hope this helps and thanks heaps for a great class.

Reproduce code:
---------------
// $Id: Table.php,v 1.4 2003/03/03 11:37:26 richard Exp $

. . .

function _validateTable()
{

. . . (at line 197)
// init _cell_lengths with zeros where cell lengths haven't been calculated yet
$this->_cell_lengths = array_pad($this->_cell_lengths,$this->_max_cols,0);

// Update cell lengths
$this->_calculateCellLengths($this->_data[$i]);

. . .