WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 20 months ago

#41480 closed defect (bug) (wontfix)

filter_var() is not working below php 5.2 version

Reported by: umangvaghela123 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: External Libraries Keywords: close
Focuses: Cc:

Description

I found the filter_var() function in class-phpmailer.php file , so I replace the filter_var function to is_email() because validate_email() function is deprecated.

Attachments (1)

41480.patch (462 bytes) - added by umangvaghela123 2 years ago.
Fix #41480 issue

Download all attachments as: .zip

Change History (6)

@umangvaghela123
2 years ago

Fix #41480 issue

#1 @umangvaghela123
2 years ago

is_email() function validate email address properly without issue.

#2 @SergeyBiryukov
2 years ago

  • Component changed from General to External Libraries
  • Keywords close added

Hi @umangvaghela123, thanks for the ticket!

PHPMailer is an external library, WordPress functions cannot be used there.

filter_var() appeared in PHP 5.2.0, but WordPress requires PHP 5.2.4+ (and recommends PHP 7 or greater).

Do you have an environment with PHP 5.2.4 or greater where filter_var() does not work? Why would you need class-phpmailer.php to work on PHP below 5.2.0?

#3 follow-up: @umangvaghela123
2 years ago

@SergeyBiryukov

If we include the class-phpmailer.php in wordpress environment so it is fine we use own default wordpress function.

issue #40353

@swissspidy comment for this bug.

As mentioned earlier in the ticket, filter_var() can't be used because it could be turned off in PHP 5.2.

#4 in reply to: ↑ 3 @SergeyBiryukov
2 years ago

Replying to umangvaghela123:

If we include the class-phpmailer.php in wordpress environment so it is fine we use own default wordpress function.

We wouldn't want to make changes to the original file though, unless absolutely necessary, as that makes it harder to maintain the file in the future.

issue #40353 @swissspidy comment for this bug.

As mentioned earlier in the ticket, filter_var() can't be used because it could be turned off in PHP 5.2.

It could, but WordPress shouldn't ever hit that branch of code, as $patternselect defaults to pcre8 or pcre if PCRE is available. If PCRE is not available, I don't think WordPress would work at all :)

#5 @dd32
20 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I'm going to close this as wontfix as realistically that branch of code shouldn't be run in WordPress.

If anyone does actually run into it being used, I'd love to know how/what/why. but I'm going to close this until such a time happens.

Note: See TracTickets for help on using tickets.