• Resolved techaddicted

    (@techaddicted)


    Hi,

    I’d like to suggest a small change for the WC_AC_Hook class. In the add_integration() method, the file "settings.php" is loaded using include_once() and in the order_status_change() method, the file "sync-contact.php" is loaded using include_once():

    44: include_once '/settings.php';
    109: include_once '/sync-contact.php';

    Using __DIR__ ensures that the path to ‘settings.php’ is always resolved relative to this file’s directory, regardless of the current working directory at runtime. This ensures reliable loading. Using a relative path like '/settings.php' could attempt to include from the wrong location, which happened in my case, the plugin tried to load wp-admin/network/settings.php and resulted in unexpected errors in my case.

    44: include_once __DIR__ . '/settings.php';
    109: include_once __DIR__ . '/sync-contact.php';

    Can this be changed in a future update?
    Thanks!

    • This topic was modified 3 months, 3 weeks ago by techaddicted.
    • This topic was modified 3 months, 3 weeks ago by techaddicted.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author mtreherne

    (@mtreherne)

    Thanks for getting in touch and I’ll update the code to use __DIR__ . ‘/filename.php’ on the next release.

    As I understand it from the php manual “Files are included based on the file path given or, if none is given, the include_path specified. If the file isn’t found in the include_path, include will finally check in the calling script’s own directory and the current working directory before failing.”

    I guess that your ‘wp-admin/network’ directory must be either in the ‘include_path’ or has been set to the current working directory. So the file is found in the wrong location before checking the calling script’s own directory.

    Thread Starter techaddicted

    (@techaddicted)

    Appreciated. 🙂

    FYI: In my previous message I forgot to add that this was happening in a WordPress Multisite environment, so you might be able to replicate the issue in a fresh install.

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

You must be logged in to reply to this topic.