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

Strangest Bug I have ever seen


Go to End


2 Posts   1227 Views

Avatar
pbenoit

Community Member, 9 Posts

8 December 2012 at 5:27am

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;
	}

Avatar
stallain

Community Member, 68 Posts

19 December 2012 at 12:10am

Edited: 19/12/2012 12:11am

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