chore: remove `@session_start()`

This commit is contained in:
vnmedeiros 2023-04-10 13:59:04 -03:00
parent 1509f3bed2
commit 72c8b03ff7
4 changed files with 25 additions and 120 deletions

View File

@ -19,17 +19,10 @@ class REST_Exporters_Controller extends REST_Controller {
*/
public function __construct() {
$this->rest_base = 'exporters';
if (session_status() == PHP_SESSION_NONE) {
@session_start(); // @ avoids Warnings when running phpunit tests
}
parent::__construct();
add_action('init', array(&$this, 'init_objects'), 11);
}
public function __destruct() {
session_write_close();
}
/**
* Initialize objects after post_type register
*/

View File

@ -11,8 +11,6 @@ use Tainacan\Entities;
*
* */
class REST_Importers_Controller extends REST_Controller {
private $collections_repository;
private $collection;
/**
* REST_Importers_Controller constructor.
@ -20,15 +18,9 @@ class REST_Importers_Controller extends REST_Controller {
*/
public function __construct(){
$this->rest_base = 'importers';
if (session_status() == PHP_SESSION_NONE) {
@session_start(); // @ avoids Warnings when running phpunit tests
}
parent::__construct();
}
public function __destruct() {
session_write_close();
}
/**
* Register the collections route and their endpoints
*/

View File

@ -1,89 +0,0 @@
<?php
class ScriptTainacanOld {
var $step = 0;
var $url = '';
/**
* start the execution
*/
function __construct($argv) {
$this->parse_args($argv);
$this->run();
}
/**
* parse args from and set the attributs
* 1 - Old Tainacan url (required)
*/
function parse_args($argv) {
if (!is_array($argv))
return;
if (isset($argv[1])) {
if (filter_var($argv[1], FILTER_VALIDATE_URL)) {
$this->url = $argv[1];
}
}
if (isset($argv[2])) {
if (is_numeric($argv[2])) {
$this->step = $argv[2];
} else {
$this->run = '';
}
}
}
/**
* echo message in prompt line
*/
function log($msg) {
echo $msg . PHP_EOL;
}
function run() {
$start = $partial = microtime(true);
// Avoid warnings
$_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
$_SERVER['REQUEST_METHOD'] = "GET";
define( 'WP_USE_THEMES', false );
define( 'SHORTINIT', false );
// require( dirname(__FILE__) . '/../../../../wp-blog-header.php' );
$old_tainacan = new \Tainacan\Importer\Old_Tainacan();
$id = $old_tainacan->get_id();
$_SESSION['tainacan_importer'][$id]->set_url($this->url);
while (!$_SESSION['tainacan_importer'][$id]->is_finished()){
$_SESSION['tainacan_importer'][$id]->run();
}
$scripttime = microtime(true) - $start;
$this->log("==========================================================");
$this->log("==========================================================");
$this->log("=== Fim do script. Tempo de execução {$scripttime}s");
$this->log("==========================================================");
$this->log("==========================================================");
}
}
$x = new ScriptTainacanOld($argv);

View File

@ -30,6 +30,15 @@ class ImporterTests extends TAINACAN_UnitTestCase {
this->assertEquals( $collection->get_id(), $_SESSION['tainacan_importer'][$id]->collection->get_id() );
}*/
public function __construct(){
parent::__construct();
@session_start();
}
public function __destruct() {
session_write_close();
}
public function test_automapping_old_tainacan()
{
//$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();