HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Solved] Parse error: syntax error, unexpected '[' in class.alias.plugin.php on line 64

fh111fh111 ✭✭
edited September 2013 in Feedback

As mentioned in the title this is what I get when trying to activate the plugin. When I take out the "[Alias]" in line 64 I can activate the plugin and it seems to work, but it only shows the most recent alias, not a list of all of them.

using 2.0.18.4 (i know it says 2.0.18.8 as a requirement but i think it should work anyways)

i turned off all other plugins but it does not make a difference

any ideas? thanks

Tagged:

Comments

  • peregrineperegrine MVP
    edited September 2013

    could be your version of php or you added an error to sytax, or

    I did not test it - I merely looked at the code and guessed.

    It is probably not initialzed correctly as an array and it thinks its a string.

    you could try (although some say it is slower - i wouldn't be worried about a microsecond if it works).

    array_push($NewAliasList, $UserName);

    instead of

    $NewAliasList[] = $UserName;
    

    I'd consider changing this code to this for an experiment

    from

     $OldAliasList = unserialize($UserModel->GetMeta($UserID, 'Alias')['Alias']);
          $NewAliasList = $OldAliasList;
          // Append current user
          $NewAliasList[] = $UserName;
    

    to

    $OldAliasList = $NewAliasList = array();
    $NewAliasList = $OldAliasList = unserialize($UserModel->GetMeta($UserID, 'Alias')['Alias']);
      // Append current user
    array_push($NewAliasList, $UserName);
    

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

  • x00x00 MVP
    edited September 2013

    @peregrine @R_J

    I would avoid stuff like this

    $UserModel->GetMeta($UserID, 'Alias')['Alias'];
    

    Instead do

    $AliasMeta = $UserModel->GetMeta($UserID, 'Alias');
    $AliasMeta['Alias'];
    

    grep is your friend.

  • @x00

    sounds good to me.

    It's RJ's plugin not mine. I looked at the code on line 64 and didn't run it it or install it.

    it pointed to this line 64. But @fh111 and I were looking at different versions. i looked at an older version apparently.

    line 64 - $NewAliasList[] = $UserName; // in the version I had downloaded.

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

  • Sorry, don't have time to look at that now. Will try to care for it this weekend

  • thanks guys for looking into it!

  • @fh111
    let us know if you try any of the code changes, and if they solve your problem

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

  • Did some research and I suppose it is a PHP issue. You are using PHP version < 5.4, I assume. Here's a short extract of the PHP manual "As of PHP 5.4 it is possible to array dereference the result of a function or method call directly."

    I'll change the code according to @x00 s suggestion because that should solve your problem, @fh111. Watch out for the new version. I will update it in the next minutes

  • It's done :-)

  • Thanks so much for making it work for me! Just tested it and everything works great. Very neat plugin, happy to have that feature

Sign In or Register to comment.