• After updating to 5.2.x, a PHP warning appears:

    Undefined array key "source" in QRPaymentModule.php on line 869

    Issue: $account['source'] is sometimes undefined.
    Fix: add isset() check before using $account['source'].

    Warning did not appear in version 5.1.10. Please fix.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Martin Svoboda

    (@martinsvoboda)

    Hello,
    This is only a warning for programmers and is not actually an error. Debug mode is enabled on your website, which is why these warnings are displayed. Debug mode should definitely not be enabled in a production environment; it is only used for development purposes and can pose a security risk in production. I therefore recommend turning it off: https://developer.ww.wp.xz.cn/advanced-administration/debug/debug-wordpress/

    However, to make this warning disappear, simply save the QR payment module settings. This will save the new settings and the warning will no longer be displayed.

    Thread Starter bepoostrava

    (@bepoostrava)

    Hello,

    Even with WP_DEBUG off and after saving QR Payment settings, the warning still appears:

    Undefined array key "source" in QRPaymentModule.php on line 869

    Issue: $account['source'] is not always defined. Please add an isset() check before accessing it, e.g.:

    if ( isset($account['source']) && ( ! empty($account['source']) || '0' == $account['source'] ) ) { $bacs_data = $this->get_bacs_account_data( $account['source'] ); }

    Thank you for fixing this.

    Plugin Contributor Martin Svoboda

    (@martinsvoboda)

    Hello,
    Thank you for letting us know.

    The source field is a newly added part of the plugin settings. This key did not exist in older versions, so in rare cases, a warning such as “Undefined array key” may appear after updating.

    However, once the plugin settings page is opened and saved again, the new settings are completely created — and thus the source field is always filled in. From that moment on, it can no longer be undefined.

    To be on the safe side, I added a safety mechanism to the plugin:

    $source = $account['source'] ?? '';
    if ( ! empty( $source ) || $source === '0' ) {

    }

    This will also handle older saved configurations where the field was not yet present.

    The fix will be included in the next update.

    Thread Starter bepoostrava

    (@bepoostrava)

    Hello,

    thank you for the explanation. That makes perfect sense. I’ll wait for the next update with the fix included.

    Thanks again!

    Thread Starter bepoostrava

    (@bepoostrava)

    After updating to 5.2.2, the warning still appears:

    Warning: Undefined array key 1 in wp-content/plugins/wpify-woo/src/Modules/QRPayment/QRPaymentModule.php on line 877

    This issue seems related to missing index checks in the QR Payment module.
    Please add proper isset() or array index validation to prevent this warning.

    The problem persists even after updating to version 5.2.2.

    Plugin Contributor Martin Svoboda

    (@martinsvoboda)

    Hello,

    The last reported warning concerns a different part of the code than the previous one and is caused by an incorrectly entered account number. However, this is again only a warning with no impact on functionality. This warning will be addressed in the next version.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.