Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

윈도우 환경에서 artisan xe:update 실행시 버전인식 못하는 문제 해결 #1141

Merged
merged 1 commit into from Jun 4, 2020

Conversation

darron1217
Copy link
Contributor

문제 재현 방법

  1. 윈도우에서 CMD로 php artisan xe:update 실행
  2. 업데이트 안됨 (버전 인식 불가)

문제의 원인

어떤게 원인 이었나요?

윈도우에서 PHP_EOL로 explode 하는 함수가 작동하지 않았고, PHP_EOL과 버전정보문서(versions.txt)간의 new line 문자가 다른 것으로 추정

패치 내역

어떤걸 수정했나요?

윈도우 리눅스 양쪽에서 호환되도록 PHP_EOL 을 \n으로 변경하는 대신 array_map("rtrim"으로 윈도우 new line 문자들을 제거

(Stackoverflow 참고함 https://stackoverflow.com/questions/4975411/when-do-i-use-php-eol-instead-of-n-and-vice-versa-ajax-jquery-client-problem)

@akasima
Copy link
Member

akasima commented Apr 27, 2020

PHP_EOL 를 사용해야 좋은거 아닌가요?
문제되는 윈도우 환경에서 $response->getBody()->getContents()PHP_EOL 가 어떻게 되나요?

@darron1217
Copy link
Contributor Author

    public function coreVersions()
    {
        if (!$this->coreVersions) {
            $response = $this->getHttpClient()->request(
                'GET',
                'http://start.xpressengine.io/download/versions.txt'
            );

            if ($response->getStatusCode() !== 200) {
                throw new \Exception('fail to get released information');
            }

            $lines = explode(PHP_EOL, $response->getBody()->getContents());
            $this->coreVersions = Collection::make($lines)->filter()->map(function ($v) {
                return basename(trim($v), '.zip');
            })->sort('version_compare')->values()->all();
        }

        // 내용 확인을 위한 throw
        throw new \Exception(print_r($this->coreVersions,true));

        return $this->coreVersions;
    }

위처럼 내용확인을 위해 exception을 중간에 던져보면 아래처럼 나옵니다

Updating Xpressengine.
======================


In ReleaseProvider.php line 93:
                                
  Array                         
  (                             
      [0] => 3.0.0-beta.23.zip  
  3.0.9.zip                     
  3.0.0-beta.30.zip             
  3.0.5.zip                     
  3.0.0-beta.20.zip             
  3.0.0-beta.28.zip             
  3.0.0-rc.3.zip                
  3.0.8.zip                     
  3.0.0-beta.16.zip             
  3.0.0-rc.5.zip                
  3.0.0-beta.18.zip             
  3.0.0-beta.27.zip             
  3.0.0-beta.22.zip             
  3.0.0-rc.1.zip                
  3.0.6.zip                     
  3.0.0-rc.7.zip                
  3.0.7.zip                     
  3.0.0-beta.21.zip             
  3.0.0-beta.19.zip             
  3.0.10.zip                    
  3.0.2.zip                     
  3.0.0-rc.2.zip                
  3.0.0-beta.26.zip             
  3.0.0.zip                     
  3.0.0-beta.25.zip             
  3.0.3.zip                     
  3.0.0-beta.17.zip             
  3.0.0-beta.29.zip             
  3.0.1.zip                     
  3.0.0-rc.4.zip                
  3.0.4.zip                     
  3.0.0-rc.8.zip                
  3.0.0-beta.15.zip             
  3.0.0-rc.6                    
  )                             

@darron1217
Copy link
Contributor Author

darron1217 commented Apr 27, 2020

제 생각엔 http://start.xpressengine.io/download/versions.txt이 주소의 서버가 리눅스라서 그냥 \n으로 고정되어 넘어오는것 같은데 윈도우 환경에서 EOL은 \r\n으로 나오기 때문에 분리가 안되는것 같습니다.
EOL은 주로 파일시스템에서 읽어올때 사용하는 용도로 알고 있는데, http 요청에 쓰는것은 용도에 맞지 않는것 같습니다. (원격지 환경과 로컬 환경이 다르기 때문에 무용지물)

@darron1217
Copy link
Contributor Author

사실상 서버쪽 newline 문자가 변할일이 없기 때문에 그냥 PHP_EOL 대신 \n을 넣기만 해도 잘 작동할것 같구요

@jhyeon1010 jhyeon1010 merged commit 703293b into xpressengine:develop Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants