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:

Archive /

Our old forums are still available as a read-only archive.

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

Bad class to singleton error when extending PageComment class


Go to End


2 Posts   3167 Views

Avatar
ivanhoe

Community Member, 2 Posts

11 December 2008 at 5:14am

I'm trying to add a couple of extra DB fields to page comments, but I've got totally stuck with the error from the title. Code in questions is:

class OurPageComment extends PageComment {
static $db = array(
"Company" => "Varchar(100)",
"Email" => "Varchar(255)",
"Homepage" => "Varchar(255)",
);
}

As you can see I've just tried extending PageComment the same way it's done with other classes in tutorials/docs, but it obviously can't be done that way.

Error trace (when I go to /db/build/..):

* Bad class to singleton() - OurPageComment
Line 263 of Core.php
* singleton(OurPageComment)
Line 161 of DatabaseAdmin.php
* DatabaseAdmin->doBuild()
Line 81 of DatabaseAdmin.php
* DatabaseAdmin->build(HTTPRequest)
Line 162 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 107 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 257 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 106 of Director.php
* Director::direct(db/build)
Line 111 of main.php

Avatar
ivanhoe

Community Member, 2 Posts

11 December 2008 at 7:18am

Ok, I managed to solve the problem, the class that extends PageComment has to be in a separate file. I had it defined in the same file where my page class is defined and SS couldn't find it there obviously.