2012-05-31 4 views
1

메일 템플릿 시스템을 프로그래밍하고있었습니다. 사용자는 거기에서 마커를 사용할 수 있어야하며 실제 데이터로 대체됩니다. 문제의 표준시는 마커를 대체 할 내 기능은 잘 작동하지만, 내가 해낸 내가 한 번만 실행됩니다 그 함수의 recursiv 호출을 할 필요가 있고, 이것이다 :PHP 재귀 호출로 인해 서버 간 오류가 발생했습니다.

public function replace_placeholders($content, $recipient, $settings, $interface, $recommendation, $format, $recursion = false) { 
    $content = $this->replace_ph('briefanrede' , $recipient['id']   , $content); 
    $content = $this->replace_ph('anrede'  , $recipient['title']  , $content); 
    $content = $this->replace_ph('email'  , $recipient['email']  , $content); 
    $content = $this->replace_ph('kundennummer' , $recipient['kdnumber'] , $content); 
    $content = $this->replace_ph('briefanrede' , $recipient['briefanrede'] , $content); 

    if($recipient['title'] == $settings['anrede_w'] || $recipient['title'] == $settings['anrede_m']) { 
     $content = $this->replace_ph('vorname' , $recipient['forename'] , $content); 
     $content = $this->replace_ph('nachname' , $recipient['surename'] , $content); 
    } else { 
     $content = $this->replace_ph('vorname' , "" , $content, true); 
     $content = $this->replace_ph('nachname' , "" , $content, true); 
    } 

    $content = $this->replace_salutation($recipient, $settings, $content); 

    //Recommendation  
    if($this->need_replacement($content, 'weiterempfehlung') === false && $recursion === false) { 
     if($recommendation['own_page'] == 1) { 
      $baseurl = $recommendation['location']; 
     } else { 
      $baseurl = $recommendation['link']; 
     } 
     $pattern = ($format == "html") ? '<a href="%s">%s</a>' : '%s'; 
     $url = $this->replace_placeholders($baseurl, $recipient, $settings, $interface, $recommendation, true); 
     $content = $this->replace_ph('weiterempfehlung' , (($format == "html") ? sprintf($pattern, $url, $settings['text_weiterempfehlung']): sprinf($pattern, $url)), $content); 

    } 

    return $content; 
} 

recursiv 이 행의 전화

$url = $this->replace_placeholders($baseurl, $recipient, $settings, $interface, $recommendation, true); 

은 500 내부 서버 오류의 원인입니다. 이유는 모르겠다. 왜냐하면 나는 재귀가 한 번 실행되는 것을 제한했기 때문이다. 너 나 좀 도와 줄 수있어?

죄송합니다. 제 영어 실력이 좋지 않아서 명확한 문장을 쓰려고 노력합니다.

// 편집 :

아파치 로그 :

[Wed May 30 15:31:56 2012] [warn] [client xx.xxx.xx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server 
[Wed May 30 15:31:56 2012] [warn] [client xx.xxx.xx.xxx] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function 
[Wed May 30 15:31:56 2012] [error] [client xx.xxx.xx.xxx] File does not exist: /var/www/web80/html/web80-newsletter/favicon.ico 
[Wed May 30 15:31:58 2012] [error] mod_fcgid: process /var/www/php-fcgi/web80.php53/php-fcgi(21975) exit(communication error), get unexpected signal 11 

PHP는 오류 로그가 비어 있습니다.

+2

더 자세한 오류 메시지는 서버 로그를 참조하십시오. –

+1

IF 문이 매번 true를 반환하는 것처럼 보이기 때문에'if ($ this-> need_replacement ($ content, 'weiterempfehlung') === false && $ recursion === false) {' 스크립트 실행 시간 초과 또는 메모리 부족으로 PHP가 종료 될 때까지 스크립트가 중단되지 않습니다. – Gavin

+0

if case에서 볼 수 있듯이 재귀 호출이 $ param $ recursion === true로 완료되면 if 문에서 루프가 가능하지 않아야합니다. –

답변

1

당신이 $recursive = false

if($this->need_replacement($content, 'weiterempfehlung') === false && $recursion === false) 

항상 true를 돌려 명세서 경우 다시 만드는 모든 시간, 거짓되고 계속하고, 당신의 재귀 호출에 하나 개의 인수를 그리워 보인다. 대신 재귀 호출에 마지막 변수를 추가하는 시도하고 제대로 즉, 스크립트를 실행 할 수 있어야한다 : 내가 대신 최초의 진정한의 추가 할 생각은 무엇

$url = $this->replace_placeholders($baseurl, $recipient, $settings, $interface, 
$recommendation, true, true); 
        ^added one true 

$format입니다.

+0

당신은 천재적입니다 !! 고마워, 내가 얼마나 오랫동안 그 벙어리가 될 수 있는지 찾고 있었어. –

+0

나도 똑같은 실수를 저질렀다;) – lfxgroove

0

신호 11은 SIGSEGV입니다. 즉, 잘못된 메모리 액세스 (예 : NULL 포인터를 역 참조하거나 액세스하지 못했던 메모리에 액세스하는 등)로 인해 프로세스가 중단되었습니다.

이것은 PHP 스크립트가 유발해야하는 것이므로 가장 안정적인 PHP 버전으로 먼저 업그레이드해야하며 가능한 경우 스크립트를 가능한 많이 줄이십시오 (충돌이 여전히 발생하는 동안 제거 할 수있는 모든 것을 제거하십시오) 그리고 PHP 버그로보고하십시오.

관련 문제