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.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

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

Search Form: "Server error Sorry, there was a problem with handling your request."


Go to End


11 Posts   8758 Views

Avatar
joejac

Community Member, 7 Posts

5 March 2016 at 5:27pm

Edited: 06/03/2016 5:25am

Hello and nice day to all.

I am new with SilverStripe. I installed SilverStripe 3.3.1 in a cPanel shared hosting.
I had problems with the .htaccess file, my web server provider found an error in the server log:

[Fri Mar 04 15:00:15.559346 2016] [core:alert] [pid 9636] [client 67.23.232.183:1863] /home/myuser/public_html/.htaccess: Invalid command 'SetEnv', perhaps misspelled or defined by a module not included in the server configuration

so he commented the following lines and SilverStripe worked:

# SetEnv BlockUntrustedIPs true
        # SetEnv HTTP_MOD_REWRITE On

My main concern is creating nice Themes, so I was studying the Theme video Lessons from UncleCheese.

While practicing with the simple theme I followed this tutorial:
https://docs.silverstripe.org/en/3.3/tutorials/site_search/
I checked that everything was like in the tutorial, I got the search form, then to test the search function, I searched for a word and I got the following error:

Server error
Sorry, there was a problem with handling your request.

My site is in Spanish and with this error changed to English and lost the search form. I click in any menu item and it goes back to Spanish, the error is cleared and the search form is back again.
But no search results only the above error message.

Any help is very much appreciated
Thank you and regards
joejac

Avatar
joejac

Community Member, 7 Posts

6 March 2016 at 5:16am

Edited: 06/03/2016 5:29am

Hello again.

I noticed a slight difference among the file in the tutorial and the one I have in my installation:

In the tutorial, in the file:

cms/code/search/ContentControllerSearchExtension.php

class ContentControllerSearchExtension extends Extension {
    ...    

    function results($data, $form, $request) {
        $data = array(
            'Results' => $form->getResults(),
            'Query' => $form->getSearchQuery(),
            'Title' => _t('SearchForm.SearchResults', 'Search Results')
        );
        return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
    }
}

In my installation in same file, I have:

<?php
/**
 * Extension to provide a search interface when applied to ContentController
 *
 * @package cms
 * @subpackage search
 */
class ContentControllerSearchExtension extends Extension {
	private static $allowed_actions = array(
		'SearchForm',
		'results',
	);

	/**
	 * Site search form
	 */
	public function SearchForm() {
		$searchText =  _t('SearchForm.SEARCH', 'Search');

		if($this->owner->getRequest() && $this->owner->getRequest()->getVar('Search')) {
			$searchText = $this->owner->getRequest()->getVar('Search');
		}

		$fields = new FieldList(
			new TextField('Search', false, $searchText)
		);
		$actions = new FieldList(
			new FormAction('results', _t('SearchForm.GO', 'Go'))
		);
		$form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
		$form->classesToSearch(FulltextSearchable::get_searchable_classes());
		return $form;
	}

	/**
	 * Process and render search results.
	 *
	 * @param array $data The raw request data submitted by user
	 * @param SearchForm $form The form instance that was submitted
	 * @param SS_HTTPRequest $request Request generated for this action
	 */
	public function results($data, $form, $request) {
		$data = array(
			'Results' => $form->getResults(),
			'Query' => DBField::create_field('Text', $form->getSearchQuery()),
			'Title' => _t('SearchForm.SearchResults', 'Search Results')
		);
		return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
	}
}

The difference is that I have:

'Query' => DBField::create_field('Text', $form->getSearchQuery()),

And the tutorial has:
'Query' => $form->getSearchQuery(),

In: public_html/themes/simple/templates/Layout
I have the files:
Page.ss
Page_results.ss

in Page_results.ss I have:

<div id="Content" class="searchResults">
    <h1>$Title</h1>

    <% if $Query %>
        <p class="searchQuery">You searched for &quot;{$Query}&quot;</p>
    <% end_if %>

    <% if $Results %>
    <ul id="SearchResults">
        <% loop $Results %>
        <li>
            <h4>
                <a href="$Link">
                    <% if $MenuTitle %>
                    $MenuTitle
                    <% else %>
                    $Title
                    <% end_if %>
                </a>
            </h4>
            <% if $Content %>
                <p>$Content.LimitWordCountXML</p>
            <% end_if %>
            <a class="readMoreLink" href="$Link" title="Read more about &quot;{$Title}&quot;">Read more about &quot;{$Title}&quot;...</a>
        </li>
        <% end_loop %>
    </ul>
    <% else %>
    <p>Sorry, your search query did not return any results.</p>
    <% end_if %>

    <% if $Results.MoreThanOnePage %>
    <div id="PageNumbers">
        <div class="pagination">
            <% if $Results.NotFirstPage %>
            <a class="prev" href="$Results.PrevLink" title="View the previous page">&larr;</a>
            <% end_if %>
            <span>
                <% loop $Results.Pages %>
                    <% if $CurrentBool %>
                    $PageNum
                    <% else %>
                    <a href="$Link" title="View page number $PageNum" class="go-to-page">$PageNum</a>
                    <% end_if %>
                <% end_loop %>
            </span>
            <% if $Results.NotLastPage %>
            <a class="next" href="$Results.NextLink" title="View the next page">&rarr;</a>
            <% end_if %>
        </div>
        <p>Page $Results.CurrentPage of $Results.TotalPages</p>
    </div>
    <% end_if %>
</div>

There are differences with the Page_results.ss of the tutorial but I guess are due to format, I did not touch those files, they are the originals that came with the simple theme and after I did: http://www.mywebsite.com/dev/build

Sorry, I am not a programmer, I design, I do not know is this makes any difference or influence in the error or it is the comments of SetEnv in the .htaccess file or it is another thing.

I appreciate your help to continue creating the site, thanks.
Regards
joejac

Avatar
joejac

Community Member, 7 Posts

7 March 2016 at 7:56am

Edited: 07/03/2016 8:00am

Hello,

Looking in Google for the server log error:
".htaccess: Invalid command 'SetEnv', perhaps misspelled or defined by a module not included in the server configuration"

I found this page that seems to relate the problem to an upgrade in Apache, and I asked the hosting company to check if this can be the problem so can be corrected and SilverStripe .htaccess original configuration can be maintained:
https://forums.cpanel.net/threads/setenv-fails-with-apache-2-4.376752/

They answered:
"We have enabled SetENV on the server. We sincerely apologize for the inconvenience as this is intended to be enabled by default on our shared servers, but it appears this did not happen when we moved the server to Apache 2.4."

So with SetENV enabled in my hosting account, I also enabled the 2 lines with SetENV, and left the .htaccess exactly like it comes from the original installation files, like this:

### SILVERSTRIPE START ###

# DirectoryIndex index.html

# Deny access to templates (but allow from localhost)
<Files *.ss>
	Order deny,allow
	Deny from all
	Allow from 127.0.0.1
</Files>

# Deny access to IIS configuration
<Files web.config>
	Order deny,allow
	Deny from all
</Files>

# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
	Order allow,deny
	Deny from all
</Files>

# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_env.c>
	# Ensure that X-Forwarded-Host is only allowed to determine the request
	# hostname for servers ips defined by SS_TRUSTED_PROXY_IPS in your _ss_environment.php
	# Note that in a future release this setting will be always on.
	SetEnv BlockUntrustedIPs true
</IfModule>

<IfModule mod_rewrite.c>

	# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
	<IfModule mod_dir.c>
		DirectoryIndex disabled
	</IfModule>

	SetEnv HTTP_MOD_REWRITE On
	RewriteEngine On

	# Enable HTTP Basic authentication workaround for PHP running in CGI mode
	RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
	
	# Deny access to potentially sensitive files and folders
	RewriteRule ^vendor(/|$) - [F,L,NC]
	RewriteRule silverstripe-cache(/|$) - [F,L,NC]
	RewriteRule composer\.(json|lock) - [F,L,NC]
	
	# Process through SilverStripe if no file with the requested name exists.
	# Pass through the original path as a query parameter, and retain the existing parameters.
	RewriteCond %{REQUEST_URI} ^(.*)$
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule .* framework/main.php?url=%1 [QSA]
	
	# If framework isn't in a subdirectory, rewrite to installer
	RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule . %1/install.php? [R,L]

</IfModule>
### SILVERSTRIPE END ###
 

And I have the same error when I do search for a word. So the problem was not the SetENV, it is other problem.

"Server error Sorry, there was a problem with handling your request."

Can somebody help me please to find what is going on with SilverStripe 3.3.1 Search function?

Thank you
Regards
joejac

Avatar
joejac

Community Member, 7 Posts

7 March 2016 at 9:23am

Hello again,

I discovered this link and found a very usefull way to report the SS errors:
https://docs.silverstripe.org/en/3.3/getting_started/installation/common_problems/

I quote: "If you can log-in to the CMS as an administrator, append ?isDev=1 to any URL to temporarily set your browsing session into "dev mode".

So I appended to the search page and I got:


[User Error] Uncaught SS_DatabaseException: Couldn't run query: SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch 0) The used table type doesn't support FULLTEXT indexes
GET /about-us/SearchForm?Search=own&action_results=L
Line 55 in /home/mysite/public_html/framework/model/connect/DBConnector.php
Source
46 		if (!empty($sql)) {
47 			$formatter = new SQLFormatter();
48 			$formattedSQL = $formatter->formatPlain($sql);
49 			$msg = "Couldn't run query:\n\n{$formattedSQL}\n\n{$msg}";
50 		}
51 
52 		if($errorLevel === E_USER_ERROR) {
53 			// Treating errors as exceptions better allows for responding to errors
54 			// in code, such as credential checking during installation
55 			throw new SS_DatabaseException($msg, 0, null, $sql, $parameters);
56 		} else {
57 			user_error($msg, $errorLevel);
58 		}
59 	}
60 	
61 	/**
Trace
DBConnector->databaseError(The used table type doesn't support FULLTEXT indexes,256,SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0)) 
MySQLiConnector.php:124
MySQLiConnector->query(SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0),256) 
MySQLiConnector.php:212
MySQLiConnector->preparedQuery(SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0),Array,256) 
Database.php:134
SS_Database->{closure}(SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0)) 
Database.php:178
SS_Database->benchmarkQuery(SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0),Closure) 
Database.php:136
SS_Database->preparedQuery(SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0),Array,256) 
DB.php:311
DB::prepared_query(SELECT DISTINCT count(*) FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('own*' IN BOOLEAN MODE) AND ShowInSearch <> 0),Array) 
SQLExpression.php:121
SQLExpression->execute() 
SQLSelect.php:554
SQLSelect->unlimitedRowCount() 
MySQLDatabase.php:195
MySQLDatabase->searchEngine(Array,own*,0,10,"Relevance" DESC,,1) 
SearchForm.php:152
SearchForm->getResults() 
ContentControllerSearchExtension.php:44
ContentControllerSearchExtension->results(Array,SearchForm,SS_HTTPRequest) 
call_user_func_array(Array,Array) 
Object.php:711
Object->__call(results,Array) 
Form.php:462
Page_Controller->results(Array,SearchForm,SS_HTTPRequest) 
Form.php:462
Form->httpSubmission(SS_HTTPRequest) 
RequestHandler.php:288
RequestHandler->handleAction(SS_HTTPRequest,httpSubmission) 
RequestHandler.php:200
RequestHandler->handleRequest(SS_HTTPRequest,DataModel) 
RequestHandler.php:222
RequestHandler->handleRequest(SS_HTTPRequest,DataModel) 
Controller.php:158
Controller->handleRequest(SS_HTTPRequest,DataModel) 
ContentController.php:172
ContentController->handleRequest(SS_HTTPRequest,DataModel) 
ModelAsController.php:75
ModelAsController->handleRequest(SS_HTTPRequest,DataModel) 
Director.php:385
Director::handleRequest(SS_HTTPRequest,Session,DataModel) 
Director.php:149
Director::direct(/about-us/SearchForm,DataModel) 
main.php:184

Then Searching for: "The used table type doesn't support FULLTEXT indexes" I found this link:
http://stackoverflow.com/questions/20964269/1214-the-used-table-type-doesnt-support-fulltext-indexes

And it said:
Before MySQL 5.6 Full-Text Search is supported only with MyISAM Engine.
Therefore either
1.- change the engine for your table to MyISAM (at the end of the SQL instructions goes: ENGINE=MyISAM;)
2.- or upgrade to 5.6 and use InnoDB Full-Text Search.

I have MySQL 5.5.48 but in the SS requirements it said that it requires MySQL 5.0+
so I comply with the requirements, please confirm if this is a bug, because I am not qualified to touch internal SQL/PHP code of the CMS Module that it should work.
https://docs.silverstripe.org/en/3.3/getting_started/server_requirements/

Thank you and regards
joejac

Avatar
joejac

Community Member, 7 Posts

7 March 2016 at 2:20pm

I found this post, is dated 23 October 2012 the person had same problem as me, no body provided a solution from inside SilverStripe since that date to today, more than 3 years! Using Google Search is using a 3rd party and In my opinion I think a CMS should have a basic Search function, out of the box, at least for the text area fields.
http://www.silverstripe.org/community/forums/general-questions/show/21251

I hope some developer sees this post and to answer it.
Thank you
joejac

Avatar
joejac

Community Member, 7 Posts

9 March 2016 at 3:27am

Hi there

Please, is there someone that is so kind as to give me an orientation to solve this issue and so I can use SilverStripe and not to be forced to change CMS, I think SilverStripe is good for me if this matter can be resolved, because my hosting provider will not upgrade MySQL.

Thank you and regards.
joejac

Avatar
Friizu

Community Member, 17 Posts

10 March 2016 at 9:27pm

Edited: 10/03/2016 9:42pm

Avatar
joejac

Community Member, 7 Posts

12 March 2016 at 10:26am

Edited: 12/03/2016 10:32am

Hello Friizu!
Nice to hear from a forum member!

Thank you very much for the links I will study them, but I am not a developer so I do not feel comfortable changing this at database label, specially database table definitions, I saw some documentation to change to MyISAM, I do not want to mess with that.

So I had to put SilverStripe on hold because I decided to do something that I have been postponing since more than 5 years, 3 days ago I rented a self-managed Virtual Private Server for a year, so I hope I will have control on what resources I have.

The problem is that I am a Linux user on Desktop since 3 years ago when I escaped from M$, but know nothing about Linux Servers and I have to learn Linux Server Administration with no time to do it, so I am very tired, little sleep this week, because I also evaluated about 30 CMS's more.

I need to run my first hosting account in my new VPS and then I will see if SilverStripe works on it, this will take some time because the Virtualmin came with 5.5.44-MariaDB so same problem, SS needs 5.6+, I need to upgrade Virtualmin and CentOS via command line without making mistakes, while studying Linux Server Administration.

Thanks and best regards
joejac

Go to Top