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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

What is if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary();


Go to End


5 Posts   1222 Views

Avatar
Ryan M.

Community Member, 309 Posts

1 May 2010 at 8:03am

What is this?

if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary();

It's in Controller.php, on line 78. I had to comment this out to get my site working again after it quit working for some strange reason and kept throwing an error related to that function.

Avatar
Ryan M.

Community Member, 309 Posts

1 May 2010 at 9:15am

For reference, the error it throws is:

Fatal error: Call to undefined method BasicAuth::protect_site_if_necessary() in /var/www/vhosts/domain.com/subdomains/subsite/httpdocs/sapphire/core/control/Controller.php on line 78

Avatar
Willr

Forum Moderator, 5523 Posts

1 May 2010 at 9:37pm

Hmm strange you're using 2.4? I can see the protect_site_if_necessary() function in the BasicAuth.php file. You want to check your BasicAuth.php file to check that function is there. It may not have been updated correctly.

Avatar
Ryan M.

Community Member, 309 Posts

2 May 2010 at 4:13am

I'm using 2.3.3

Avatar
Willr

Forum Moderator, 5523 Posts

3 May 2010 at 9:19pm

Well even my 2.3 site has this, perhaps if you updated the core before (say it was an earlier version) maybe the BasicAuth file didn't get updated.

The function which should be in BasicAuth.php looks like...

	/**
	 * Call {@link BasicAuth::requireLogin()} if {@link BasicAuth::protect_entire_site()} has been called.
	 * This is a helper function used by Controller.
	 */
	static function protect_site_if_necessary() {
		if(self::$entire_site_protected) {
			self::requireLogin("SilverStripe test website. Use your CMS login.", "ADMIN");
		}
	}

You could try (if your missing it) just putting that in the BasicAuth.php file. Also note the 2.3 branch is up to 2.3.7 so your 4 versions behind the latest security updates so if you are worried about it, your site could be compromised.