Skip to main content
Admin menu disappearing Started by emanuele · · Read 19803 times 0 Members and 2 Guests are viewing this topic. previous topic - next topic

Re: Admin menu disappearing

Reply #15

I doing some more debug, just to figure out where this goes sideways.

It has nothing to do with action_post2, you can add a redirect exit to the top of that function and the issue is still there.

Since the profile button disappears, that is a permissions issue, it does know I'm not a guest, however none of the profile perms are loaded so I fail the allowedTo check in menu subs.

As a experiment, I turned off the cache and:man_dancing:  it works fine.  So somewhere in user loader its pulling a cached entry that lacks all the permissions.  This site runs memcache and I had APC on, so its not the engine itself, its what is getting saved or pulled.

Re: Admin menu disappearing

Reply #16

If I enable file-based cache on windows and php 7.4.29, everything is broken.
But if I change:
Code: [Select]
		if ((time() - $cacheTime <= $modSettings['settings_updated'])
|| $menu_buttons = $cache->get('menu_buttons-' . implode('_', $this->user->groups) . '-' . $this->user->language, $cacheTime) === null)
to:
Code: [Select]
		if ((time() - $cacheTime <= $modSettings['settings_updated'])
|| ($menu_buttons = $cache->get('menu_buttons-' . implode('_', $this->user->groups) . '-' . $this->user->language, $cacheTime)) === null)
in themes/default/Theme.php it works again.
So, for sure this has to be changed, though I cannot verify if this is actually the issue here because I hate caches and don't know how to use them, and I have the ftp stuff on the other system (that is still waiting to be restored).:angel:
Bugs creator.
Features destroyer.
Template killer.

Re: Admin menu disappearing

Reply #17

Just gave that fix a try but:crying_cat_face:it did not solve the disappearing buttons after you post, at least with APC enabled.

I recall there were some changes to the cache code, I've not really done much looking at that at all.  I don't even have APC monitor installed to see what the heck its doing, if anything!

Re: Admin menu disappearing

Reply #18

I think I have found the issue.  The problem is in function loadPermissions

If we load from the cache the permissions are directly assigned to User::$info->permissions and the array $permissions is empty.  If the cache is off $permissions is populated and then  User::$info->permissions  gets that value.

That is the difference .. now the problem.  After that we sometimes have to grab the board permissions.  Those are assigned (really appended) to the permissions array which is empty on a cache hit or full when not cached.   At the end of the board permissions check good old  User::$info->permissions  get assigned the permissions array which means on a cache hit it will only contain the board level ones, or if the cache is off, everything.

Quick fix is in the board permissions check change
Code: [Select]
		User::$info->permissions = $permissions;
to
Code: [Select]
		User::$info->permissions += $permissions;

I think I may change things around and just assign User::$info->permissions once at the end so the intent of the code is clear.  Also for some reason (probably debug leftover) the cache TTL is set to 2 seconds for one of the values:rofl:

PS I really like being able to use fenced `'s for inline code:smiling_face_with_3_hearts:

ETA: Here is my proposed fix with some decluttering of the code. https://github.com/Spuds/Elkarte/commit/8f71abd8038b26941e5b79bb5314b1fd5ff30145
Last Edit: June 21, 2022, 10:20:05 am by Spuds

 

Re: Admin menu disappearing

Reply #19

I was looking there as well yesterday evening but then it became quite late and gave up thinking to pick it up today, but you beat me! :P
Bugs creator.
Features destroyer.
Template killer.