• Hello,

    I found this topic: https://ww.wp.xz.cn/support/topic/php-7-17/. Also, we tested our website with plugin PHP Compatibility Checker (https://ww.wp.xz.cn/plugins/php-compatibility-checker/) for PHP 7.0 compatibility.

    We noticed two warnings/errors:

    FILE:
    wp-content/plugins/woocommerce-pdf-invoices-packing-slips/lib/dompdf/dompdf.php
    183 | ERROR | The use of function split is discouraged from PHP version 5.3 and forbidden from PHP version 7.0; use preg_split instead

    FILE: wp-content/plugins/woocommerce-pdf-invoices-packing-slips/lib/dompdf/include/page_cache.cls.php
    40 | WARNING | Method name “Page_Cache::__query” is discouraged; PHP has reserved all method names with a double underscore prefix for future use

    I can offer solution for first:

    $arr = split(‘,’,$opts[‘t’]);
    can be replaced with:
    $arr = explode(‘,’,$opts[‘t’]);
    explode is simpler than preg_replace.
    http://php.net/manual/en/function.explode.php
    http://php.net/manual/en/function.split.php

    Second warning it’s related to name of function. You can change __query to something else.

    Also, I’ve one performance optimization:

    woocommerce-pdf-invoices-packingslips.php – line 108

    $site_plugins = get_site_option( ‘active_sitewide_plugins’, array() );
    ->
    $site_plugins = is_multisite() ? (array) maybe_unserialize( get_site_option('active_sitewide_plugins' ) ) : array();

    On single sites, It saves call of get_option – is_multisite is basically return false. On this way we save one SQL query (because option doesn’t exist and it isn’t in the cache – it’s helpful for shared hostings). On mulisite installation, option active_sitewide_plugins is already cached.

    I’ll try plugin on PHP7 in next couple days. What’s current status?

    Sasa

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi Sasa,
    Thanks for reporting! Unfortunately both errors come from the DOMPDF library, which is a third party component. I intend to move to the latest version of DOMPDF (which is php7 compatible) before the end of the year, but I don’t have an exact release date yet.

    Since split() doesn’t work in PHP7, I have applied your explode() suggestion and will include this in the next release. The __query function name is only a warning so I’ll leave that as is for now.

    Thanks for the suggestion for the multisite check too! I will probably add a check for the WooCommerce class or function too, since that will also prevent errors if people install in a none-standard location.

    Again, thanks, great contributions!
    Ewout

    • This reply was modified 9 years, 9 months ago by Ewout.
Viewing 1 replies (of 1 total)

The topic ‘PHP Compatibility Checker – warnings’ is closed to new replies.