0

first up, many thanks to all who help out in the Civi community.

I tried upgrading from Civi 4.6.38 to 5.28.0 which failed on the queue runner screen (JS errors).
enter image description here

In the screenshot you can see that the path to assets includes the constant CIVICRM_PLUGIN_URL. This explains the 404 but why hasn't the value of the constant been used? This matches whats in the Apache error log:

[Thu Aug 13 15:44:56.862133 2020] [php7:warn] [pid 19200] [client 109.148.55.130:36242] PHP Warning: Use of undefined constant CIVICRM_PLUGIN_URL - assumed 'CIVICRM_PLUGIN_URL' (this will throw an Error in a future version of PHP) in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php on line 69, referer: https://example.com/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fupgrade&reset=1 [Thu Aug 13 15:44:56.862169 2020] [php7:warn] [pid 19200] [client 109.148.55.130:36242] PHP Warning: file_get_contents(CIVICRM_PLUGIN_DIRcivicrm/extension-compatibility.json): failed to open stream: No such file or directory in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Extension/System.php on line 290, referer: https://example.com/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fupgrade&reset=1

You can see that file_get_contents() is also using the constant. I tailed the civi log file in ConfigAndLog/ but nothing was appended to the log file.

I've restored and tried a few upgrades to work out where the problem begins; its version 5.27.0. Version 5.26.2 is as late as I can go, I've also tried 5.27.4 hoping to pick up a fix to no avail.

I have read version-specific notes and the release notes for 5.2.7:

https://docs.civicrm.org/sysadmin/en/latest/upgrade/version-specific/

https://civicrm.org/blog/dev-team/civicrm-527-release

I have also tried a CLI db upgrade:

wp civicrm upgrade-db

    PHP Warning:  Use of undefined constant CIVICRM_PLUGIN_DIR - assumed 'CIVICRM_PLUGIN_DIR' (this will throw an Error in a future version of PHP) in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php on line 68
Warning: Use of undefined constant CIVICRM_PLUGIN_DIR - assumed 'CIVICRM_PLUGIN_DIR' (this will throw an Error in a future version of PHP) in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php on line 68
PHP Warning:  Use of undefined constant CIVICRM_PLUGIN_URL - assumed 'CIVICRM_PLUGIN_URL' (this will throw an Error in a future version of PHP) in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php on line 69
Warning: Use of undefined constant CIVICRM_PLUGIN_URL - assumed 'CIVICRM_PLUGIN_URL' (this will throw an Error in a future version of PHP) in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php on line 69
PHP Warning:  file_get_contents(CIVICRM_PLUGIN_DIRcivicrm/extension-compatibility.json): failed to open stream: No such file or directory in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Extension/System.php on line 290
Warning: file_get_contents(CIVICRM_PLUGIN_DIRcivicrm/extension-compatibility.json): failed to open stream: No such file or directory in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Extension/System.php on line 290
PHP Warning:  file_get_contents(CIVICRM_PLUGIN_DIRcivicrm/extension-compatibility.json): failed to open stream: No such file or directory in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Extension/System.php on line 290
Warning: file_get_contents(CIVICRM_PLUGIN_DIRcivicrm/extension-compatibility.json): failed to open stream: No such file or directory in /home/user_dev/example.com/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Extension/System.php on line 290

My environment is: Wordpress 5.4.2 Debian Stretch PHP 7.3

In case its helpful files are still in plugins/files/ not the newer location of uploads/

It appears as if the code in civicrm.php which sets up the defines runs too late but that seems very strange. Thanks for reading, I hope this is a well formed question, please let me know if i can improve it.

2

Try adding below lines into civicrm.settings.php file

global $civicrm_paths;
$civicrm_paths['civicrm.root']['path'] = '/path-to-wordpress/wp-content/plugins/civicrm/civicrm/';
$civicrm_paths['civicrm.root']['url'] = 'http://sitename.org/wp-content/plugins/civicrm/civicrm/';
  • Thank you for your answer. I think Civi should be calculating these paths so hard-coding them here may not be future proof. Your answer doesn't explain why the constant isn't replaced with the correct value and that was my question. – axa Aug 14 '20 at 13:12
0

The answer from Pradeep is correct. The documentation is here: https://docs.civicrm.org/sysadmin/en/latest/upgrade/version-specific/#civicrm-5.29

Version 4.6 used a path and URL convention that is no longer in use. I would have expected you to be able to go up to version 5.28 (as I have been) but it's possible you have values stored in the settings table.

I'd add the lines that are detailed above and look to move to the new structure.

You should also flush all caches, CiviCRM, WP, and flush permalinks. This will clear out any problems due to pre-compiled templates where CiviCRM references old cached values.

  • Thanks for your answer and for pointing me to the 5.29 doc. Since I'm trying to upgrade to 5.27 I didn't think the 5.29 warnings would apply yet. Hopefully this will help others. Its still unclear why this is an issue at 5.27. – axa Aug 18 '20 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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