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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[User Error] Bad class to singleton() - HomePage


Reply


3 Posts   1527 Views

Avatar
slavelabourer

Community Member, 25 Posts

28 April 2009 at 11:07pm

Hi, just playing with silverstripe for the first time, hoping that this is a typical newbie problem, but am struggling to find resources for specific errors. Hope someone can help thanks for your time.

Dan.

Problem occurs when flushing the database after creating the homepage.php in tutorial 1.

Building Database

Creating database tables
# PageComment
# SiteTree
# Field SiteTree.ClassName: changed to enum('SiteTree','Page','GhostPage','HomePage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree')
# Field SiteTree_Live.ClassName: changed to enum('SiteTree','Page','GhostPage','HomePage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree')
# Field SiteTree_versions.ClassName: changed to enum('SiteTree','Page','GhostPage','HomePage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree')
# Email_BounceRecord
# QueuedEmail
# File
# Group
# LoginAttempt
# Member
# MemberPassword
# Permission
# Widget
# WidgetArea
# Page
# GhostPage
# ErrorPage
# RedirectorPage
# VirtualPage
# Image
# Folder
# Image_Cached

Creating database records
# PageComment
# SiteTree
[User Error] Bad class to singleton() - HomePage
GET /silver/SilverStripe/dev/build?flush=1

Line 263 in /home/digitalp/public_html/silver/SilverStripe/sapphire/core/Core.php
Source

254    if(($pos = strpos($className,'_')) !== false) $className = substr($className,0,$pos);
255    if($_CLASS_MANIFEST[$className]) return $_CLASS_MANIFEST[$className];
256 }
257
258 function singleton($className) {
259    static $_SINGLETONS;
260    if(!isset($className)) user_error("singleton() Called without a class", E_USER_ERROR);
261    if(!is_string($className)) user_error("singleton() passed bad class_name: " . var_export($className,true), E_USER_ERROR);
262    if(!isset($_SINGLETONS[$className])) {
263     if(!class_exists($className)) user_error("Bad class to singleton() - $className", E_USER_ERROR);
264       $_SINGLETONS[$className] = Object::strong_create($className,null, true);
265       if(!$_SINGLETONS[$className]) user_error("singleton() Unknown class '$className'", E_USER_ERROR);
266    }
267    return $_SINGLETONS[$className];
268 }
269

Trace

* Bad class to singleton() - HomePage
Line 263 of Core.php
* singleton(HomePage)
Line 1867 of DataObject.php
* DataObject::has_own_table(HomePage)
Line 89 of ClassInfo.php
* ClassInfo::dataClassesFor(SiteTree)
Line 2109 of DataObject.php
* DataObject->buildSQL(URLSegment = 'home')
Line 2366 of DataObject.php
* DataObject->instance_get_one(URLSegment = 'home',)
Line 2320 of DataObject.php
* DataObject::get_one(SiteTree,URLSegment = 'home')
Line 925 of SiteTree.php
* SiteTree->requireDefaultRecords()
Line 210 of DatabaseAdmin.php
* DatabaseAdmin->doBuild(,1)
Line 100 of DatabaseAdmin.php
* DatabaseAdmin->build()
Line 130 of DevelopmentAdmin.php
* DevelopmentAdmin->build(HTTPRequest)
Line 107 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/dev/build)
Line 115 of main.php

Avatar
rbquirke

Community Member, 70 Posts

29 April 2009 at 12:29am

Can you post the code you have in HomePage.php?

Avatar
slavelabourer

Community Member, 25 Posts

29 April 2009 at 12:42am

hey thanks for the reply,

I figured out it was just camelcasing on the filename, i come from a .NET background where casing isn't important, trying to mend my evil ways. mod can mark as solved now.

thanks again