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.

All other Modules /

Discuss all other Modules here.

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

MSSQL Full Text Search on Page Classname


Go to End


796 Views

Avatar
donsimpson66

Community Member, 1 Post

5 April 2013 at 10:00am

I am new to SS and have SS 3.0.5 running on IIS 7 and MSSQL. I enabled the full text search but it was not searching any items in the SiteTree with the Classname of Page. Searches on other classes works fine just not on Page. The only reference I could find to this was this post http://www.silverstripe.org/general-questions/show/18319 . I was able to use this to find where the query is made in the mssql module and on line 1366 of MSSQLdatabase.php.

I changed this line from

$queries[$tableName]->addWhere("\"$baseClass\".\"ClassName\" IN ('".implode($allClassesToSearch, "', '")."')");

to this

$queries[$tableName]->addWhere("\"$baseClass\".\"ClassName\" IN ('Page','".implode($allClassesToSearch, "', '")."')");

and now the search works for Page.

I don't think is the proper correction for this but I don't know if this an MSSQL only problem. I traced the problem back to the ClassInfo.php file in framework/core.

/**
* Returns an array of the current class and all its ancestors and children
* which have a DB table.
*
* @param string|object $class
* @todo Move this into data object
* @return array
*/
public static function dataClassesFor($class) {
$result = array();

if (is_object($class)) {
$class = get_class($class);
}

$classes = array_merge(
self::ancestry($class),
self::subclassesFor($class));

foreach ($classes as $class) {
if (self::hasTable($class)) $result[$class] = $class;
}

return $result;
}

Page is the only classname in SiteTree that does not have a table and thus it not being passed into the query.