I inherit old cms build on CodeIgniter 2.0.2 with DataMapper ORM 1.8.0 and the website is with ads. When the ads were under a few thousands it was working fine. Now the ads are close to 20 thousands and it just crash. And there is not error log. The problem is on homepage and sometimes on ad page. I can't figure it out why. I had to edit this function located in "./application/libraries/datamapper.php" so it won't crash.
/**
* Process Query
*
* Converts a query result into an array of objects.
* Also updates this object
*
* @ignore
* @param CI_DB_result $query
*/
protected function _process_query($query)
{
if ($query->num_rows() > 0)
{
// Populate all with records as objects
$this->all = array();
$this->_to_object($this, $query->row());
// don't bother recreating the first item.
$index = ($this->all_array_uses_ids && isset($this->id)) ? $this->id : 0;
$this->all[$index] = $this->get_clone();
if($query->num_rows() > 1)
{
$model = get_class($this);
$first = TRUE;
foreach ($query->result() as $key =>$row)
{
if($first)
{
$first = FALSE;
continue;
}
$item = new $model();
$this->_to_object($item, $row);
if($this->all_array_uses_ids && isset($item->id))
{
$this->all[$item->id] = $item;
} //HERE IS THE EDIT
else if($key < 12)
{
$this->all[] = $item;
}
}
}
// remove instantiations
$this->_instantiations = NULL;
// free large queries
if($query->num_rows() > $this->free_result_threshold)
{
$query->free_result();
}
}
else
{
// Refresh stored values is called by _to_object normally
$this->_refresh_stored_values();
}
}
On line "HERE IS THE EDIT" , I add if the key is less than 12 to add then to $this->all . If I put more than 12 , it crashes.
My question is how can I overcome this? Has anyone come a cross this? On the server I use php 7 and etc. It is as modern server.
I set: public $free_result_threshold = 50; public $production_cache = FALSE; //I turn it on but it didn't help
Any idea would be helpful.