Bug in 5.5.1 ContentBlockController::replaceDownloadFileID()?

Permalink
A client is receiving the following error after using one of my company's add-ons:

Fatal error: Call to a member function getCollectionID() on a non-object in <snip>/concrete5.5.1/concrete/blocks/content/controller.php on line 233

I will admit to not being familiar with this code but I gotta say it looks fishy:

226 private function replaceDownloadFileID($match) {
227   $fID = $match[1];
228   if ($fID > 0) {
229     $c = Page::getCurrentPage();
230     if (is_object($c)) {
231       return View::url('/download_file', 'view', $fID);
232     } else {
233       return View::url('/download_file', 'view', $fID, $c->getCollectionID());               
234     }
235   }
236 }


Should lines 231 and 233 be swapped?

 
andrew replied on at Permalink Reply
andrew
Yeah. I actually got a pull request for this recently. It is merged and fixed in github.
ScottC replied on at Permalink Best Answer Reply
ScottC
Yeah they should be, i submitted the pull request.

I only found this through a tools request method that called upon the block controller for its translate methods. A workaround would be to get the request object and if the request object isn't set then set it to Page::getbyID(HOME_CID) or something similar.

-Scott
nklatt replied on at Permalink Reply
Thanks guys - that fixed the client's problem.