Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] CustomSiteConfig not found

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: 239 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    [SOLVED] CustomSiteConfig not found Link to this post

    Hi,

    I'm getting an error (Fatal error: Object::add_extension() - Can't find extension class for "CustomSiteConfig") on my live site but only once in a while. The site works fine most of the time and then now and again it gives me the error.

    I've been working with SilverStripe for many years and never quite had this problem.

    I'm using SS3.1, here is my code:

    _config.php

    <?php

    global $project;
    $project = 'mysite';

    global $databaseConfig;
    $databaseConfig = array(
       "type" => 'MySQLDatabase',
       "server" => 'localhost',
       "username" => 'root',
       "password" => 'root',
       "database" => 'SS_pbcv',
       "path" => '',
    );

    SSViewer::setOption('rewriteHashlinks', false);

    // Set the site locale
    i18n::set_locale('en_GB');

    MySQLDatabase::set_connection_charset('utf8');

    // Set the current theme. More themes can be downloaded from
    SSViewer::set_theme('boilerplate');

    // Site config & extentions
    DataObject::add_extension('SiteConfig', 'CustomSiteConfig');

    // Shorcodes
    ShortcodeParser::get()->register('Vimeo',array('Page','VimeoShortCodeHandler'));
    ShortcodeParser::get()->register('YouTube',array('Page','YouTubeShortCodeHandler'));

    /********************** Security **********************/

    // Set default login
    Security::setDefaultAdmin('admin','password');

    // Define the password validator
    $pwdValidator = new PasswordValidator();
    $pwdValidator->minLength(8);
    $pwdValidator->checkHistoricalPasswords(2);
    $pwdValidator->characterStrength(2,array('lowercase','digits'));
    Member::set_password_validator($pwdValidator);

    // Set the site locale
    i18n::set_locale('en_UK');

    // Enable nested URLs for this site (e.g. page/sub-page/)
    if (class_exists('SiteTree')) SiteTree::enable_nested_urls();

    FulltextSearchable::enable();

    // Set the resizing image quality
    GD::set_default_quality(95);

    // Force enviroment to Dev
    Director::set_environment_type("dev");

    // Force cache to flush on page load if in Dev mode (prevents needing ?flush=1 on the end of a URL)
    if (Director::isDev()) {
    SSViewer::flush_template_cache();
    }

    error_reporting(E_ALL);

    /********************** Emails **********************/

    //Set the admin email address
    Email::setAdminEmail('me@peterbroom.co.uk');

    //Set to CC all emails to
    Email::cc_all_emails_to('me@peterbroom.co.uk');

    /********************** Live environment **********************/

    // uncomment this line for live environment
    @include '_live-config.php';

    _live-config.php

    <?php

    global $project;
    $project = 'mysite';

    global $databaseConfig;
    $databaseConfig = array(
       "type" => 'MySQLDatabase',
       "server" => '****',
       "username" => '****',
       "password" => '****',
       "database" => '****',
       "path" => '',
    );

    // force enviroment to Live
    Director::set_environment_type("live");

    CustomSiteConfig.php

    <?php

    class CustomSiteConfig extends DataExtension{

    static $db = array(
    );

    static $has_many = array(
    );
    }

    Regards

    Harley

  • kinglozzer
    Avatar
    Community Member
    139 Posts

    Re: [SOLVED] CustomSiteConfig not found Link to this post

    Hi Harley,

    The extension you pasted is empty - if there's nothing in there you should just remove it and that'll solve this. If there is something in there that you've just hidden for this post, I'd ensure you've done a /dev/build?flush=1 firstly. Also, your extension should be applied with:

    SiteConfig::add_extension('CustomSiteConfig');

    You mentioned that it only happens occasionally, which is odd given that a PHP class shouldn't be able to disappear at random. According to your _config.php, you're flushing the template cache on every page load - I wonder if this is somehow interfering with the class manifest as well (it definitely shouldn't affect this, but I've seen stranger), so I'd try removing that too.

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: [SOLVED] CustomSiteConfig not found Link to this post

    Thanks for the suggestions,

    Yeah I think you're right about the cache flush, that could be the problem. I've only got the custom site config there for future development so I'll just remove it for the time being and see what happens.

    Thanks again!

    239 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.