Project60 / org.project60.sepa

SEPA direct debit integration with civicrm
19 stars 46 forks source link

php-iban.php might be in conflict with other plugins/modules using the same library #622

Open Detsieber opened 2 years ago

Detsieber commented 2 years ago

Within a Wordpress install, we had the strange situation, that some pretty widely used plugin (woocommerce-germanized) includes the same library php-iban.php as CiviSEPA does. It went out, that SEPA online transactions crashed due to a php error:

[12-Jan-2022 12:49:29 Europe/Berlin] PHP Fatal error: Cannot redeclare verify_iban() (previously declared in /html/wordpress/wp -content/plugins/woocommerce-germanized/vendor/globalcitizen/php-iban/php-iban.php:12) in /html/wordpress/wp-content/uploads/civ icrm/ext/org.project60.sepa/packages/php-iban-1.4.0/php-iban.php on line 37

After removing /html/wordpress/wp-content/uploads/civicrm/ext/org.project60.sepa/packages/php-iban-1.4.0/ (as expected), the following error occurs: [12-Jan-2022 16:45:45 Europe/Berlin] PHP Warning: require_once(packages/php-iban-1.4.0/php-iban.php): failed to open stream: No such file or directory in /html/wordpress/wp-content/uploads/civicrm/ext/org.project60.sepa/CRM/Sepa/Logic/Verification.php on line 17

Line 17 of /html/wordpress/wp-content/uploads/civicrm/ext/org.project60.sepa/CRM/Sepa/Logic/Verification.php contains the path for that iban library: require_once 'packages/php-iban-1.4.0/php-iban.php';

As a quick workaround, I commented out the path and instead entered to file from woocommerce-germanized: //require_once 'packages/php-iban-1.4.0/php-iban.php'; require_once '/html/wordpress/wp-content/plugins/woocommerce-germanized/vendor/globalcitizen/php-iban/php-iban.php';

For now, that worked, but it is not nice. Any better idea for an (updatable) solution?

imho, this might also occur with any other wordpress plugin or drupal plugin using that php-iban library.

bjendres commented 2 years ago

Yes, you're right, and the libraries should be included using composer. @Detsieber Could you be able to create a PR?