0

I am running CiviCRM v5.48.1 with WordPress v5.9.3 and I am writing some functions outside of CiviCRM environment on Wordpress, using this:

<?php

require_once '/home/me/public_html/wp-content/plugins/civicrm/civicrm/civicrm.config.php';
require_once '/home/me/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Config.php';
$civi_config = CRM_Core_Config::singleton();

?>

This call creates the following deprecated function error in the php log:

PHP Deprecated:  Deprecated function CRM_Utils_System::getUrlPath, use CRM_Utils_System::currentPath. in /home/me/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php on line 1043
3
  • This seems like a duplicate of civicrm.stackexchange.com/questions/41780/… Can you clarify how it's a different question please? Commented May 24, 2022 at 8:45
  • No they are not duplicates. The other question is asking HOW to access civicrm functions from external script. In my question, I am already doing that, but I am receiving the PHP DEPRECATED notice in the logs all the time, so was wondering how to get rid of this notice.
    – jsherk
    Commented May 24, 2022 at 13:16
  • The answers are the same, however. Like Aidan said, don't do what you're doing - use CV, WP-CLI or the REST API. Commented May 25, 2022 at 14:05

1 Answer 1

0

Depends what you're doing but try cv.

Don't add any require's or CRM_Core_Config::singleton() stuff. Just write your script and call it with cv scr path_to_your_script. cv takes care of setting up the Civi environment before running your script.

2
  • I could not get CV to work which is why I used the above method instead.
    – jsherk
    Commented May 20, 2022 at 0:29
  • CV is really useful so I'd persevere with getting that to work. Maybe open a separate question about what's not working with cv.
    – Aidan
    Commented May 20, 2022 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.