Skip to content

Commit 92cc1b0

Browse files
committed
fix bugs: constants already defined
1 parent 6af8bf7 commit 92cc1b0

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/Core/Server.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* ------------------------------------------------------------------------------------
77
*
88
* @author lanlin
9-
* @change 2018/06/30
9+
* @change 2018/09/25
1010
*/
1111
class Server
1212
{
@@ -205,7 +205,15 @@ public static function onTask(\Swoole\Server $serv, $taskId, $workerId, $data)
205205
}
206206

207207
catch (\Throwable $e) { self::logs($e); }
208-
finally { \Swoole\Process::kill(getmypid()); }
208+
209+
// ignore...
210+
// finally
211+
// {
212+
// register_shutdown_function(function()
213+
// {
214+
// \Swoole\Process::kill(getmypid());
215+
// });
216+
// }
209217
}
210218

211219
// ------------------------------------------------------------------------------

src/Helpers/starter.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @link https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/CodeIgniter.php
66
* @since Version 3.2.0
7-
* @change 2018/09/12
7+
* @change 2018/09/25
88
*/
99

1010

@@ -65,7 +65,7 @@
6565
ini_set('default_charset', $charset);
6666
if (extension_loaded('mbstring'))
6767
{
68-
define('MB_ENABLED', TRUE);
68+
!defined('MB_ENABLED') AND define('MB_ENABLED', TRUE);
6969
// mbstring.internal_encoding is deprecated starting with PHP 5.6
7070
// and it's usage triggers E_DEPRECATED messages.
7171
@ini_set('mbstring.internal_encoding', $charset);
@@ -75,20 +75,20 @@
7575
}
7676
else
7777
{
78-
define('MB_ENABLED', FALSE);
78+
!defined('MB_ENABLED') AND define('MB_ENABLED', FALSE);
7979
}
8080
// There's an ICONV_IMPL constant, but the PHP manual says that using
8181
// iconv's predefined constants is "strongly discouraged".
8282
if (extension_loaded('iconv'))
8383
{
84-
define('ICONV_ENABLED', TRUE);
84+
!defined('ICONV_ENABLED') AND define('ICONV_ENABLED', TRUE);
8585
// iconv.internal_encoding is deprecated starting with PHP 5.6
8686
// and it's usage triggers E_DEPRECATED messages.
8787
@ini_set('iconv.internal_encoding', $charset);
8888
}
8989
else
9090
{
91-
define('ICONV_ENABLED', FALSE);
91+
!defined('ICONV_ENABLED') AND define('ICONV_ENABLED', FALSE);
9292
}
9393
if (is_php('5.6'))
9494
{
@@ -169,19 +169,19 @@
169169
*
170170
* @return CI_Controller
171171
*/
172-
if (! function_exists('get_instance'))
172+
if (! function_exists('get_instance')) // check
173173
{
174174
function &get_instance()
175175
{
176176
return CI_Controller::get_instance();
177177
}
178178
}
179-
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
180-
{
181-
require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
182-
}
183-
// Set a mark point for benchmarking
184-
$BM->mark('loading_time:_base_classes_end');
179+
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
180+
{
181+
require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
182+
}
183+
// Set a mark point for benchmarking
184+
$BM->mark('loading_time:_base_classes_end');
185185
/*
186186
* ------------------------------------------------------
187187
* Sanity checks

tests/application/controllers/tests/Test.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* Test Client & Task
66
* ----------------------------------------------------------------------------------
77
*
8+
* Tips: you must enable logs at config.php first before use log_message()
9+
*
810
* @author lanlin
9-
* @change 2018/07/01
11+
* @change 2018/09/25
1012
*/
1113
class Test extends CI_Controller
1214
{
@@ -20,7 +22,7 @@ public function task()
2022
{
2123
$data = $this->input->post();
2224

23-
log_message('info', var_export($data, true));
25+
log_message('error', var_export($data, true));
2426
}
2527

2628
// ------------------------------------------------------------------------------
@@ -30,7 +32,7 @@ public function task()
3032
*/
3133
public function task_timer()
3234
{
33-
log_message('info', 'timer works!');
35+
log_message('error', 'timer works!');
3436
}
3537

3638
// ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)