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

Update DB_URL #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

donmhico
Copy link

@donmhico donmhico commented Jul 7, 2021

Issue

It seems like the URL which contains the iso3166.csv was updated. https://dev.maxmind.com/csv-files/codes/iso3166.csv is returning "Redirecting to /static/csv/codes/iso3166.csv" which causes the composer install fail because the generated iso3166.php contains

array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(44) "Redirecting to /static/csv/codes/iso3166.csv"
  }
}

instead of the expected iso3166 data.

See - https://dev.maxmind.com/geoip/legacy/codes?lang=en

Description

This PR updates DB_URL

@NeilJ247
Copy link

NeilJ247 commented Jul 7, 2021

I raised this as an issue in #14. I am thinking we should set CURLOPT_FOLLOWLOCATION when downloading the file instead of changing the URL variable all the time.

    protected static function downloadFile($filename, $url)
    {
        $fileHandle = fopen($filename, 'w');
        $options    = [
            CURLOPT_FILE    => $fileHandle,
            CURLOPT_TIMEOUT => 600,
            CURLOPT_URL     => $url,
            CURLOPT_FOLLOWLOCATION => true,
        ];

        $curl = curl_init();
        curl_setopt_array($curl, $options);
        curl_exec($curl);
        curl_close($curl);
    }

@NeilJ247
Copy link

NeilJ247 commented Jul 7, 2021

I've created another PR in #15 for my suggested change.

@donmhico
Copy link
Author

donmhico commented Jul 9, 2021

I raised this as an issue in #14. I am thinking we should set CURLOPT_FOLLOWLOCATION when downloading the file instead of changing the URL variable all the time.

    protected static function downloadFile($filename, $url)
    {
        $fileHandle = fopen($filename, 'w');
        $options    = [
            CURLOPT_FILE    => $fileHandle,
            CURLOPT_TIMEOUT => 600,
            CURLOPT_URL     => $url,
            CURLOPT_FOLLOWLOCATION => true,
        ];

        $curl = curl_init();
        curl_setopt_array($curl, $options);
        curl_exec($curl);
        curl_close($curl);
    }

That approach should work as well. Just, personally, I tend not to use CURLOPT_FOLLOWLOCATION for fetching data just so that if the API URL was changed, just like this case, I can immediately know that it was change and see if other breaking changes happened.

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.

2 participants