Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#47920 closed feature request (invalid)

PHP Warning: Parameter 2 to qtranxf_postsFilter() expected to be a reference

Reported by: blew2's profile blew2 Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.2.2
Component: Plugins Keywords:
Focuses: coding-standards Cc:

Description

Not sure this should be called a bug but

ubuntu 18.04 apache error.log complains about

"PHP Warning: Parameter 2 to qtranxf_postsFilter() expected to be a reference, value given in ../wp-includes/class-wp-hook.php on line 286"

php version: 7.2

changing: public function apply_filters( $value, $args )
to public function apply_filters( $value, &$args )

silenced the log

Clearly this has to do with qTranslate-X plugin.

Is it a bad idea to pass $args as a reference in function_apply_filters,
or maybe the plugin creators should change their code to avoid modifying data in passed references?

qtranslate_frontend.php has this definition:

function qtranxf_postsFilter($posts,&$query)

and the query is modified inside of the function.

Change History (1)

#1 in reply to: ↑ description @SergeyBiryukov
5 years ago

  • Component changed from General to Plugins
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the ticket.

Replying to blew2:

or maybe the plugin creators should change their code to avoid modifying data in passed references?

Yes, that would be the correct resolution here.

Looks like the issue is already reported to plugin authors:
https://github.com/qTranslate-Team/qtranslate-x/issues/544

However, the plugin hasn't been updated in 3 years, and is apparently abandoned.

This topic has some details on a workaround: https://wordpress.org/support/topic/problem-with-php-7-1-2/

Note: See TracTickets for help on using tickets.