If you try to enable the elasticsearch search option in Configure site -> Site options -> Search settings when the ElasticSearch Server is not running it hangs on saving site options.
There needs to be a report back to the screen that an error occurred like 'ElasticSearch Server is not running, please start service and try again'
Actually for this to work we'd need to check if it is running before letting them choose it - because the site option is saved before the failure so coming back to the page it shows the search is set to 'elasticsearch' which is incorrect.
The error log has errors like this:
[WAR] 15 (lib/errors.php:448) An exception was thrown of class Elastica\\Exception\\ClientException. , referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/errors.php:448) THIS IS BAD and should be changed to something extending MaharaException,, referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/errors.php:448) unless the exception is from a third party library., referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/errors.php:448) Original trace follows, referer: http://mahara-testing/admin/site/options.php
[WAR] 15 (lib/elastica/lib/Elastica/Client.php:431) No enabled connection, referer: http://mahara-testing/admin/site/options.php
Call stack (most recent first):, referer: http://mahara-testing/admin/site/options.php
* Elastica\\Client->getConnection() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Client.php:530, referer: http://mahara-testing/admin/site/options.php
* Elastica\\Client->request("mahara/", "DELETE", array(size 0), array(size 0)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Client.php:551, referer: http://mahara-testing/admin/site/options.php
* Elastica\\Client->request("mahara/", "DELETE", array(size 0), array(size 0)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Index.php:405, referer: http://mahara-testing/admin/site/options.php
* Elastica\\Index->request("", "DELETE") at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Index.php:133, referer: http://mahara-testing/admin/site/options.php
* Elastica\\Index->delete() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/elastica/lib/Elastica/Index.php:184, referer: http://mahara-testing/admin/site/options.php
* Elastica\\Index->create(array(size 3), true) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/search/elasticsearch/lib.php:1363, referer: http://mahara-testing/admin/site/options.php
* ElasticsearchIndexing::create_index() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/search/elasticsearch/lib.php:403, referer: http://mahara-testing/admin/site/options.php
* PluginSearchElasticsearch::reset_all_searchtypes() at /home/robertl/htdocs/mahara-testing/mahara/htdocs/search/elasticsearch/lib.php:371, referer: http://mahara-testing/admin/site/options.php
* PluginSearchElasticsearch::initialize_sitewide() at Unknown:0, referer: http://mahara-testing/admin/site/options.php
* call_user_func_array(array(size 2), array(size 0)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/mahara.php:1453, referer: http://mahara-testing/admin/site/options.php
* call_static_method("PluginSearchElasticsearch", "initialize_sitewide") at /home/robertl/htdocs/mahara-testing/mahara/htdocs/admin/site/options.php:763, referer: http://mahara-testing/admin/site/options.php
* siteoptions_submit(object(Pieform), array(size 65)) at Unknown:0, referer: http://mahara-testing/admin/site/options.php
* call_user_func_array("siteoptions_submit", array(size 2)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/pieforms/pieform.php:528, referer: http://mahara-testing/admin/site/options.php
* Pieform->__construct(array(size 7)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/pieforms/pieform.php:170, referer: http://mahara-testing/admin/site/options.php
* Pieform::process(array(size 7)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/lib/pieforms/pieform.php:71, referer: http://mahara-testing/admin/site/options.php
* pieform(array(size 7)) at /home/robertl/htdocs/mahara-testing/mahara/htdocs/admin/site/options.php:673, referer: http://mahara-testing/admin/site/options.php
What is needed is a function like ch_server_ available( )
is_elasticsear
Which checks to see if a connection can be made to the ElasticSearch Server - returning true/false
That way we could use it in places like admin/extension s/pluginconfig. php?plugintype= search& pluginname= elasticsearch to complement the "The Elasticsearch plugin is currently active." message with something like "The Elasticsearch Server is/is not currently reachable".
And we could use it on search/ elasticsearch/ index.php to suppress the "An exception was thrown of class Elastica\ Exception\ ClientException . No enabled connection" warnings if the ElasticSearch Server is not able to be accessed.
We could instead have a "We were unable to process your search - please try again. If the problem persists please contact your administrator" message for the page.