Penggunaan fungsi FILTER_FLAG_HOST_REQUIRED pada PHP

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

Comments

This error is also shown to me when I send an email.

Like the thread already says, this has been fixed. Update your PHPMailer.

My version is the last stable (6.0.7) and the problem are still there.

The FILTER_FLAG_SCHEME_REQUIRED constant is not used anywhere in the current release. Double-check your versions.

Sorry for my complain.
My VSCode cache from Github was keeping the old code, instead of update it (even after composer.json update)

Sorry for my complain.
My VSCode cache from Github was keeping the old code, instead of update it (even after composer.json update)

in my composer.json is

"phpmailer/phpmailer": "v6.1.7",

how did you force composer to use the new version?

well, and we use php 7.4

Change your composer.json to:

"phpmailer/phpmailer": "^6.1",

Then update (just PHPMailer) using composer update phpmailer/phpmailer. This pattern will match semver numbering and will get the latest version of PHPMailer 6.x.x, currently 6.1.8.

After execute this command php artisan mapping:rerun
i have got this exception
[ErrorException] filter_var(): explicit use of FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED is deprecated
How can i overcome this exception can anybody help me .

Same here. I will do some digging on this, but would appreciate some pointers. I guess it has to do with Elastic updates on the system.

Same happen if i upgrade php version to 7.3.

i found some way to fix it

go to:

vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php

find below:

private function prependMissingScheme($host) {    
    if (!filter_var($host, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {       
        $host = 'http://' . $host;    
    }    
    return $host;
}

replace to

private function prependMissingScheme($host)
{
     
      if (empty(parse_url($host, PHP_URL_SCHEME))) { 
         $host = 'http://' . $host; 
     } 

     return $host;
}

In PHP 7.3, these two flags are deprecated because they are already implied (since PHP 5.6). The ideal fix is to remove these flags. See php.watch's post about filter_var() deprecation warnings.

So the ideal fix would be replacing the following block with the block followed by it.

private function prependMissingScheme($host) {    
    if (!filter_var($host, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {       
        $host = 'http://' . $host;    
    }    
    return $host;
}

replace with this:

private function prependMissingScheme($host) {    
    if (!filter_var($host, FILTER_VALIDATE_URL)) {       
        $host = 'http://' . $host;    
    }    
    return $host;
}