Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS_HTTPRequest could not be converted to int

Go to End

3 Posts   1661 Views


Community Member, 245 Posts

5 October 2010 at 9:11am


I have used the code below hundreds of times in Silverstripe. Just trying to pass in a limit to a function to decide how many items to chow in the template:

public function News($limit=0) {
           return DataObject::get("NewsPage", "", 'Date DESC', "", $limit); 
           return DataObject::get("NewsPage", "", 'Date DESC', "", ""); 

Since I've been working in 2.4.1, I get the following error:

[Notice] Object of class SS_HTTPRequest could not be converted to int

On this line:


WHY? What is wrong with this code?



Community Member, 473 Posts

5 October 2010 at 9:17am

You're calling the method by using a URL. Something like, which means a SS_HTTPRequest is passed as the argument. You could use something like

if(is_numeric($limit) && $limit != 0)

which should handle this better.


Community Member, 245 Posts

6 October 2010 at 3:29am


I never really "got" the URL "action" thing until now. I was clearly hoodwinked by having a page and a function with the same name. So I guess the function takes precedence....