Установка максимального времени выполнения работает в некоторых функциях, а не в других, codeigniterPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Установка максимального времени выполнения работает в некоторых функциях, а не в других, codeigniter

Сообщение Anonymous »

Прошло много времени с тех пор, как я был здесь, но я в тупике. Неясно, является ли это кодировщиком или нет, но у меня есть функция, которая извлекает много данных и занимает больше 60 секунд. В разработке это позволяет мне пройти более 60 секунд, но в Prod это жесткая остановка на 60 секундах.
Я пробовал изменить время выполнения в php.ini... ничего. ini_set('max_execution_time', '300'); некоторые функции работают, но не моя функция... Я здесь потерялся, и моя работа валится на меня. В чем дело?
Вот функция, с которой ini_set не работает. Даже здесь, если установить нулевое значение, тайм-аут на выходе будет составлять 60 секунд:
public function cron_clever_import()
{ ini_set('max_execution_time', 0);

$this->load->model('Clever_model', 'clevermodel');
$this->load->model('Licenses_model', 'licenses');
$this->load->model('Users_model', 'users');
$this->load->model('Groups_model', 'groups');
$this->load->model('Userslicenses_model', 'userLicenses');
$this->load->library('Clever');

$adny_group_schools = array();
$adny_group_distric = array();
$special_da_emails = array();
$getChildHierarchy = $this->groups->getChildHierarchy(7699);
foreach($getChildHierarchy as $child_id) {
$adny_group = $this->groups->get($child_id);
if($adny_group->group_type == 'S') {
array_push($adny_group_schools, $child_id);
}
if($adny_group->group_type == 'D'){
array_push($adny_group_distric, $child_id);
}
}
$imploded_adny_groups = implode(",",$adny_group_distric);
$current_da_adny_users = $this->users->getActiveDaAdny($imploded_adny_groups);
foreach($current_da_adny_users as $current_da_adny_user)
{
array_push($special_da_emails, $current_da_adny_user->email);
}

foreach($adny_group_schools as $groupID) {
//arrays for checking our system against clever.
$current_active_emails = array();
$current_clever_emails = array();
$current_in_system = $this->users->getByGroupID($groupID);
//fill array with current active users in otis system
foreach($current_in_system as $current) {
if($current->is_active == 1 && !in_array($current->email, $special_da_emails)) {
array_push($current_active_emails, $current->email);
}
}

//get the entry id and oauth toke to gain access to clever, then grab the data and license info

$is_in_mapping = $this->clevermodel->getCurrentMapByGroupId($groupID, 7699);
if (!empty($is_in_mapping)) {

$clever_teachers = $this->clever->clever_get_school_users($is_in_mapping->clever_school_key, $is_in_mapping->district_oauthtoken, 'teacher');
$clever_staff = $this->clever->clever_get_school_users($is_in_mapping->clever_school_key, $is_in_mapping->district_oauthtoken, 'staff');
$teachers_decoded = json_decode($clever_teachers);
$staff_decoded = json_decode($clever_staff);
}
else {
$group_settings = $this->clevermodel->getSchoolSettings($groupID);
$oauth_token = $this->clevermodel->grabOauthToken($group_settings->district_oauthtoken_id);
//calls for teacher and staff(or school admin)
$clever_teachers = $this->clever->clever_get_school_users($group_settings->entry_id, $oauth_token, 'teacher');
$clever_staff = $this->clever->clever_get_school_users($group_settings->entry_id, $oauth_token, 'staff');
$groupMappingBySchoolId = $this->clevermodel->getCurrentMapBySchoolId($group_settings->entry_id);
if($groupMappingBySchoolId->otis_group_id < 1) {
$teachers_decoded = array();
$staff_decoded = array();
}
else {
$teachers_decoded = json_decode($clever_teachers);
$staff_decoded = json_decode($clever_staff);
}
}

//fill data into coherent array I can work with
foreach ($teachers_decoded->data as $teacher_data) {

if (is_null($teacher_data->data->email) || in_array($teacher_data->data->email, $special_da_emails)) {
//do not add to import users list
} else {

$import_users[$teacher_data->data->id] = array(
'first_name' => $teacher_data->data->name->first,
'last_name' => $teacher_data->data->name->last,
'email' => $teacher_data->data->email,
'role_id' => '2'
);

//push array of clever emails so I can check aginst current in otis
array_push($current_clever_emails, $teacher_data->data->email);
}
}
foreach ($staff_decoded->data as $staff_data) {

if (is_null($staff_data->data->email) || in_array($staff_data->data->email, $special_da_emails)) {
//do not add to import users list
} else {
$import_users[$staff_data->data->id] = array(
'first_name' => $staff_data->data->name->first,
'last_name' => $staff_data->data->name->last,
'email' => $staff_data->data->email,
'role_id' => '3'
);

array_push($current_clever_emails, $staff_data->data->email);
}
}
//if user active in our system but not existing in clever, make them inactive in otis
foreach($current_active_emails as $current_otis) {
if(!in_array($current_otis, $current_clever_emails)) {
$this->users->makeUserInactiveClever($current_otis);
}

}

//do the actual import of users. If they exist and are not active make them active, if they do not exists add them to group and apply license
foreach ($import_users as $clever_users) {
$user_exists = $this->users->getByEmail($clever_users['email']);
if (!empty($user_exists)) {
if ($user_exists->is_active == 0 || $user_exists->is_deleted == 1 || $user_exists->is_locked == 1) {
$this->users->updateInactiveCleverUser($user_exists->id);
}
} else {
$cleverData = array(
'first_name' => $clever_users['first_name'],
'last_name' => $clever_users['last_name'],
'email' => $clever_users['email'],
'role_id' => $clever_users['role_id'],
'password' => 'hidden',
'confirm_password' => 'hidden',
'group_id' => $groupID
);
$saved = $this->save($cleverData);
$new_user = $this->users->getByEmail($clever_users['email']);
if (!empty($new_user)) {
$current_group_license = $this->licenses->getByGroupIDAndTypeForClever(7699, 'opd');

$current_available_licenses = ($current_group_license[0]->license_count - $current_group_license[0]->total_users);
if($current_available_licenses > 0)
{
$add_license = $this->users->addLicenceCleverImport($saved, $current_group_license[0]->id);
$this->userLicenses->add(array(
'license_id' => $current_group_license[0]->id,
'user_id' => $saved,
'start_date' => date('Y-m-d H:i:s'),
'end_date' => $current_group_license[0]->expiration_date,
'expiration_date' => $current_group_license[0]->expiration_date,
'is_active' => 1,
'create_date' => date('Y-m-d H:i:s')
));
}
}
}
}


Подробнее здесь: https://stackoverflow.com/questions/721 ... codeignite
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»