Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » DataObject/ missing Page Table problem?

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

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

Page: 1
Go to End
Author Topic: 1571 Views
  • Tama
    Avatar
    Community Member
    130 Posts

    DataObject/ missing Page Table problem? Link to this post

    Hi there

    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:

       function ShareURL(){
          urlencode('http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
       }

    instead of what I meant to put (that'll teach me to check my e-mail halfway through writing code):

       function ShareURL(){
          $output = urlencode('http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
          return $output;
       }

    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:

    ...
    Permission
    Widget
    WidgetArea
    Page
    Table Page: created
    Field Page.ID: created as int(11) not null auto_increment

    [User Error] Uncaught ReflectionException: Class does not exist
    GET /db/build?flush=1

    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

    Tama

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: DataObject/ missing Page Table problem? Link to this post

    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.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: DataObject/ missing Page Table problem? Link to this post

    Almost certainly an error in your Page.php file. Did you have a matching Page_Controller?

    Post the entire Page.php.

    Regards,
    Hamish

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: DataObject/ missing Page Table problem? Link to this post

    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.

    Cheers
    Tama

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: DataObject/ missing Page Table problem? Link to this post

    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?

    1571 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.