History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: OSC-206
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Andy Cox
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
osCommerce Core

Caching Queries creates empty array element.

Created: 22/Jun/07 11:03 PM   Updated: 28/Mar/09 08:00 PM
Component/s: Database
Affects Version/s: 3.0 Alpha 4
Fix Version/s: None


 Description  « Hide
When caching queries an empty element is added to the end of $this->cache_data array in the osC_Database_Result object. This causes an incorrect return from calls to numberOfRows() on cached data.

For example the configuration query in application_top.php :

// set the application parameters
  $Qcfg = $osC_Database->query('select configuration_key as cfgKey, configuration_value as cfgValue from :table_configuration');
  $Qcfg->bindTable(':table_configuration', TABLE_CONFIGURATION);
  $Qcfg->setCache('configuration');
  $Qcfg->execute();

  while ($Qcfg->next()) {
    define($Qcfg->value('cfgKey'), $Qcfg->value('cfgValue'));
  }

  $Qcfg->freeResult();

if you print_r($Qcfg) you can see the $this->cached_data array has an empty element at the end.

 It can be easily resolved by checking $this->result before adding to the cached data array.

 All   Comments   Change History      Sort Order:
Andy Cox [28/Mar/09 08:00 PM]