Please upgrade here. These earlier versions are no longer being updated and have security issues.

Get fatal error after when click enable

This discussion is related to the Q&A addon.
geexisgeexis New
edited May 2014 in Vanilla 2.0 - 2.8

I am getting this "The addon could not be enabled because it generated a fatal error:" when trying to enable it.

Comments

  • LincLinc Director of Development Detroit Vanilla Staff

    What's the error?

  • hgtonighthgtonight ∞ · New Moderator

    If there is no error listed, right click on the enable button and open in a new tab. It should show up then.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • hi, I am getting
    Parse error: syntax error, unexpected T_FUNCTION in /.../forum/plugins/QnA/class.qna.plugin.php on line 415
    Version 2.0.18.11
    and latest v.1.2.1 QnA

  • peregrineperegrine MVP
    edited May 2014

    I don't get the error in 2.1, but I use php 5.3

    Is there any reason why you don't upgrade to 2.1 and php 5.3 as well, eventually you will need to upgrade to 2.1 since it will be phased out in a year and you might as well use 2.1 if you can (alot more features available).
    and php 5.3 and above have more functionality.

       $Comments = $Sender->Data['Comments']->Result();
             $Comments = array_filter($Comments, function($Row) {
                return strcasecmp(GetValue('QnA', $Row), 'accepted');
             });
    

    what version of php do you use? probably more related to php version rather than vanilla version.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • PHP is older than 5.3. Anonymous function support wasn't available until 5.3

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited May 2014

    you might need to change it to something like this for older php

    I haven't tested it...
    change from:

       // Remove the accepted answers from the comments.
          if (isset($Sender->Data['Comments'])) {
             $Comments = $Sender->Data['Comments']->Result();
             $Comments = array_filter($Comments, function($Row) {
                return strcasecmp(GetValue('QnA', $Row), 'accepted');
             });
             $Sender->Data['Comments'] = new Gdn_DataSet(array_values($Comments));
          }
       }
    

    to

                  // Remove the accepted answers from the comments.
                  if (isset($Sender->Data['Comments'])) {
                     $Comments = $Sender->Data['Comments']->Result();
                     $Comments = array_filter($Comments, $this->ReturnValue($Row));
                     $Sender->Data['Comments'] = new Gdn_DataSet(array_values($Comments));
                  }
               }
    
    
         public function  ReturnValue($Row) {
                    return strcasecmp(GetValue('QnA', $Row), 'accepted');
                 }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    hgtonightvrijvlinder
  • yes, I'm thinking about 2.1 but need to check rest of plugins before..
    my previous version 1.0.8b now works just fine

  • peregrineperegrine MVP
    edited May 2014

    once again WHAT PHP version??? are you using.

    even if you upgrade to vanilla 2.1 - you would still get error unless you modify code or upgrade to php 5.3

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited May 2014

    see the changelog on this link.

    http://php.net/manual/en/functions.anonymous.php

    if you download the version check plugin - you can easily see what version of php you have.
    http://vanillaforums.org/addon/versioncheck-plugin

    or type php -v at the command line

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • grungrun New
    edited May 2014

    @peregrine said:
    once again WHAT PHP version??? are you using.

    even if you upgrade to vanilla 2.1 - you would still get error unless you modify code or upgrade to php 5.3

    really 5.2.17!

  • @grun said:

    @peregrine said: even if you upgrade to vanilla 2.1 - you would still get error unless you modify code or upgrade to php 5.3

    really 5.2.17!

    really!

    you should be able to change to 5.3 in cpanel or ask your host.

    or try the code changes I suggested.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @linc - this addon requires php 5.3 yet vanilla requirements are 5.2 for vanilla 2.1 and below !

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • the changes above for 5.2 PHP works fine
    many tnx!!!

    peregrinehgtonight
  • LincLinc Director of Development Detroit Vanilla Staff

    Ah, looks like Todd got a little ahead of things and created a closure. Hm. I think I may need to branch the addons repo.

  • grungrun New
    edited May 2014

    @Linc said:
    I think I may need to branch the addons repo.

    may be its a reasonably for older PHP versions, but I'll try to change for 5.3 anyway
    thanks again!

  • LincLinc Director of Development Detroit Vanilla Staff

    I've branched addons so we can change Q&A to work with 2.1.

    peregrinehgtonightjohntang
  • geexisgeexis New
    edited May 2014

    I am using PHP 5.3 and vanilla 2.1 stable. I was still unable to enable the plug-in

  • peregrineperegrine MVP
    edited May 2014

    @geexis said:
    I am using PHP 5.3 and vanilla 2.1 stable. I was still unable to enable the plug-in

    what version does the q&a plugin say for you @gexis? did you get it from github?

    available from here:
    https://github.com/vanilla/addons/tree/2.1

    If you still get and error:

    for debugging purposes only

    you can enable and force the plugin to TRUE in your config.php by adding the line below or changing tot TRUE (if the line exists).

    $Configuration['EnabledPlugins']['QnA'] = TRUE;

    generally you don't want to force if you are not debugging (if the plugin won't enable via dashboard)

    and also change

    $Configuration['Debug'] = TRUE;

    then report the error you get.

    if you get the same error as above , then make these changes.

    http://vanillaforums.org/discussion/comment/207522/#Comment_207522

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    vrijvlindergeexis
  • I tired this https://github.com/vanilla/addons/tree/2.1 still got error.

    Btw, which file should I place this code, from the link you provided. http://vanillaforums.org/discussion/comment/207522/#Comment_207522

    hgtonight
  • /plugins/QnA/class.qna.plugin.php

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.