anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Deprecated flag warning under PHP 7.4 #161

Closed paulmer closed 3 years ago

paulmer commented 3 years ago

The filter_var on line 501 of system/application/controllers/books.php uses the deprecated flag FILTER_FLAG_HOST_REQUIRED which generates a visible warning when running in development mode. This flag has been implied with FILTER_VALIDATE_URL since PHP 5.2.1 and can safely be removed from the code to eliminate the warning.

craigdietrich commented 3 years ago

Hi @paulmer!

So, you're saying we could replace this:

filter_var($this->data['prev'],FILTER_VALIDATE_URL,FILTER_FLAG_HOST_REQUIRED)

... with this:

filter_var($this->data['prev'],FILTER_VALIDATE_URL)

paulmer commented 3 years ago

That's right, more specifically the line should read:

if ((filter_var($this->data['prev'],FILTER_VALIDATE_URL) === FALSE) || (filter_var($this->data['link'],FILTER_VALIDATE_URL) === FALSE)) {

since filter_var appears twice with that flag. Sorry I'm not able to put a pull request together on this right now.

craigdietrich commented 3 years ago

Done!

https://github.com/anvc/scalar/commit/af5012503bebef991647a87587cf8c906775a4a3

Thanks!