Commit 5799a487 authored by Nigel McNie's avatar Nigel McNie
Browse files

Better error reporting for the solr plugin. A fix for #1721.

It's still not great, but at least it's no longer "a bug in the system". Instead reindexing says when it failed and suggests to check the error log.
parent 7a5be75e
...@@ -41,6 +41,7 @@ $string['go'] = 'Go'; ...@@ -41,6 +41,7 @@ $string['go'] = 'Go';
$string['default'] = 'Default'; $string['default'] = 'Default';
$string['upload'] = 'Upload'; $string['upload'] = 'Upload';
$string['complete'] = 'Complete'; $string['complete'] = 'Complete';
$string['Failed'] = 'Failed';
$string['loading'] = 'Loading ...'; $string['loading'] = 'Loading ...';
$string['showtags'] = 'Show my tags'; $string['showtags'] = 'Show my tags';
$string['errorprocessingform'] = 'There was an error with submitting this form. Please check the marked fields and try again.'; $string['errorprocessingform'] = 'There was an error with submitting this form. Please check the marked fields and try again.';
......
...@@ -109,6 +109,7 @@ class PluginSearchSolr extends PluginSearchInternal { ...@@ -109,6 +109,7 @@ class PluginSearchSolr extends PluginSearchInternal {
$elements = array(); $elements = array();
$enc_complete = json_encode(get_string('complete')); $enc_complete = json_encode(get_string('complete'));
$enc_failed = json_encode(get_string('Failed'));
$script = <<<END $script = <<<END
<script type="text/javascript"> <script type="text/javascript">
...@@ -118,7 +119,7 @@ class PluginSearchSolr extends PluginSearchInternal { ...@@ -118,7 +119,7 @@ class PluginSearchSolr extends PluginSearchInternal {
insertSiblingNodesAfter(td, progress); insertSiblingNodesAfter(td, progress);
sendjsonrequest(config.wwwroot + 'search/solr/reindex.json.php', {'type': type}, 'POST', function (data) { sendjsonrequest(config.wwwroot + 'search/solr/reindex.json.php', {'type': type}, 'POST', function (data) {
replaceChildNodes(progress, {$enc_complete}); replaceChildNodes(progress, (data.error) ? {$enc_failed} : {$enc_complete});
}); });
} }
</script> </script>
...@@ -128,6 +129,10 @@ END; ...@@ -128,6 +129,10 @@ END;
'type' => 'text', 'type' => 'text',
'title' => get_string('solrurl', 'search.solr'), 'title' => get_string('solrurl', 'search.solr'),
'defaultvalue' => get_config_plugin('search', 'solr', 'solrurl'), 'defaultvalue' => get_config_plugin('search', 'solr', 'solrurl'),
'rules' => array(
// Rather simplistic for now. Should match a valid URL
'regex' => '#^https?://.*$#',
),
); );
$elements['indexcontrol'] = array( $elements['indexcontrol'] = array(
'type' => 'fieldset', 'type' => 'fieldset',
......
...@@ -32,25 +32,30 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php'); ...@@ -32,25 +32,30 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$type = param_variable('type', 'all'); $type = param_variable('type', 'all');
safe_require('search', 'solr'); safe_require('search', 'solr');
switch ($type) { try {
case 'user': switch ($type) {
PluginSearchSolr::rebuild_users(); case 'user':
PluginSearchSolr::commit(); PluginSearchSolr::rebuild_users();
PluginSearchSolr::optimize(); PluginSearchSolr::commit();
break; PluginSearchSolr::optimize();
case 'artefact': break;
PluginSearchSolr::rebuild_artefacts(); case 'artefact':
PluginSearchSolr::commit(); PluginSearchSolr::rebuild_artefacts();
PluginSearchSolr::optimize(); PluginSearchSolr::commit();
break; PluginSearchSolr::optimize();
case 'view': break;
PluginSearchSolr::rebuild_views(); case 'view':
PluginSearchSolr::commit(); PluginSearchSolr::rebuild_views();
PluginSearchSolr::optimize(); PluginSearchSolr::commit();
break; PluginSearchSolr::optimize();
default: break;
PluginSearchSolr::rebuild_all(); default:
break; PluginSearchSolr::rebuild_all();
break;
}
}
catch (RemoteServerException $e) {
json_reply('local', 'Unable to perform re-index. Please check the ErrorLog for more information');
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment