SAAS-624: Request to rest/media throws an exception if the data set is too large
This commit is contained in:
parent
1f6f880dad
commit
df28b47b92
|
@ -14,15 +14,27 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
|
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$files_array = array();
|
$pager = CcFilesQuery::create()->paginate($page=1, $maxPerPage=50);
|
||||||
foreach (CcFilesQuery::create()->find() as $file)
|
$numPages = $pager->getLastPage();
|
||||||
{
|
|
||||||
array_push($files_array, CcFiles::sanitizeResponse($file));
|
$nextPage = 1;
|
||||||
|
|
||||||
|
while ($nextPage <= $numPages) {
|
||||||
|
$pager = CcFilesQuery::create()->paginate($page=$nextPage, $maxPerPage=50);
|
||||||
|
|
||||||
|
$files = array();
|
||||||
|
foreach($pager->getResults() as $file) {
|
||||||
|
array_push($files, CcFiles::sanitizeResponse($file));
|
||||||
|
}
|
||||||
|
$this->getResponse()->appendBody(json_encode($files));
|
||||||
|
unset($files);
|
||||||
|
|
||||||
|
$nextPage +=1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(200)
|
->setHttpResponseCode(200);
|
||||||
->appendBody(json_encode($files_array));
|
|
||||||
|
|
||||||
/** TODO: Use this simpler code instead after we upgrade to Propel 1.7 (Airtime 2.6.x branch):
|
/** TODO: Use this simpler code instead after we upgrade to Propel 1.7 (Airtime 2.6.x branch):
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
|
|
Loading…
Reference in New Issue