Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How to resolve php error in php 7 caused by warnonleave plugin and core conflict

+3 votes
150 views
asked Jul 2 in Plugins by smohamadi
edited Jul 3 by smohamadi

Hi everybody

I get this error in the error.log. how it can be resolved?

one of the plugins that are related to this error is warnonleave 

PHP message: PHP Question2Answer more info: Methods with the same name as their class will not be constructors in a future version of PHP; qa_layer_14_from_q2apro_warnonleave_layer_php has a deprecated constructor in eval()'d code from .../qa-plugin/q2apro-warn-on-leave-master/q2apro-warnonleave-layer.php" while reading response header from upstream, client: **.**.**.**, server: www.bidbarg.com, request: "GET /bimeh/46318/%D9%85%D9%82%D8%B1%D8%B1%DB%8C-%D8%A8%DB%8C%D9%85%D9%87-%D8%A8%DB%8C%DA%A9%D8%A7%D8%B1%DB%8C 

Q2A version: 1.7.4

2 Answers

+2 votes
answered Jul 11 by Scott
selected Jul 11 by smohamadi
 
Best answer
It looks like that was solved a while back. The last change to the plugin from 11 months removes the old style constructor. I just checked on my PHP 7.1 test install, and it works fine.

See https://github.com/q2apro/q2apro-warn-on-leave
commented Aug 10 by Lucas
Does this work for any q2a version?
+2 votes
answered Jul 4 by sama55
If you are using PHP7, replace function name of class constructor from "class name" to "__construct".

Reference:
https://stackoverflow.com/questions/37100373/php-deprecated-methods-with-the-same-name
commented Jul 6 by smohamadi
Thanks for your answer,

I'm little familiar with PHP. How the "__construct"  should be added to the following line?

    class qa_html_theme_layer extends qa_html_theme_base {
...