21310 Posts in 5739 Topics by 2604 members
|Go to End|
11 October 2009 at 9:37pm
I'm new to Silverstripe and have run into a problem that's been messing with my head for most of the day. I was adding a couple of functions to /mysite/code/Page.php to do simple outputs and originally I messed up the syntax like so:
instead of what I meant to put (that'll teach me to check my e-mail halfway through writing code):
$output = urlencode('http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
Now things are really weird. Silverstripe seems to have created a page type or class or dataobject or something called "Page" so when I run Silverstripe in debug I get the following message:
[User Error] Couldn't run query: SELECT `SiteTree`.*, `Page`.*, `GhostPage`.*, `BlogEntry`.*, `BlogTree`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `BlogHolder`.*, `SiteTree`.ID, if(`SiteTree`.ClassName,`SiteTree`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree` LEFT JOIN `Page` ON `Page`.ID = `SiteTree`.ID LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree`.ID LEFT JOIN `BlogEntry` ON `BlogEntry`.ID = `SiteTree`.ID LEFT JOIN `BlogTree` ON `BlogTree`.ID = `SiteTree`.ID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree`.ID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree`.ID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree`.ID LEFT JOIN `BlogHolder` ON `BlogHolder`.ID = `SiteTree`.ID WHERE (HomepageForDomain REGEXP '(, ^) *mydomain\.com *(,|$)') ORDER BY Sort LIMIT 1 | Table 'ssdb.Page' doesn't exist
And if I try to do /db/build/flush=1 it spits out this:
Table Page: created
Field Page.ID: created as int(11) not null auto_increment
[User Error] Uncaught ReflectionException: Class does not exist
Line 87 in /var/www/html/sapphire/core/Object.php
If I go in and check the database the "Page" database doesn't exist - but if I manually add "Page", "Page_Live", "Page_versions" (with only a ID row on each) to the database the site will work but I can't edit anything in the admin panel. Looking at an original Silverstripe database it appears that the Page tables don't exist in the default setup, or am I missing something?
I've spent the past few hours trawling through the code and database trying to work out what's triggered the need for the Page tables but it's totally got me confused. Any ideas?
Thanks in advance
12 October 2009 at 3:08pm
OK - this is really weird. I've recreated what I thought triggered this problem on a fresh website and the faulty syntax didn't seem to do anything to it...
...I'm confused - any ideas to what's producing the faulty SQL statement would be appreciated.
12 October 2009 at 3:42pm
Almost certainly an error in your Page.php file. Did you have a matching Page_Controller?
Post the entire Page.php.
12 October 2009 at 3:45pm
Hi Hamish - thank you for your reply.
If it is an error with my Page.php does this mean that replacing Page.php with the file from the default install will fix it up?
I'll give it a crack later today, will let you know how it goes.
12 October 2009 at 5:46pm
Well I'm officially King Durr of Mongland. I'd completely forgotten that I'd added this line to Page.php under the mistaken theory that it would disable comments across the whole site:
public static $db = array(
'ProvideComments' => false
I can't believe I wasted so much time looking for something that was staring me in the face!
So, how do I disable comments across the entire site?
|Go to Top|