Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » [User Error] Bad class to singleton() - HomePage

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

Page: 1
Go to End
Author Topic: 1429 Views
  • slavelabourer
    Avatar
    Community Member
    25 Posts

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

    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

  • rbquirke
    Avatar
    Community Member
    70 Posts

    Re: [User Error] Bad class to singleton() - HomePage Link to this post

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

  • slavelabourer
    Avatar
    Community Member
    25 Posts

    Re: [User Error] Bad class to singleton() - HomePage Link to this post

    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

    1429 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.