Extra Form
PHP PHP 8.0
CMS Rhymix 2.0

우여곡절(??) 끝에 PHP 8.0으로 갈아탄후 후속작업 계속하고 있습니다.

 

livexe를 들여다보고 있습니다. 죽은자식 거시기 만지기??? 좌우간....

 

cd /home/http/htdocs/soonj.net/rx8 && php /home/http/htdocs/soonj.net/rx8/modules/livexe/get_rss.php
를 크론으로 정기적으로 RSS를 수집하는데

PHP Exception: Error #0 "Context::/(): Argument #1 ($val) cannot be passed by reference" in modules/livexe/livexe.controller.php on line 130 (via classes/context/Context.class.php on line 945)
#0 /home/http/htdocs/soonj.net/rx8/classes/context/Context.class.php(1019): Context::convertEncoding()
#1 /home/http/htdocs/soonj.net/rx8/modules/livexe/livexe.controller.php(130): Context::convertEncodingStr()
#2 /home/http/htdocs/soonj.net/rx8/modules/livexe/livexe.controller.php(96): livexeController->_get()
#3 /home/http/htdocs/soonj.net/rx8/modules/livexe/get_rss.php(13): livexeController->doCrawl()

의 에러가 발생합니다.

물론 7.4에서는 문제가 없었던 대목이구요.

 

modules/livexe/livexe.controller.php에서

$body = Context::convertEncodingStr(FileHandler::getRemoteResource($item->rss_url, null, 10, 'GET', 'application/xml', array('User-Agent'=>'liveXE ( '.Context::getRequestUri().' )')));
 

 

classes/context/Context.class.php
      public static function checkConvertFlag(&$val, $key = null, $charset = null) 에서

&$val이 문제더군요.

 

우선은 급한김에 public static function checkConvertFlag($val, $key = null, $charset = null) 로 수정해서 사용하고 있는데

 

이렇게 수정하지 않고 해결하는 방법은 없는 건가요?

안되면 아예

body = FileHandler::getRemoteResource($item->rss_url, null, 10, 'GET', 'application/xml', array('User-Agent'=>'liveXE ( '.Context::getRequestUri().' )'));

로 UTF8만 긁어오는 것으로 해결하는 수밖에 없을 듯합니다.

  • profile

    두 단계로 나눠서 처리하시면 됩니다.

     

    $body = FileHandler::getRemoteResource($item->rss_url, null, 10, 'GET', 'application/xml', array('User-Agent'=>'liveXE ( '.Context::getRequestUri().' )'));

     

    Context::convertEncodingStr($body);

     

    참조로 넘기는 함수는 참조할 변수가 있어야 하는데, 다른 함수의 출력값을 변수에 할당하지 않고 그냥 넘겨서 에러가 나는 것입니다. PHP 내장함수 중 배열을 조작하는 것들은 대부분 참조로 받기 때문에, a(b(c())) 이렇게 한 번에 묶어서 사용할 수 없고 꼭 변수에 할당한 후에 넘겨야 합니다.
     

    코어를 수정하여 참조를 제거하시면 저 함수는 아무 기능을 하지 못합니다. 즉, 아무런 변환도 일어나지 않게 되므로 해결책이 아닙니다.

  • profile profile
    두단계로 나눠서 처리해도 똑같은 에러가 생깁니다.

    PHP Exception: Error #0 "Context::checkConvertFlag(): Argument #1 ($val) cannot be passed by reference" in modules/livexe/livexe.controller.php on line 128 (via classes/context/Context.class.php on line 945)
    #0 /home/http/htdocs/soonj.net/rx8/classes/context/Context.class.php(1020): Context::convertEncoding()
    #1 /home/http/htdocs/soonj.net/rx8/modules/livexe/livexe.controller.php(128): Context::convertEncodingStr()
    #2 /home/http/htdocs/soonj.net/rx8/modules/livexe/livexe.controller.php(96): livexeController->_get()
    #3 /home/http/htdocs/soonj.net/rx8/modules/livexe/get_rss.php(13): livexeController->doCrawl()
  • profile profile

    음, 저기서 에러가 난다면 코어가 정상 작동할 리가 없는데? 라고 생각하고 자세히 살펴보니 코어에서는 entry를 제외하면 이 함수를 아예 사용하지 않는군요. 예전에 다 들어내버려서 고아가 된 함수인가 봅니다.

    그냥 없는 기능이라고 치고 별도로 구현하시면 좋을 것 같습니다. 예를 들어 EUC-KR/CP949로 들어올 가능성이 있는 리소스라면

    $body = 외부 리소스 가져오기;
    if (!utf8_check($body)) {
        $body = iconv('CP949', 'UTF-8', $body);
    }

     

    코어에서도 문제의 함수들은 deprecated 처리하겠습니다.

  • profile profile
    예 항상 감사합니다.