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