Chap 16 – TableGateway Undefined variable key

Home Forums Learn ZF2 Chap 16 – TableGateway Undefined variable key

This topic contains 2 replies, has 2 voices, and was last updated by  Slavey Karadzhov 3 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #564

    Hello everybody,

    When I’m adding a new user in the database, it works fine (the user is saved) except this error :

    Notice: Undefined variable: key in …my_own_application_path…/module/User/src/User/Service/Invokable/TableGateway.php on line 24

    It’s not a typing error as I got the code from the git repo and didn’t change a single character.

    Is this something local or am I missing something? I can’t find the issue.

    Any help to fix this will be welcome.


    Slavey Karadzhov

    Hi Brad,
    If you have the same line like be:

    if(isset($this->cache[$key])) {

    Then you have found a small bug in the code. And I would like to thank toy for this. The line should be changed to:

    if(isset($this->cache[$cacheKey])) {

    I will change the source code in the repository sometime this week to have that fix in it.


    Slavey Karadzhov

    Brad, the fix for the bug that you have found is pushed into the repository. If you want to use the latest source code you have either clone the complete repository and rewind it to the point that you were before, or just copy the TableGateway.php from github ( and replace it with what you have at the moment.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.