1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Trophy cron job awards trophy for all unknown rules

Discussion in 'Resolved Bug Reports' started by Rigel Kentaurus, Nov 11, 2010.

  1. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    Today I was working on implementing new Trophy rules (for example, time the user spends browsing in the forum, has replied (a lot) to a single thread, thropies based off forumid, logging in 3 days in a row at midnight .., lots of goodies.

    I added the trophy to the trophies table, with a different criteria. Problem is, since my criteria is a non-understood one, now the cron jobs picks it up and approves the trophy. I guess when the rule is not matched in the switch case, it just falls back to "return true" meaning "match".

    I suggest something like this on Criteria.php

    switch ($criterion['rule'])
      return false;
    With the current implementation, if the criterion does not match any known rule, it defaults to true, which means the trophy is awarded. I do not want that, my impression is that if the cron jobs encounters an unknown rule it most likely mean it is used by other addon and it should ignore that trophy since it doesn't know how to interpret that.
  2. Lawrence

    Lawrence Well-Known Member

    It is done that way for efficiency. If one of the known criteria is not matched, break out of the check as quick as possible, and if they all do match, then award a trophy. Create a load class listener and when the XenForo_Helper_Criteria class is loaded, have your listener extend the function with your own set of criteria (just remember to call the parent function first to check if a true condition was returned).
  3. anotheralias

    anotheralias Well-Known Member

    Wow, that would be a wonderful Mod to have. Hint hint. :)
  4. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    Lawrence, this is not an efficiency or criteria problem at all. It is the cron job assuming all unknown rules as passing.

    Say I override the Criteria, say I make my mod work, that is not the problem.

    Then, some day, I disable the mods for some reason (performance, debugging, an upgrade), the cron job fires as usual and approves ALL the trophies for everybody.

    That would be a serious bug.
    Jurhum likes this.
  5. Mike

    Mike XenForo Developer Staff Member

    That's a reasonable point, changed.

Share This Page