PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
column formatter sends apache into a tight loop

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures
View previous topic :: View next topic  
Author Message
sutterp



Joined: 16 Apr 2008
Posts: 6
Location: Western Australia

PostPosted: Wed May 07, 2008 10:42 am    Post subject: column formatter sends apache into a tight loop Reply with quote

Consider the following column formatter callbacks.
Code:
   # Column Formatter for an input field
   function addInput($params,$args) {
   print_r("<pre>addColumn");var_dump($args);print_r("</pre>");
      $colname = $args['colname'];
      $size = $args['size'];
      extract($params);
      return('<input type="text" ' .
         'name="' . $colname . '-' . $record['sparesvehiclestpk'] . '" ' .
         'value="' . $record[$colname] . '" ' .
         'size="' . $size . '" ' .
         'class="textoc" />');
   }
   
   // -----------------------------------------------------------------------------------------------
   # Column Formatter for the normal data columns
   function addText($params,$args) {
   print_r("<pre>addColumn");var_dump($args);print_r("</pre>");
   $colname = $args['colname'];
      extract($params);
      return($record[$colname]);
   }

The formatters are used in the following manner in the addColumn functions.
Code:

   $datagrid->addColumn(new Structures_DataGrid_Column('Mob.',
      'vehiclestpk',
      'vehiclestpksort',
      array('class'=>'colValueC'),
      null,
      'AddText()',
      array('colname'=>'vehiclestpk')));
   
   $datagrid->addColumn(new Structures_DataGrid_Column('Quant.',
      'quantity',
      'quantity',
      array('class'=>'colValueC'),
      null,
      'AddInput()',
      array('colname'=>'quantity','size'=>'3')));
   
   $datagrid->addColumn(new Structures_DataGrid_Column('Description',
      'description',
      'description',
      array('class'=>'colValueC'),
      null,
      'AddInput()',
      array('colname'=>'description','size'=>'20')));

This works nicely. I can in fact add as many AddInput formatters as I want. If I add however any another addColumn which does not have AddInput as formatter, the program goes into a tight loop until http-prefork exhausts cpu limit. http-prefork consumes all available cpu. AddInput appears to break some code somewhere.

The following warnings are issued:
Quote:
Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 89

Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 89

Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 90

Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 91

Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 92

Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 93

Warning: Cannot use a scalar value as an array in /data/www/intranet/spares/compiled/%%-19^%%-1964659800^sparesGrid_VehicleDe.inc.scr.php on line 94

Here is the code from the the compile file
Quote:

$this->_sections['row']['index'] += $this->_sections['row']['step'], $this->_sections['row']['iteration']++):
$this->_sections['row']['rownum'] = $this->_sections['row']['iteration'];
$this->_sections['row']['index_prev'] = $this->_sections['row']['index'] - $this->_sections['row']['step'];
$this->_sections['row']['index_next'] = $this->_sections['row']['index'] + $this->_sections['row']['step'];
$this->_sections['row']['first'] = ($this->_sections['row']['iteration'] == 1);
$this->_sections['row']['last'] = ($this->_sections['row']['iteration'] == $this->_sections['row']['total']);


What am I missing?

Any clues welcome

Thanks

Peter

oops, I forgot to mention that the code works fine under php5, the symptoms manifest only under php4.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1011

PostPosted: Thu May 08, 2008 10:23 pm    Post subject: Reply with quote

Sorry, without your (almost) complete code and templates, this will be hard to debug. You could maybe try whether another column works without Smarty, e.g. by just rendering an HTML_Table with Structures_DataGrid.

One note about your formatter definitions: You're defining 'colname' in the array for the formatters. This isn't really needed because the name of the column is available via $params['fieldName'].
Back to top
View user's profile Send private message
sutterp



Joined: 16 Apr 2008
Posts: 6
Location: Western Australia

PostPosted: Fri May 09, 2008 1:39 pm    Post subject: Reply with quote

The observed symptoms are caused by the column sort argument. When a column sort supplied for an <input type="text"> field smarty appears to throw a spanner into the works. Specifying null as column sort fixed the problem. I guess, it does not make much sense to sort over a series of input fields.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1011

PostPosted: Fri May 09, 2008 3:37 pm    Post subject: Reply with quote

sutterp wrote:
I guess, it does not make much sense to sort over a series of input fields.


I agree, I would disable sorting for this column (third parameter of column constructor IIRC).
Back to top
View user's profile Send private message
sutterp



Joined: 16 Apr 2008
Posts: 6
Location: Western Australia

PostPosted: Fri May 09, 2008 4:47 pm    Post subject: Reply with quote

However, this in not yet the end of the story, this is, I believe, a bug manifesting.

Consider the following code used, and working fine under php5.

Code:
   $dat =& new Structures_DataGrid(50);
   $dat->setRequestPrefix('dat_');
   $dat->setDefaultSort(array('sort1' => 'ASC'));
   $status = $dat->bind($datSql, $dsn);
   
   $dat->addColumn(new Structures_DataGrid_Column('Group',
      'sparesgroupname',
      'sort1',
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'sparesgroupname')));
   
   $dat->addColumn(new Structures_DataGrid_Column('Manufacturer',
      'manufacturer',
      'manufacturer',
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'manufacturer')));
   
   $dat->addColumn(new Structures_DataGrid_Column('Supplier',
      'supplier',
      'supplier',
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'supplier')));
   
   $dat->addColumn(new Structures_DataGrid_Column('Supplier Part No',
      'supplierpartno',
      null,
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'supplierpartno')));
   
   $dat->addColumn(new Structures_DataGrid_Column('S',
      'supplierpartno',
      null,
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'supplierpartno')));
   
   $dat->addColumn(new Structures_DataGrid_Column('Part Description',
      'sdescription',
      null,
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'sdescription')));
   
   $dat->addColumn(new Structures_DataGrid_Column('Quantity',
      'quantity',
      null,
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'quantity')));
   
   $dat->addColumn(new Structures_DataGrid_Column('Remarks',
      'vdescription',
      null,
      array('class'=>'colValueL'),
      null,
      'AddText()',
      array('colname'=>'sdescription')));
   


and here is the html source generated after rendering it via smarty under php5.

Code:
<table class="dstable" cellspacing="0" border="0">
<tr class="colheads">
<th class="colValueL" >
<a href="/spares/php/sparesGrid_List.php?VisionAcctableFK=HAWKINS-539&amp;VehiclesTPK=539&amp;dat_orderBy=sort1&amp;dat_direction=DESC&amp;dat_page=1">Group</a>                                                                                                ▼</th>
<th class="colValueL" >
<a href="/spares/php/sparesGrid_List.php?VisionAcctableFK=HAWKINS-539&amp;VehiclesTPK=539&amp;dat_orderBy=manufacturer&amp;dat_direction=ASC&amp;dat_page=1">Manufacturer</a>
</th>
<th class="colValueL" >
<a href="/spares/php/sparesGrid_List.php?VisionAcctableFK=HAWKINS-539&amp;VehiclesTPK=539&amp;dat_orderBy=supplier&amp;dat_direction=ASC&amp;dat_page=1">Supplier</a>
</th>
<th class="colValueL" >
Supplier Part No
</th>
<th class="colValueL" >
S
</th>
<th class="colValueL" >
Part Description
<th>
<th class="colValueL" >
Quantity
</th>
<th class="colValueL" >
Remarks
</th>
</tr>
<tr >
<td class="colValueL" >Filters - Fuel</td>
<td class="colValueL" >Ryco</td>
<td class="colValueL" >Truck City</td>
<td class="colValueL" >Z14K</td>
<td class="colValueL" >Z14K</td>
<td class="colValueL" >Engine fuel filter X14K</td>
<td class="colValueL" >1</td>
<td class="colValueL" >Engine fuel filter X14K</td>
</tr>

but the output is screwed up under php4
Code:

<table class="dstable" cellspacing="0" border="0">
<tr class="colheads">
<th class="colValueL" >
<a href="/spares/php/sparesGrid_List.php?VisionAcctableFK=HAWKINS-539&amp;VehiclesTPK=539&amp;dat_orderBy=sort1&amp;dat_direction=DESC&amp;dat_page=1">Group</a>

</th>
<th class="colValueL" >
<a href="/spares/php/sparesGrid_List.php?VisionAcctableFK=HAWKINS-539&amp;VehiclesTPK=539&amp;dat_orderBy=manufacturer&amp;dat_direction=ASC&amp;dat_page=1">Manufacturer</a>
</th>
<th             " >
<a href="/spares/php/sparesGrid_List.php?VisionAcctableFK=HAWKINS-539&amp;VehiclesTPK=539&amp;dat_orderBy=supplier&amp;dat_direction=ASC&amp;dat_page=1">Supplier</a>
</th>
<th class="colValueL" >
Supplier Part No
</th>
<th class="colValueL" >
S
</th>
<th >
</th>
<th class="colValueL" >
Quantity
</th>
<th class="colValueL" >
Remarks
</th>
</tr>
<tr >
<td class="colValueL" >Filters - Fuel</td>
<td class="colValueL" >Ryco</td>
<td             " >Truck City</td>
<td class="colValueL" >Z14K</td>
<td class="colValueL" >Z14K</td>
<td >Engine fuel filter X14K</td>
<td class="colValueL" >1</td>
<td class="colValueL" >Engine fuel filter X14K</td>
</tr>

Some of the header data is corrupted and pieces of the header are missing.

For completeness, here is the code of my formatter.
Code:
   // -----------------------------------------------------------------------------------------------
   # Column Formatter for the normal data columns
   function addText($params,$args) {
      $colname = $args['colname'];
      extract($params);
      return($record[$colname]);
   }


What next?
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1011

PostPosted: Fri May 09, 2008 5:09 pm    Post subject: Reply with quote

I don't know much about Smarty, but I'd guess that this is a Smarty problem. Maybe you could post the code and the description in a Smarty forum or mailing list?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software