/** * use the config API to get the CloudSearch domain/index status * * @return array */ public static function get_remote_status() { $domain = Lift_Search::get_domain_manager()->get_domain(Lift_Search::get_search_domain_name()); if (!$domain) { return array('errors' => true, 'reason' => 'Domain has been deleted or the CloudSearch API request failed.', 'severity' => 2, 'status' => array('fatal' => true, 'text' => 'Domain has been deleted or the CloudSearch API request failed')); } $errors = false; $severity = 0; $reason = ''; $text = 'active'; $pending = !$domain->Created && !$domain->Deleted; $deleting = $domain->Deleted; $processing = $domain->Processing; $num_searchable_docs = $domain->NumSearchableDocs; $needs_indexing = $domain->RequiresIndexDocuments; $search_instance_count = $domain->SearchInstanceCount; $search_instance_type = $domain->SearchInstanceType; $search_partition_count = $domain->SearchPartitionCount; if ($deleting) { $severity = 2; $reason = 'CloudSearch domain being deleted'; $text = 'being deleted'; } else { if ($needs_indexing || $processing) { if (0 == $search_instance_count) { $severity = 1; $reason = 'CloudSearch domain loading'; $text = 'loading'; } else { if ($needs_indexing) { $severity = 1; $reason = 'CloudSearch domain needs indexing'; $text = 'needs indexing'; } else { $severity = 1; $reason = 'CloudSearch domain processing'; $text = 'processing'; } } } else { if ($pending) { $severity = 1; $reason = 'CloudSearch domain pending'; $text = 'pending'; } } } if (0 != $severity) { $errors = true; } $status = compact('text', 'pending', 'deleting', 'processing', 'num_searchable_docs', 'needs_indexing', 'search_instance_count', 'search_instance_type', 'search_partition_count'); $status['api_error'] = false; $status['text'] = $text; $results = array('errors' => $errors, 'severity' => $severity, 'reason' => $reason, 'status' => $status); return $results; }
function _lift_deactivate() { if (class_exists('Left_Search')) { $domain_manager = Lift_Search::get_domain_manager(); if ($domain_name = Lift_Search::get_search_domain_name()) { TAE_Async_Event::Unwatch('lift_domain_created_' . $domain_name); TAE_Async_Event::Unwatch('lift_needs_indexing_' . $domain_name); } //clean up options delete_option(Lift_Search::INITIAL_SETUP_COMPLETE_OPTION); delete_option(Lift_Search::SETTINGS_OPTION); delete_option('lift_db_version'); delete_option(Lift_Document_Update_Queue::QUEUE_IDS_OPTION); if (class_exists('Voce_Error_Logging')) { Voce_Error_Logging::delete_logs(array('lift-search')); } Lift_Batch_Handler::_deactivation_cleanup(); Lift_Document_Update_Queue::_deactivation_cleanup(); } }
/** * is the domain ready for a batch. has to exist and be in a good state * * @param string $domain_name * @return boolean */ public static function ready_for_batch($domain_name) { $domain_manager = Lift_Search::get_domain_manager(); return $domain_manager->can_accept_uploads($domain_name); }
public function action__wp_ajax_lift_domain() { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['model'])) { $model = json_decode(stripslashes($_POST['model'])); $response = array('status' => 'SUCCESS', 'data' => array(), 'errors' => array()); $error = new WP_Error(); if (isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'lift_domain')) { $dm = Lift_Search::get_domain_manager(); $result = $dm->initialize_new_domain($model->DomainName, $model->Region); if (is_wp_error($result)) { $error = $result; } else { $response['data'] = $dm->get_domain($model->DomainName); } } else { $error->add('invalid_nonce', 'The request was missing required authentication data.'); } if (count($error->get_error_codes())) { foreach ($error->get_error_codes() as $code) { $response['errors'][] = array('code' => $code, 'message' => $error->get_error_message($code)); } status_header(400); header('Content-Type: application/json'); $response['status'] = 'FAILURE'; } die(json_encode($response)); } }