• Resolved charlesgodwin

    (@charlesgodwin)


    We have CBX PhpSpreadSheet Library enabled to provide PHPExcel support for several internally developed plugins. This has worked for years. But when I enable GravityExport Lite for Gravity Forms those plugins fail at this point

    if (defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && file_exists(CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php')) {
      //Include PHPExcel
      require_once CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php';
    //now take instance
                $excel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
    } else {
         error_log(__FILE__ . " CBX PhpSpreadSheet Library plugin is missing");
                return false;
            }
    $sheet = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($excel, 'Active');
    $excel->addSheet($sheet, 0);

    The problem is the code is getting your version of the classes. Here is an error log message

    PHP Fatal error:  Uncaught TypeError: GFExcel\Vendor\PhpOffice\PhpSpreadsheet\Spreadsheet::addSheet(): Argument #1 ($pSheet) must be of type GFExcel\Vendor\PhpOffice\PhpSpreadsheet\W
    orksheet\Worksheet, PhpOffice\PhpSpreadsheet\Worksheet\Worksheet given, called in /home/ogsonca/public_html/wp-content/plugins/ogs-membership/class-ogs-membership-report.php on line 474 and defined in /home/og
    sonca/public_html/wp-content/plugins/gf-entries-in-excel/build/vendor_prefixed/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php:628
    #0 /home/ogsonca/public_html/wp-content/plugins/ogs-membership/class-ogs-membership-report.php(474): GFExcel\Vendor\PhpOffice\PhpSpreadsheet\Spreadsheet->addSheet(Object(PhpOffice\PhpSpreadsheet\Worksheet\Work
    sheet), 0)

    What do you suggest as a solution?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Doeke Norg

    (@doekenorg)

    Hi @charlesgodwin,

    Sorry to hear this. Unfortunately we were forced to namespace the PHPSpreadsheet library to our own namespace; to avoid collisions with other plugins that use the same dependency. It is therefor not advised to use underlaying packages of the plugin.

    In order to avoid breaking changes for customers who use the old namespaces, we create aliases for the old namespace to the new one. It is possible this is interfering with your plugin.

    Could you test if removing the creation of these aliases fixes your problem? (it can be removed from the main GravityExport Lite plugin file).

    If that works, please let me know; I can make these aliases optional.

    We do check if the classes can be aliased; which probably means our plugin is loaded before the other one.

    So, maybe you can change the order of which they are included?

    In any case, if you have influence on the CBX plugin, that should probably also scope PHPSpreadsheet into their own name space. The problem that can arise, and has arisen, is that multiple versions of the same library are active. And those can conflict with each other. Therefor a custom namespace is best to avoid those collisions.

    Thread Starter charlesgodwin

    (@charlesgodwin)

    thanks for the advice. It may be a couple of days before I can test your suggestions but I will let you know

    Thread Starter charlesgodwin

    (@charlesgodwin)

    I was able to test.

    First, I ensured I had latest version of CBX plugin.
    Then I made a one change in GravityExport Lite.
    before
    gfexcel.php:64: $is_build = true;
    after
    gfexcel.php:64: $is_build = false;
    My plugins now work as before.
    I also tested GravityExport Lite?and it too works.

    Thank you. I can’t advise a permanent fix, but this will do for now and we’ll make sure GravityExport Lite?plug in is not autoupdate.

    Plugin Author Doeke Norg

    (@doekenorg)

    @charlesgodwin this is not advisable. By changing that parameter, gravityexport-lite is now dependent on the CBX plugin. It may also have unforseen side effects. Also, gravity export (pro) will not work this way.

    I’ll try to reproduce this myself and come with a fix that will work, while keeping gravity export lite up to date.

    Thread Starter charlesgodwin

    (@charlesgodwin)

    Have you made any progress on this? Thanks

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @charlesgodwin,

    I’m sorry but unfortunately I haven’t had a chance to look into this. If your previous solution doesn’t work anymore with the latest release you can try and change if ( $is_build ) { to if ( false ) {. This will avoid the declaring of the class aliases.

    I do believe this problem lies more in the other plugin, as they are not scoping the PHP spreadsheet dependency.

    I can (maybe) only fix the incompatibility to our plugin, but they can fix it against every plugin. And I think that is a better solution.

    Thread Starter charlesgodwin

    (@charlesgodwin)

    thanks. Currently the fix described is still working. I’ll work with the other plugins and see if I can get them to all play nice together

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘This plugin is incompatible with CBX PhpSpreadSheet Library’ is closed to new replies.