Model override invoke cannot pass more than one parameter

Bug #689063 reported by jsherk
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PHPDevShell
Invalid
Undecided
Greg

Bug Description

Using v3 beta4

In somePlugin, setup controller named test.php like this:
<?php
class test extends PHPDS_controller
{
public function execute()
 {
 $test = $this->db->invokeQuery('somePlugin_test', 'PHPDevShell_access_logging', '1');
 echo '<pre>';
 print_r($test);
 echo '</pre>';
 }
}
return 'test';

Now setup model named test.query.php like this
<?php
class somePlugin_test extends PHPDS_query
{
protected $sql = "
 SELECT *
 FROM _db_core_settings
 WHERE setting_description='%s'
 AND setting_value=%u
";
public function invoke($params)
 {
 list($x, $y) = $params;
 $results = parent::invoke($x, $y);
 return $results;
 }
}

Now add menu button to link to test.php and click to see error:
vsprintf() [function.vsprintf]: Too few arguments
Error building sql for PHPDS_query

Now make the following change... change NOTHING ELSE except change the %u to 1 and it will perform without a problem.

Revision history for this message
TitanKing (titan-phpdevshell) wrote :

When overriding invoke pass through parameters as array:

public function invoke($params)
 {
 list($x, $y) = $params;
 $results = parent::invoke(array($x, $y));
 return $results;
 }

Greg, can you confirm if a feature to pass parameters through like with invokeQuery is possible?

Changed in phpdevshell:
importance: Undecided → Wishlist
assignee: nobody → Greg (gregfr)
Revision history for this message
Greg (gregfr) wrote :

I have to say that:

public function invoke($params)
 {
 list($x, $y) = $params;
 $results = parent::invoke($x, $y);

is obviously wrong: you must call the function's parent the same way the function has been called.

BTW, you can use named parameters:

$sql = "SELECT * FROM myTable WHERE name = '%(searchname)s'";

and:

invoke(array('searchname' => 'root'));

Changed in phpdevshell:
importance: Wishlist → Undecided
status: New → Invalid
Revision history for this message
Greg (gregfr) wrote :

hum sorry it seems to be a documentation problem, I'll work on this asap

Revision history for this message
jsherk (jeff-forerunnertv) wrote :

In a normal invokeQuery() call, you specify the parameters one after the other (not in an array) so I assumed it would the same for the override invoke($param1, $param2, $etc) as well.

The problem is solved (no bug) when using invoke(array($param1, $param2, $etc));

Thanks

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.