Sessions::Event::Base sub sub classes do not establish database connections

Sessions::Event::Base has a class level method database_connection_required. Only when a sub class of this class calls this method a database connection gets established in initialize and removed in destroy.

See:

This does not work as expected as I have described in


(TL;DR: class level instance variables do not get inherited but the current code expect that to happen).

These changes were made in commit 75230c3d

/cc @thorsteneckel

Hi @d-j

that is really strange. It’s right Sessions::Event::Base is not using database connections per default. But Sessions::Event::ChatBase which is used for chat events.

For me it looks like you using old files (which normally could not be because if package installation). But to ensure that, can you share lib/sessions/event/*.rb or at least md5sum lib/sessions/event/*.rb?

Thanks!

I use

deb https://dl.packager.io/srv/deb/zammad/zammad/stable/ubuntu 16.04 main

as package source.

I checked and the files in /opt/zammad/lib/sessions/event are the same as in https://github.com/zammad/zammad/tree/stable/lib/sessions/event

Here are the MD5s from my installation:

e18cf342743f0061b58187fcaee09f10  base.rb
400f9702c9c48858e4bdd51c3dcf5b71  broadcast.rb
0a1fbb93c06911a935b9d4f092c3d1b7  chat_agent_state.rb
6fa95853db9a987043f76ee4fd8f337e  chat_base.rb
ccd09ac316710c950e073801516e5a74  chat_session_close.rb
28d7810421ea46f6d725c275065f5891  chat_session_init.rb
312a897515eb7be1b1a137ad90092f15  chat_session_leave_temporary.rb
55086017ed6b24e01940752d7a7ce68d  chat_session_message.rb
c57ecb648b19b841a2330ca33ed758a8  chat_session_notice.rb
3e269bdc571b1b910b1e4c2fd1d129a9  chat_session_start.rb
aad7f3dbd06b5d5d2b2a6f74af2b2c2f  chat_session_typing.rb
c4b1b0b2a1b56c82ff7c6565c1fbc8bb  chat_session_update.rb
905765da167e032221a4f7cc9b8ff529  chat_status_agent.rb
e44fdb8fd7a8837947e8f54034af83b8  chat_status_customer.rb
a47b2228d137706a8b4a99e4b47f1812  login.rb
57c80d433b3b34a8593b565f90f9bbec  maintenance.rb
9d81b1287878e5d0699f8d52f1ec3a94  ping.rb
31668506461f3850b59b8dece5e9fe69  spool.rb
109a14c70a00f50628eb460d07865600  ticket_overview_index.rb
7dfc85e92a58896020f377f0b03d2464  ticket_overview_list.rb
e9dc369370f69eeb53b109e53169979d  who_am_i.rb

Anyways, call zammad run rails c and check for yourself:

Sessions::Event::ChatBase.instance_variable_get(:@database_connection) # => true
Sessions::Event::ChatStatusAgent.instance_variable_get(:@database_connection) # => nil
1 Like

@d-j thanks for the feedback. Now I got it. Your bugfix extended with tests is in CI and will be merged ASAP. :heart_eyes_cat::+1:t2:

1 Like

Update: It’s fixed now in stable (2.7) and develop (upcoming 2.8) now (just update your Zammad package). As reference seed https://github.com/zammad/zammad/issues/2353

Thanks and credits to @d-j !