Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21795 - Avoid fatal error to be displayed in log files. #11712

Merged
merged 1 commit into from
Feb 27, 2018

Conversation

jitendrapurohit
Copy link
Contributor

@jitendrapurohit jitendrapurohit commented Feb 23, 2018

Overview

Fix fatal error - CRM/Utils/System/Drupal.php on line 857

Before

This doesn't occur when we navigate through the site but are recorded silently in the error log files. Maybe, CMS isn't bootstrapped and some function call happens at the backend.

[18-Feb-2018 11:15:00 Pacific/Auckland] PHP Fatal error: Call to undefined function module_invoke_all() in /srv/www/livingstreets/livingstreets.org.nz/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 857
[17-Feb-2018 17:15:27 America/New_York] PHP Fatal error: Call to undefined function module_invoke_all() in /var/www/mainepeoplesalliance/www.mainepeoplesalliance.org/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 857

After

Added a safety check to onCiviExit() function which avoids the fatal error to be recorded.


@@ -853,10 +853,12 @@ public function synchronizeUsers() {
* Similar to drupal_exit().
*/
public function onCiviExit() {
if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
module_invoke_all('exit');
if (function_exists('drupal_session_commit')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it the case that module_invoke_all would also not exist? Just wondering why we skip both parts of this if drupal_session_commit does not exist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie. if feels like separately checking for module_invoke_all makes sense or only checking for module_invoke_all as the first one seems slightly better than just checking for drupal_session_commit - as it stands I feel it needs at least a comment to explain why we skip module_invoke_all if drupal_session_commit doesn't exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logged error was related to module_invoke_all function itself. My thought was to check either of the function just to ensure CMS is bootstrapped which will avoid error to be recorded. Updated the above line to check for module_invoke_all function for readability 👍.

@eileenmcnaughton
Copy link
Contributor

seems fine to me - I think it's intuitive now that the first function implies the second function is not going to work wanna squash them?

@jitendrapurohit
Copy link
Contributor Author

Done @eileenmcnaughton

@eileenmcnaughton
Copy link
Contributor

Ok - this appears safe, sensible & clean now - merge on pass

@seamuslee001 seamuslee001 merged commit e5e6e75 into civicrm:master Feb 27, 2018
@jitendrapurohit jitendrapurohit deleted the CRM-21795 branch February 28, 2018 02:40
@mlutfy mlutfy added this to the 4.7.32 milestone Mar 6, 2018
@mlutfy
Copy link
Member

mlutfy commented Mar 6, 2018

This happens when users visit /sites/all/modules/civicrm/extern/url.php?u=xx&qid=xxxx.

I'm now seeing: PHP message: PHP Fatal error: Call to undefined function drupal_session_commit().

Update: my bad, I had incorrectly applied the patch. Works fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants