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

Fatal PHP Error with Civi Core 5.47 #848

Open
pbarmak opened this issue Mar 7, 2022 · 8 comments
Open

Fatal PHP Error with Civi Core 5.47 #848

pbarmak opened this issue Mar 7, 2022 · 8 comments

Comments

@pbarmak
Copy link

pbarmak commented Mar 7, 2022

I was testing an upgrade to Civi Core 5.47 due to an issue with another extension. When I upgraded core, almost every page stopped displaying data. I didn't see any errors in the Civi log, but found this in the apache error log. I know CiviCase may not yet be tested for 5.47, but thought I'd open the issue so you all can review it (maybe it's something quick to fix, not sure). Unfortunately, this means we cannot upgrade core for now and resolve issues with other extensions we use.

Apache error log:
[Mon Mar 07 07:52:38.209706 2022] [php7:error] [pid 520589] [client 104.173.5.77:50085] PHP Fatal error: Cannot make static method CRM_Contact_BAO_Query_Interface::from() non static in class CRM_Civicase_BAO_Query_ContactLock in /var/www/xxx/sites/default/files/civicrm/ext/uk.co.compucorp.civicase/CRM/Civicase/BAO/Query/ContactLock.php on line 21, referer: https://xxx/civicrm/case?reset=1

@larnoult
Copy link

Same issue here, running WordPress 5.9.2; I'm using coopsymbiotic's fork for Wordpress.

@pbarmak
Copy link
Author

pbarmak commented Mar 25, 2022

@larnoult and anyone else seeing this, I think I have a workaround for this issue for now. It seems like a quick fix, the function declarations just need changing (I'm guessing Core changed to static functions, so this extension needs to change to static as well). Below is a diff of the page. All you need to do is change "public function ..." to "public static function ..." for a couple of the function declarations ("from" and "where"). Just changing those two lines seems to work for our site.

I don't know the process to submit fixes or commit changes via github, apologies for that. If devs want to walk me through that process, I'm happy to follow it. For now, here is the diff output:

diff --git a/CRM/Civicase/BAO/Query/ContactLock.php b/CRM/Civicase/BAO/Query/ContactLock.php
index 19097a9b..bfd3c779 100644
--- a/CRM/Civicase/BAO/Query/ContactLock.php
+++ b/CRM/Civicase/BAO/Query/ContactLock.php
@@ -18,7 +18,7 @@ class CRM_Civicase_BAO_Query_ContactLock extends CRM_Contact_BAO_Query_Interface
   /**
    * Alters from statement to include case locks.
    */
-  public function from($fieldName, $mode, $side) {
+  public static function from($fieldName, $mode, $side) {
     if ($fieldName == 'civicase_contactlock') {
       $loggedContactID = CRM_Core_Session::singleton()->getLoggedInContactID();

@@ -38,7 +38,7 @@ class CRM_Civicase_BAO_Query_ContactLock extends CRM_Contact_BAO_Query_Interface
   /**
    * Alters where statement to include case locks.
    */
-  public function where(&$query) {
+  public static function where(&$query) {
     if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_ACTIVITY) {

       $query->_where[0][] = CRM_Contact_BAO_Query::buildClause("activity_lock", 'IS NULL');

pbatroff added a commit to pbatroff/uk.co.compucorp.civicase that referenced this issue Jul 8, 2022
@masetto
Copy link

masetto commented Aug 12, 2022

@pbarmak has a pull request been created for this?

@pbarmak
Copy link
Author

pbarmak commented Aug 12, 2022

@masetto I didn't create one, no. I wasn't sure how to do all that at the time, just knew where to find the code. Thanks.

@masetto
Copy link

masetto commented Aug 12, 2022

@pbarmak you should create a pull request as describer [https://docs.civicrm.org/dev/en/latest/tools/git/#pr-submit]
I think the better is to create a specific branch only with the relavant change.
Can you try? Otherwise I would have to do it, but you already have! ;-)

pbarmak pushed a commit to pbarmak/uk.co.compucorp.civicase that referenced this issue Aug 13, 2022
@pbarmak
Copy link
Author

pbarmak commented Aug 13, 2022

@masetto I just created the pull request. Thanks for looking into it.

@syxys1
Copy link

syxys1 commented Oct 7, 2022

Running WP 6.0.2, CiviCRM 5.50.1 and Civicase extension 2.9.0 + Bootstrap 1.0.0-beta.11 + Shoreditch WordPress Workarounds 1.0 + UserMenu 1.0.

Same error but also crash when running cron job API group_rebuild. Did not went to see yet if patch made it to v2.9.

@syxys1
Copy link

syxys1 commented Oct 7, 2022

I can confirm that the patch was not part of v2.9. Made the change and it clear the error. But another problem appear. The CiviCRM menu appear briefly and then disappear since I activated the Civicase extension. Will open a new issue

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

No branches or pull requests

4 participants