public function init() { if (defined('DOING_CRON') && DOING_CRON || defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) { $keys = get_option('tae_event_keys', array()); foreach ($keys as $key) { $event = TAE_Async_Event::Restore($key); add_action('tae_event_' . $key, array($event, 'execute')); } } }
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(); } }
public function apply_schema($domain_name, $schema = null, &$changed_fields = array(), $region = false) { if (is_null($schema)) { $schema = apply_filters('lift_domain_schema', Cloud_Schemas::GetSchema()); } if (!is_array($schema)) { return false; } $result = $this->config_api->DescribeIndexFields($domain_name, $region); if (false === $result) { return new WP_Error('bad-response', 'Received an invalid repsonse when trying to describe the current schema'); } $current_schema = $result->IndexFields; if (count($current_schema)) { //convert to hashtable by name for hash lookup $current_schema = array_combine(array_map(function ($field) { return $field->Options->IndexFieldName; }, $current_schema), $current_schema); } foreach ($schema as $index) { $index = array_merge(array('options' => array()), $index); if (!isset($current_schema[$index['field_name']]) || $current_schema[$index['field_name']]->Options->IndexFieldType != $index['field_type']) { $response = $this->config_api->DefineIndexField($domain_name, $index['field_name'], $index['field_type'], $index['options']); if (false === $response) { Lift_Search::event_log('There was an error while applying the schema to the domain.', $this->config_api->get_last_error(), array('schema', 'error')); continue; } else { $changed_fields[] = $index['field_name']; } } } if (count($changed_fields)) { TAE_Async_Event::WatchWhen(array($this, 'needs_indexing'), array($domain_name, $region), 60, 'lift_needs_indexing_' . $domain_name)->then(array($this, 'index_documents'), array($domain_name, $region), true)->then(array('Lift_Batch_Handler', 'queue_all'))->commit(); } return true; }
public static function set_search_domain_name($domain_name) { $old_domain_name = self::get_search_domain_name(); if ($old_domain_name && $domain_name != $old_domain_name) { $domain_manager = self::get_domain_manager(); TAE_Async_Event::Unwatch('lift_domain_created_' . $old_domain_name); TAE_Async_Event::Unwatch('lift_needs_indexing_' . $old_domain_name); } self::__set_setting('search-domain', $domain_name); }