PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject_FormBuilder » Bug #6894

_reorderElements unusual case

Details

Submitted2006-02-22 18:48 UTC
Fromcar at cespi dot unlp dot edu dot ar
Assignedjustinpatrin
StatusClosed
PackageDB_DataObject_FormBuilder
PHP VersionIrrelevant
OSALL
Roadmaps(Not assigned)

Comments

[2006-02-22 18:48 UTC] car at cespi dot unlp dot edu dot ar

Description:
------------
In case _getFieldsToRender() is disjoint from preDefOrder, there is a problem in the _reoprderElements method. The error rises at line 1652.
In know it is a very unusual case, but I think declaring the ordered variable as an empty array is a cleaner solution than the current one.

Test script:
---------------
I propose declaring $ordered variable as empty array in line 1635

[2006-02-22 19:03 UTC] car at cespi dot unlp dot edu dot ar

if you look at the code, in the lines I mentioned, In my opinion, it make sense to declare the variable.
The example you asked me to post could by like this:
class DataObjects_Distrito extends DB_DataObject
{

var $fb_fieldLabels = array('id_localidad'=>'Localidad','id_entidad'=>'Entidad');
var $fb_linkDisplayFields = array('nombre');

/************ The following two lines raise the bug ******
var $fb_preDefOrder=array('nombre');
var $fb_fieldsToRender=array('email');
//
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */

public $__table = 'distrito'; // table name
public $id; // int(11) not_null primary_key auto_increment
public $nombre; // string(100) not_null unique_key
public $id_localidad; // int(11) not_null multiple_key
public $direccion; // string(255)
public $telefono; // string(100)
public $email; // string(100)
public $id_entidad; // int(11) not_null multiple_key

/* Static get */
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Distrito',$k,$v); }

/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
}

[2006-02-22 19:21 UTC] car at cespi dot unlp dot edu dot ar

The problem with the example I gave, and the following two lines:
var $fb_preDefOrder=array('nombre');
var $fb_fieldsToRender=array('email');
That are disjoint sets of table fields of my do, gives the following error:

/usr/share/php/DB/DataObject/FormBuilder.php (1652)
Undefined variable: ordered

So I suggested a solution to, in my opinion, a better or cleaner way to write the _reorderElements method.
Please take a look at the code in the error line, and then consider declaring the ordered variable.
But as it is an unusual case, you should not consider my report, and instead advice not to declare those variables disjoints.