CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Language and Locality »
  • UK Users Group (Moderator: Michael McAndrew) »
  • Issue with GiftAid module: Fatal error: Using $this when not in object context
Pages: [1]

Author Topic: Issue with GiftAid module: Fatal error: Using $this when not in object context  (Read 7633 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Issue with GiftAid module: Fatal error: Using $this when not in object context
August 06, 2012, 11:24:15 pm
I am running the GiftAid module under CiviCRM 4.1.5 with Drupal 6.x. When trying to save a new contribution, I get the following error:

Fatal error: Using $this when not in object context in /home/dev6/public_html/sites/all/modules/civicrm/CRM/Utils/Hook/Drupal6.php on line 58

Has anyone seen this error before? Or have ideas on what to investigate?
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 07, 2012, 04:59:48 am
Not that familiar with giftaid module any more, but from where that error message is coming from it doesn't look like a massively GiftAid specific error.

I'm guessing it is because it is being called statically, and not from an object instance.  might want to turn on backtrace to see if/where CRM_Utils_Hook_Drupal6::invoke() is getting called from.

Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 07, 2012, 05:41:55 am
Debugging/backtrace is turned on. But I only get that 1 line error message.

The moment I disable the GiftAid Drupal module, the problem goes away.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 07, 2012, 01:42:17 pm
i think the key is finding out where/how that is getting called. i think there are some other backtrace tools in php that you could use to help you find out how you got to that place in the code.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 07, 2012, 08:51:31 pm
Added some debugging directly to the code.  The following is being reported:

Code: [Select]
Hook.php(91) : eval()'d code   1   invoke ()   -- /home/dev6/public_html/sites/all/modules/civicrm_giftaid/GiftAid/Utils/
Hook.php   91   eval ()   -- /home/dev6/public_html/sites/all/modules/civicrm_giftaid/GiftAid/Utils/
GiftAid.php   80   alterDeclarationQuery ()   -- /home/dev6/public_html/sites/all/modules/civicrm_giftaid/GiftAid/Utils/
GiftAid.php   132   getDeclaration ()   -- /home/dev6/public_html/sites/all/modules/civicrm_giftaid/GiftAid/Utils/
civicrm_giftaid.module   110   setDeclaration ()   -- /home/dev6/public_html/sites/all/modules/civicrm_giftaid/
Hook.php   132   civicrm_giftaid_civicrm_custom ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Utils/
Drupal6.php   67   runHooks ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Utils/Hook/
Hook.php   276   invoke ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Utils/
CustomValueTable.php   243   custom ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/BAO/
CustomValueTable.php   341   create ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/BAO/
Contribution.php   264   store ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Contribute/BAO/
Contribution.php   1598   create ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/
Form.php   250   postProcess ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/
Upload.php   154   mainProcess ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/
Upload.php   131   realPerform ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/
Controller.php   203   perform ()   -- /home/dev6/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/
Page.php   103   handle ()   -- /home/dev6/public_html/sites/all/modules/civicrm/packages/HTML/QuickForm/
Controller.php   292   handle ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/
Tab.php   267   run ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Contribute/Page/
Tab.php   325   edit ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Contribute/Page/
Invoke.php   245   run ()   -- /home/dev6/public_html/sites/all/modules/civicrm/CRM/Core/
civicrm.module   381   invoke ()   -- /home/dev6/public_html/sites/all/modules/civicrm/drupal/
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 08, 2012, 06:28:53 am
does that help you debug the issue? are you familiar with what the error message means? changing how the object method is called e.g. use parent:: rather than $this-> in http://svn.civicrm.org/civicrm/trunk/CRM/Utils/Hook/Drupal6.php *might* help http://php.net/manual/en/keyword.parent.php
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 11, 2012, 06:43:22 pm
I modified the file "sites/all/modules/civicrm/CRM/Utils/Hook/Drupal6.php" as suggested:

I changed the line
 return $this->runHooks($allModules, $fnSuffix,
      $numParams, $arg1, $arg2, $arg3, $arg4, $arg5
    );

to use 'parent' instead, ie
 return parent::runHooks($allModules, $fnSuffix,
      $numParams, $arg1, $arg2, $arg3, $arg4, $arg5
    );


And this worked like charm!!     But what I am concerned about is the impact of changing this core CiviCRM file on features/functionality outside of the GiftAid.    Should this be patched in Core?
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
August 24, 2012, 05:52:03 am
since the runHooks() method in http://svn.civicrm.org/civicrm/trunk/CRM/Utils/Hook.php does not itself need anything from outside itself, i don't think there would be a problem in calling it 'statically'.

I would file a patch with link to this forum post and submit it for QA.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Issue with GiftAid module: Fatal error: Using $this when not in object context
September 24, 2012, 06:16:29 am
Quote from: Sarah Gladstone on August 06, 2012, 11:24:15 pm
I am running the GiftAid module under CiviCRM 4.1.5 with Drupal 6.x. When trying to save a new contribution, I get the following error:

Fatal error: Using $this when not in object context in /home/dev6/public_html/sites/all/modules/civicrm/CRM/Utils/Hook/Drupal6.php on line 58

Has anyone seen this error before? Or have ideas on what to investigate?

Hi Sarah,

I've seen the same error with D6 / Civi 4.1.5 . The problem in this case was that the Gift Aid code was an old version. Using the Civi 4.1 code from http://svn.civicrm.org/tools/branches/v4.1/drupal/modules/civicrm_giftaid , amended for Drupal 6 instead of 7, got rid of the error, without changing core Civi files.

This issue is for the D7 / Civi 4.1 version: http://issues.civicrm.org/jira/browse/CRM-9750
This one is for D6 or D7 / Civi 4.2: http://issues.civicrm.org/jira/browse/CRM-10704 .
I took the D7 / Civi 4.1 code and applied the D7 -> D6 changes as in the giftaid-4.2-drupal6-fixes patch in CRM-10704. It didn't quite patch cleanly but the changes are small and easy to apply manually.

Dave J

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Language and Locality »
  • UK Users Group (Moderator: Michael McAndrew) »
  • Issue with GiftAid module: Fatal error: Using $this when not in object context

This forum was archived on 2017-11-26.