Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
mateuswetah 2018-08-02 23:05:31 -03:00
commit fbd8d8b3a1
3 changed files with 21 additions and 3 deletions

View File

@ -217,8 +217,12 @@ class REST_Items_Controller extends REST_Controller {
$collection_id = $request['collection_id'];
}
$query_start = microtime(true);
$items = $this->items_repository->fetch($args, $collection_id, 'WP_Query');
$query_end = microtime(true);
$response = [];
$return_template = false;
@ -274,6 +278,8 @@ class REST_Items_Controller extends REST_Controller {
$rest_response->header('X-WP-Total', (int) $total_items);
$rest_response->header('X-WP-TotalPages', (int) $max_pages);
$rest_response->header('X-Tainacan-Query-Time', $query_end - $query_start);
$rest_response->header('X-Tainacan-Elapsed-Time', microtime(true) - $query_start);
return $rest_response;
}

View File

@ -113,6 +113,8 @@ abstract class Importer {
private $error_log = [];
private $author = 0;
/**
* Wether to abort importer execution.
* @var bool
@ -141,7 +143,9 @@ abstract class Importer {
@session_start();
}
$this->id = uniqid();
$this->id = uniqid();
$this->author = get_current_user_id();
$_SESSION['tainacan_importer'][$this->get_id()] = $this;
if (!empty($attributess)) {
@ -793,7 +797,7 @@ abstract class Importer {
}
if( !empty( $itemMetadataArray ) && $collection instanceof Entities\Collection ){
$item->set_collection( $collection );
$item->set_collection( $collection );
if( $item->validate() ){
$insertedItem = $Tainacan_Items->insert( $item );
@ -866,6 +870,8 @@ abstract class Importer {
$method_name = $steps[$current_step]['callback'];
if (method_exists($this, $method_name)) {
$this->add_log('User in process: ' . $this->author);
wp_set_current_user($this->author);
$result = $this->$method_name();
} else {
$this->add_error_log( 'Callback not found for step ' . $steps[$current_step]['name']);

View File

@ -65,6 +65,12 @@ class Old_Tainacan extends Importer{
*/
public function create_taxonomies() {
if(!$this->get_url()){
$this->add_error_log('Site url not found');
$this->abort();
return false;
}
$this->add_log('Creating taxonomies');
foreach ($this->get_taxonomies() as $taxonomy) {