Jump to:

23372 Posts in 18175 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Strangest Bug I have ever seen

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: 527 Views
  • pbenoit
    Avatar
    Community Member
    9 Posts

    Strangest Bug I have ever seen Link to this post

    Hi all,

    First off I think this is one for the super SS users out there.

    I am developing a site in 3.0.2 mainly in Chrome. The site code has been static for about 4 days while we content populate the site. Suddenly the homepage crashes, returning an error in the mysql query when getting a page class through DataObject. In fact all pages with db queries crashed.

    Basically the query string should contain queries to the 'pageType'_Live table in the DB but during this error it only looks for the 'pageType' table. So my query filter of 'pageType'_Live.Date fails as there is no field in the query that matches this.

    Now to add to the mystery, this happend only after the code was active for 4 days with 3 people using it. It only happend in Chrome, all other browsers were working fine. Every other machine in the dev team could access the home page fine. Refreshing didnt work, clearing cache didnt work, flushing=all didnt work. The only thing that solved it was restarting the browser and then everything was fine again.

    If there are any ideas I am open to any suggestions. Here is the code from the homepage that queries the DB.

    public function LatestNews($num=3) {
          $holder = ArticleYear::get()->First();
          $holder1 = RestrictedPage::get()->First();
          $ds = new ArrayList();
    if ($holder) {
          $ds->merge(DataObject::get($obj="ArticlePage", $filter = "ArticlePage_Live.Date < curdate()"));
    }
    if ($holder1) {
          $ds->merge(DataObject::get($obj="RestrictedPage", $filter = "RestrictedPage_Live.Date < curdate()"));
    }
          return ($holder || $holder1) ? $ds->sort('Date')->reverse()->limit($num) : false;
       }

  • stallain
    Avatar
    Community Member
    61 Posts

    Re: Strangest Bug I have ever seen Link to this post

    Hi, I think I already had the same kind of error - don't know if it was due to chrome. I remember I solved it writing my conditional query a little differently. Maybe you could try something like this :
    Instead of

    $holder = ArticleYear::get()->First();
    // supposes such a dataobject exists ?
    if ($holder) { ...


    Try

    if ($holder = ArticleYear::get()->First()) { ...
    // checks is the query returns a value

    527 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.