1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

1.7 Php7 Warnings And Errors

Discussion in 'General Troubleshooting' started by valMETNG, Dec 11, 2015.

  1. valMETNG

    valMETNG Administrator Staff Member Admin

    I recently did a quick test of just-released PHP7 in my build and immediately noticed the following warnings:
    The issue occurs because PHP7 will deprecate PHP4 Style constructors. The Inspect library hasn't been maintained in about 6 years but it would be quite the chore to remove it from Hotaru core given it's used pretty much everywhere (and I'm not sure what a better library would be). @shibuya246, what do you think is the best way to approach this? Here are some ideas from WordPress.

    For those who are testing PHP7, please post any warnings or errors you see in this thread. Auditing the code is going to take some time and effort.
     
  2. valMETNG

    valMETNG Administrator Staff Member Admin

    So far, the above warnings are the only ones I've found. To remove these warnings, I've made the following changes:

    Change line 21 in /libs/extensions/Inspekt/Inspekt/Error.php, line 61 in /libs/extensions/Inspekt/Inspekt/Cage.php, line 77 in /libs/extensions/Inspekt/Inspekt/Supercage.php, and line 61 in /libs/extensions/ezSQL/ez_sql_core.php to:
    Code:
    function __construct() {
    Change line 48 in /libs/extensions/ezSQL/mysqli/ez_sql_mysqli.php to:
    Code:
    function __construct($dbuser='', $dbpassword='', $dbname='', $dbhost='localhost', $encoding='')
    You will also need to either change your PHP environment (e.g., under cPanel PHP Selector) to 7.x or add the following line to the top of your .htaccess:
    Code:
    AddHandler application/x-httpd-php70 .php .php5 .php4 .php3
    Oh yes. It is indeed MUCH faster. Based on some random testing, I'm seeing about 45-50% increases in page load time. :)
     
    shibuya246 and narc like this.
  3. narc

    narc Well-Known Member

    many thanks for you, bei its hotfix dont run for me. will PHP7 with hotaru too :)

    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Whois has a deprecated constructor in /vendor/phpwhois/phpwhois/src/whois.main.php on line 31
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WhoisClient has a deprecated constructor in /vendor/phpwhois/phpwhois/src/whois.client.php on line 30
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; idna_convert has a deprecated constructor in /vendor/phpwhois/phpwhois/src/whois.idna.php on line 54
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ezSQLcore has a deprecated constructor in /libs/extensions/ezSQL/ez_sql_core.php on line 27
     
  4. valMETNG

    valMETNG Administrator Staff Member Admin

    Interesting - what did you do to generate this error? I submitted links both with a domain found and a non-existing domain and neither generated this error. I want to know this as there might be testing I'm missing.

    To fix -

    Change line 51 in /vendor/phpwhois/phpwhois/src/whois.main.php and line 71 in /vendor/phpwhois/phpwhois/src/whois.client.php to:
    Code:
    function __construct()
    Change line 94 of /vendor/phpwhois/phpwhois/src/whois.idna.php to:
    Code:
    function __construct($options = false)
    For the last one, I gave you the fix above for ez_sql_core.php - did you forget to change?
     
    Last edited: Jan 7, 2016
  5. narc

    narc Well-Known Member

  6. narc

    narc Well-Known Member

    ok , to live on the side of it does not work unfortunately . Only a 500 error with nginx and Apache :( + PHP 7.0.1
     
  7. valMETNG

    valMETNG Administrator Staff Member Admin

    I'm glad it works. But what did you do previously to generate the error?
     
  8. valMETNG

    valMETNG Administrator Staff Member Admin

    @narc found another one in libs/extensions/GenericPHPConfig/class.metadata.php. (Shows how awful my testing was.) To fix, change line 79 to:
    Code:
    function __construct() {
     
  9. narc

    narc Well-Known Member

    Yes it worked locally . have it tested with MAMP PRO and PHP 7.0.0 . Only two of its own plugins have made mistakes. This I have been deactivated and all pushed to live . life would have it but do not run . The site has always produced a 500 error .

    I'll set up a stage environment . Then I test further . my two plugins I have to correct yet .
     
  10. valMETNG

    valMETNG Administrator Staff Member Admin

    Internal server errors are sometimes difficult to figure out. For me, I almost always find the problem is related to a mistake in the .htaccess file.
     
    narc likes this.
  11. valMETNG

    valMETNG Administrator Staff Member Admin

    Never mind - I figured it out.
     
    narc likes this.
  12. robin007

    robin007 Well-Known Member

    Now Stable PHP 7.0.2 version released.
     
  13. valMETNG

    valMETNG Administrator Staff Member Admin

    I'm waiting for my host to get it through testing and offer it :)
     
    robin007 likes this.
  14. narc

    narc Well-Known Member

    so testing enought on my mamp local mashine. it ist works :( error 500 without logs under php7. the same as live-site.
     
  15. valMETNG

    valMETNG Administrator Staff Member Admin

    I thought you said earlier you were able to get it working on local? Now it's not working?

    I know how hard it is to troubleshoot environment errors. If you have the local environment configuration files when it was working, you could compare those to the ones you have now (or the ones on your live site). Be sure to look at both your server configuration files and your php.ini file. Another place to look is to compare the environment settings from your earlier PHP 5.x environment to the PHP 7.x environment. There may be a setting difference. Also, it could be a file or directory needs to have different permissions (e.g., using chmod, change all files and directories in your test environment to 777 - if you don't see the 500 error anymore, then it's a permissions issue).

    I've never used it but, while searching for other ideas, I came across PHP7 compatibility checker. Perhaps you could try this to see what issues it finds.
     
  16. valMETNG

    valMETNG Administrator Staff Member Admin

    It's unclear if this is related to using PHP 7, but I think it is. I'm seeing the following errors in 1.7.3 base:
    To fix it, replace line 88 with:
    Code:
    $parts1 = (string)$parts[1];
    $cron_call->$parts1($h);
     
  17. valMETNG

    valMETNG Administrator Staff Member Admin

    My hosting provider upgraded PHP7 to PHP7.0.7 recently without telling anyone and it caused my site to crash. For any of you using PHP 7, I wanted to post the fix so you don't spend 2 full days figuring it out as I just did :)

    There was a harmless PHP bug (69659 according to PHP's change log - see also 72117) corrected in the 7.0.6 patch that now "completely breaks the null-coalesce operator in PHP 7." To fix it, you'll need to replace line 163 in Hotaru.php and line 204 in /libs/Initialize.php with the following:
    Code:
    if (method_exists($this, 'get_' . $name) || isset($this->$name)) { return true; } else { return false; } 
    From what I can tell, you should be able to make that change even if you are using an earlier PHP version.

    @shibuya246, it would be great if you can review my fix and confirm it makes sense. If so, you'll want to add this to the queue for future releases.
     
    Last edited: Jun 14, 2016
  18. narc

    narc Well-Known Member

    can you tell me, what line was it before? my initialize.php is custom... and line 161 and 204 empty :(
     
  19. valMETNG

    valMETNG Administrator Staff Member Admin

    Sure. In Hotaru.php, starting on line 160, the full function looks like this:
    Code:
            // to get protected properties
            public function __isset($name)
            {
                    return isset($this->data[$name]);
            }
    In /libs/Initialize.php, starting on line 200, the line looks like this:
    Code:
            // to get protected properties
            public function __isset($name)
            {
                    //echo "Is '$name' set?\n";
                    return isset($this->data[$name]);
            }
    So you're replacing the lines that start with "return."

    Effectively, when using > PHP 7.0.6, Hotaru's isset() functions stop working on array dimensions. The first thing to go were the plugins: none of them would get loaded because there are functions that go and grab all the functions and put them into arrays. After doing this, Hotaru checks if the plugin arrays are empty and, if they are, it leaves you with an "oops" page not found. However, the arrays were not empty - they were just evaluated as empty because of the bug.
     

Share This Page