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';
$string['default'] = 'Default';
$string['upload'] = 'Upload';
$string['complete'] = 'Complete';
$string['Failed'] = 'Failed';
$string['loading'] = 'Loading ...';
$string['showtags'] = 'Show my tags';
$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 {
$elements = array();
$enc_complete = json_encode(get_string('complete'));
$enc_failed = json_encode(get_string('Failed'));
$script = <<<END
<script type="text/javascript">
......@@ -118,7 +119,7 @@ class PluginSearchSolr extends PluginSearchInternal {
insertSiblingNodesAfter(td, progress);
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>
......@@ -128,6 +129,10 @@ END;
'type' => 'text',
'title' => get_string('solrurl', 'search.solr'),
'defaultvalue' => get_config_plugin('search', 'solr', 'solrurl'),
'rules' => array(
// Rather simplistic for now. Should match a valid URL
'regex' => '#^https?://.*$#',
),
);
$elements['indexcontrol'] = array(
'type' => 'fieldset',
......
......@@ -32,25 +32,30 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$type = param_variable('type', 'all');
safe_require('search', 'solr');
switch ($type) {
case 'user':
PluginSearchSolr::rebuild_users();
PluginSearchSolr::commit();
PluginSearchSolr::optimize();
break;
case 'artefact':
PluginSearchSolr::rebuild_artefacts();
PluginSearchSolr::commit();
PluginSearchSolr::optimize();
break;
case 'view':
PluginSearchSolr::rebuild_views();
PluginSearchSolr::commit();
PluginSearchSolr::optimize();
break;
default:
PluginSearchSolr::rebuild_all();
break;
try {
switch ($type) {
case 'user':
PluginSearchSolr::rebuild_users();
PluginSearchSolr::commit();
PluginSearchSolr::optimize();
break;
case 'artefact':
PluginSearchSolr::rebuild_artefacts();
PluginSearchSolr::commit();
PluginSearchSolr::optimize();
break;
case 'view':
PluginSearchSolr::rebuild_views();
PluginSearchSolr::commit();
PluginSearchSolr::optimize();
break;
default:
PluginSearchSolr::rebuild_all();
break;
}
}
catch (RemoteServerException $e) {
json_reply('local', 'Unable to perform re-index. Please check the ErrorLog for more information');
}
......
Markdown is supported
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