Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Critical
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.5
-
Fix Version/s: 4.5
-
Component/s: WordPress Integration
-
Labels:None
-
Documentation Required?:None
Description
Starting in 4.5.Alpha2 (I think) all event Info, registration and Contribution links became 'broken' causing a php Fatal error. There are no issues in 4.4.6
Example is calling an Event Info link on the sandbox site (logged in as demo user) http://wordpress.sandbox.civicrm.org/?page=CiviCRM&q=civicrm/event/info&reset=1&id=3 This results in the following Error: "Fatal error: Call to undefined function wp_get_current_user() in /home/webeditor/jenkins-node/workspace/buildkit-demos.civicrm.org/build/wp-sandbox/wp-includes/capabilities.php on line 1342"
Also reported in forum.civicrm.org http://forum.civicrm.org/index.php/topic,33585.0.html
The issue is that we seem to be calling in the template file )(example is CRM/Event/Page/EventInfo.tpl a permission check via "if call_user_func(array('CRM_Core_Permission','check'), 'access CiviEvent'" which in turn calls CRM/Core/Permission/WordPress.php This then calls the WordPress function 'current_user_can'. current_user_can relies upon wp_get_current_user, this function is in wp-includes/capabilities.php, but relies on wp-includes/pluggable.php being loaded first.
Somehow we are not calling pluggable.php first.
If we use a shortcode, we end up in a WordPress page and the form displays, but if you click on any links we are back to the Fatal Error.
I have gone through all the commits to civicrm-wordpress and changes to the 3 WordPress.php files and cannot find the cause of this regression. We can 'fix' this by inserting a `require_once...` in CRM/Core/Permission/WordPress.php, but that does not answer what went wrong.
I will create a PR for the above mentioned workaround, but if anyone can track down the actual regression, I'd prefer to fix it there