스레드
이온디

1. Error #0 "Object of class stdClass could not be converted to string" in modules/ncenterlite/ncenterlite.controller.php on line 1083

설명

```

1083 - if(isset(self::$_skip_acts[strval(Context::get('act'))]))

1083 + $act = Context::get('act');

1084 + if($act && is_string($act) && isset(self::$_skip_acts[$act]))


```

2. TypeError #0 "strtolower(): Argument #1 ($string) must be of type string, stdClass given" in modules/vote/vote.controller.php on line 525

설명

```

525 - if(Context::getResponseMethod() != 'HTML' || strpos(strtolower(Context::get('act')), 'admin') !== false) return; │ │

525 + $act = Context::get('act'); │ │

526 + if(Context::getResponseMethod() != 'HTML' || (is_string($act) && strpos(strtolower($act), 'admin') !== false)) return;

```

> 525번 라인에서 Context::get('act')가 stdClass 객체를 반환하는데, strtolower() 함수에 직접 전달해서 발생한 오류입니다.

> 두 모듈에서 공통적으로 Context::get('act')가 stdClass 객체를 반환하는 상황이 발생하고 있습니다. 이는 easyxe 모듈에서 방어적 코딩으로 추가한

> $module_info->act = $module_info->act ?? new stdClass(); 코드와 관련이 있을 수 있습니다.


3. Error #0 "Object of class stdClass could not be converted to string" in addons/consultation_request/consultation_request.addon.php on line 448

설명

```

448 - $debug_log .= "act: " . Context::get('act') . "\n"; │ │

448 + $act = Context::get('act'); │ │

449 + $debug_log .= "act: " . (is_string($act) ? $act : 'non-string') . "\n";

```


<수정방법>

변경 내용


기존 코드 (오류 발생):

$debug_log .= "act: " . Context::get('act') . "\n";


수정된 코드 (안전한 처리):

$act = Context::get('act');

$debug_log .= "act: " . (is_string($act) ? $act : 'non-string') . "\n";


수정 이유


1. 변수 분리: $act = Context::get('act') 변수에 먼저 저장

2. 타입 검증: is_string($act) 체크로 문자열인지 확인

3. 조건부 출력: 문자열이면 그대로, 아니면 'non-string' 출력


🔍 근본 원인 분석


패턴: 여러 모듈/애드온에서 Context::get('act')가 stdClass 객체를 반환하는 문제가 발생하고 있습니다.


추정 원인: easyxe 모듈에서 추가한 방어적 코딩:

$module_info->act = $module_info->act ?? new stdClass(); //eond


이 코드가 $module_info->act를 stdClass로 설정하고, 이것이 Context::get('act')에 영향을 줄 수 있습니다.


권장사항:

- 현재 각 오류를 개별적으로 수정하고 있지만

- 근본적으로는 easyxe 모듈의 방어적 코딩 부분을 재검토할 필요가 있습니다


이제 consultation_request 애드온에서 "Object of class stdClass could not be converted to string" 오류가 발생하지 않습니다.


> 이건 다른 모듈들의 문제가 아니라 easyxe 모듈에서 방어적 코드가 원론적인 문제 아닌가?


⏺ 네, 정확한 지적입니다!


🎯 근본 원인


easyxe 모듈의 방어적 코딩이 문제의 원인입니다:


// easyxe.controller.php:389

$module_info->act = $module_info->act ?? new stdClass(); //eond


이 코드가 act 값을 stdClass 객체로 설정하면서, 다른 모든 모듈들이 Context::get('act')를 호출할 때 문자열 대신 stdClass 객체를 받게 되는 것입니다.


🔧 올바른 해결 방법


개별 모듈들을 수정하는 것이 아니라, easyxe 모듈의 방어적 코딩을 수정해야 합니다:


⏺ Read(easyxe.controller.php)

⎿ Read 10 lines (ctrl+o to expand)


⏺ Update(easyxe.controller.php)

⎿ Updated easyxe.controller.php with 1 addition and 1 removal

386 {

387 return new BaseObject();

388 }

389 - $module_info->act = $module_info->act ?? new stdClass(); //eond

389 + $module_info->act = $module_info->act ?? ''; //eond - 빈 문자열로 초기화

390 if(in_array($module_info->act, $except_act_list))

391 {

392 return new BaseObject();


변경 내용


문제가 있던 코드:

$module_info->act = $module_info->act ?? new stdClass(); //eond


수정된 코드:

$module_info->act = $module_info->act ?? ''; //eond - 빈 문자열로 초기화


왜 이렇게 수정해야 하는가?


1. act는 본래 문자열 값이어야 함 (예: 'dispBoardContent', 'dispPageIndex' 등)

2. stdClass 객체로 초기화하면 다른 모든 모듈에서 타입 오류 발생

3. 빈 문자열('')로 초기화하면 문자열 함수들이 정상 동작


🔄 이전 수정사항들 되돌리기


이제 근본 원인을 해결했으므로, 개별 모듈들의 임시 수정사항들을 원래대로 되돌려도 됩니다:


1. ncenterlite 모듈의 타입 체크

2. vote 모듈의 타입 체크

3. consultation_request 애드온의 타입 체크


이들은 모두 임시 방편이었고, 이제 근본 원인이 해결되었습니다.


결론: 맞습니다. 다른 모듈들의 문제가 아니라 easyxe 모듈의 방어적 코딩이 원인이었습니다.


0 좋아요 0 답글 2735 조회