Skip to content

CI4: Return of an undefined variable in Token_customer model class #3454

Closed

Description

@objecttothis

Issue / Bug / Question / New Feature

The get_value() function in app/Models/Tokens/Token_customer.php returns $value which is never defined in the function.

image

Activity

  1. linked a pull request that will close this issueUpgrade CI to 4.1.3 (Old) #3271on Apr 1, 2022
  2. jekkos commented on Apr 2, 2022

    @jekkos
    Member

    I wonder if the method is even used then?

  3. objecttothis commented on Apr 4, 2022

    @objecttothis
    MemberAuthor

    I wonder if the method is even used then?

    It's an abstract public function that is declared in Token.php and implemented in each of the child classes including Token_customer.php

    image

    It's called in the replace_token() function in Token.php but replace_token is never called in the code.
    It's called in the Token_lib parse() function
    It's also called in the Token_lib resolve_token() function.

    It only gets to that return statement (return $value;) in one of the below scenarios:

    • There's no customer assigned at the time of function call
    • customer_info is not empty
    • Both

    Seems to me that if the customer_info is not empty we should return that value. If the customer_id is -1 we should return '';

  4. jekkos commented on Apr 5, 2022

    @jekkos
    Member

    Ok thanks for listing all this here @objecttothis .
    I guess the implementation will only kick in once a user uses the variable that resolves to this token. We did not have any bug reports on this but this is obviously broken. I think the solution is as you suggest.

  5. objecttothis commented on Apr 12, 2022

    @objecttothis
    MemberAuthor

    Fixed in #3271

  6. added this to the 3.4.0 milestone on Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions