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

Cannot access Admin - dev/build and possibly others.


Go to End


9 Posts   5105 Views

Avatar
KaDMiO

Community Member, 5 Posts

29 July 2011 at 1:57pm

Hi all!

Even though it is the first time I use SilverStripe, I've found it very useful, keep up the good work!

The problem I am having is that I cannot access either the admin page nor any of the dev pages. I admit I have been tinkering with the code, but nothing related to the part that handles paths. flush=all won't work either.

The page I always land on says:
Server error
Sorry, there was a problem with handling your request.

I don't really know what to do, any help is appreciated. Whatever you need, just ask me.

Thanks!

Avatar
swaiba

Forum Moderator, 1899 Posts

29 July 2011 at 9:22pm

Hi KaDMiO,

Welcome to Silverstripe!

The server error can be turned into something more meaningful, please checkout http://www.silverstripe.org/general-questions/show/16055 for turning on dev mode.

Avatar
KaDMiO

Community Member, 5 Posts

29 July 2011 at 11:27pm

Thanks a lot about that!

It seemed that a function I had added to page.php was triggering the problem. By removing it I was able to solve this issue, but now I have another one. I need a way of knowing if a certain page has or has not a Sidebar with widgets in it. The code I had added was the following:

I have found it in another post of the forum.

function IHaveWidgets () {
return DataObject::get("Widget", "ParentID = $this->SidebarID");
}

Do you know a way I can do the same without breaking the installation?

Again, thanks for the superquick answer.

Avatar
swaiba

Forum Moderator, 1899 Posts

29 July 2011 at 11:32pm

Looks fine to me, although I've never used it, what was the errror?

Avatar
KaDMiO

Community Member, 5 Posts

29 July 2011 at 11:43pm

This is the specific error.

[User Error] Couldn't run query: SELECT "Widget"."ClassName", "Widget"."Created", "Widget"."LastEdited", "Widget"."Sort", "Widget"."Enabled", "Widget"."ParentID", "PageContentWidget"."WidgetTitle", "PageContentWidget"."PageID", "Widget"."ID", CASE WHEN "Widget"."ClassName" IS NOT NULL THEN "Widget"."ClassName" ELSE 'Widget' END AS "RecordClassName" FROM "Widget" LEFT JOIN "PageContentWidget" ON "PageContentWidget"."ID" = "Widget"."ID" WHERE (ParentID = ) ORDER BY "Sort" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY "Sort"' at line 1

This is the trace:

Trace

Couldn't run query: SELECT "Widget"."ClassName", "Widget"."Created", "Widget"."LastEdited", "Widget"."Sort", "Widget"."Enabled", "Widget"."ParentID", "PageContentWidget"."WidgetTitle", "PageContentWidget"."PageID", "Widget"."ID", CASE WHEN "Widget"."ClassName" IS NOT NULL THEN "Widget"."ClassName" ELSE 'Widget' END AS "RecordClassName" FROM "Widget" LEFT JOIN "PageContentWidget" ON "PageContentWidget"."ID" = "Widget"."ID" WHERE (ParentID = ) ORDER BY "Sort" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY "Sort"' at line 1
Line 525 of MySQLDatabase.php

MySQLDatabase->databaseError(Couldn't run query: SELECT "Widget"."ClassName", "Widget"."Created", "Widget"."LastEdited", "Widget"."Sort", "Widget"."Enabled", "Widget"."ParentID", "PageContentWidget"."WidgetTitle", "PageContentWidget"."PageID", "Widget"."ID", CASE WHEN "Widget"."ClassName" IS NOT NULL THEN "Widget"."ClassName" ELSE 'Widget' END AS "RecordClassName" FROM "Widget" LEFT JOIN "PageContentWidget" ON "PageContentWidget"."ID" = "Widget"."ID" WHERE (ParentID = ) ORDER BY "Sort" | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY "Sort"' at line 1,256)
Line 123 of MySQLDatabase.php

MySQLDatabase->query(SELECT "Widget"."ClassName", "Widget"."Created", "Widget"."LastEdited", "Widget"."Sort", "Widget"."Enabled", "Widget"."ParentID", "PageContentWidget"."WidgetTitle", "PageContentWidget"."PageID", "Widget"."ID", CASE WHEN "Widget"."ClassName" IS NOT NULL THEN "Widget"."ClassName" ELSE 'Widget' END AS "RecordClassName" FROM "Widget" LEFT JOIN "PageContentWidget" ON "PageContentWidget"."ID" = "Widget"."ID" WHERE (ParentID = ) ORDER BY "Sort",256)
Line 129 of DB.php

DB::query(SELECT "Widget"."ClassName", "Widget"."Created", "Widget"."LastEdited", "Widget"."Sort", "Widget"."Enabled", "Widget"."ParentID", "PageContentWidget"."WidgetTitle", "PageContentWidget"."PageID", "Widget"."ID", CASE WHEN "Widget"."ClassName" IS NOT NULL THEN "Widget"."ClassName" ELSE 'Widget' END AS "RecordClassName" FROM "Widget" LEFT JOIN "PageContentWidget" ON "PageContentWidget"."ID" = "Widget"."ID" WHERE (ParentID = ) ORDER BY "Sort",256)
Line 400 of SQLQuery.php

SQLQuery->execute()
Line 2736 of DataObject.php

DataObject->instance_get(ParentID = ,,,,DataObjectSet)
Line 2714 of DataObject.php

DataObject::get(Widget,ParentID = )
Line 12 of Page.php

Page->IHaveWidgets()

call_user_func_array(Array,Array)
Line 693 of Object.php

Avatar
KaDMiO

Community Member, 5 Posts

29 July 2011 at 11:44pm

The error was triggered by trying to access the admin page.

Avatar
swaiba

Forum Moderator, 1899 Posts

30 July 2011 at 12:00am

Sounds like you don't have...

class Page extends SiteTree {
...
	public static $has_one = array(
		"SideBar" => "WidgetArea",
	);
...

but you could wrap it with this to ensure it doesn't error in that case...

function IHaveWidgets () { 
	if (is_numeric($this->SidebarID)) {
		return DataObject::get("Widget", "ParentID = $this->SidebarID"); 
	}
return null;
}

Avatar
KaDMiO

Community Member, 5 Posts

30 July 2011 at 8:53am

Thanks a lot! That did it!

Page.php does have the WidgetArea enabled, I think the problem was that one of the Admin sites does inherit from Page.php, but has the $has_one variable defined differently, without the WidgetArea.

Go to Top