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