ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: emanuele on May 28, 2022, 10:42:12 am

Title: Admin menu disappearing
Post by: emanuele on May 28, 2022, 10:42:12 am
And this is quite a nice one if I can say so myself.

Okay, so I have no idea what kind of permissions we have set up here on my account, so we start with uncertainty already.
I think it is a moderator with permission to change permissions?
Anyway, normally I have the admin button visible with "Administration Center", "Permissions" and "Moderate" visible.

If I start in quick reply and hit preview, when I end up in the post page, the "admin" menu disappears. :grimacing:
Title: Re: Admin menu disappearing
Post by: Spuds on May 28, 2022, 06:32:55 pm
There are some odd issues and I think they are all related to the User:: change that was made.

For example, after making a post, the upper menu does not show your profile and I think some other things, as if it did not reload permissions so reverts to guest level, at least until you refresh.   I've not been able to track that one done, but it sounds similar to what you are saying.

For example I hit preview, now there is no profile button above, but there are other top menu items are there.

If you can determine where that is happening, it would be :cool:  :sparkles: :fireworks:
Title: Re: Admin menu disappearing
Post by: emanuele on May 29, 2022, 04:44:30 am
hmm... that is interesting.
I'll try to have a look, I was expecting to have weird side-effects from this change because the thing was so intricate that looked like a pile of... mess. :D
TBH I'm kind of surprised this is just it. :o
Title: Re: Admin menu disappearing
Post by: emanuele on June 15, 2022, 06:08:28 pm
Well... to look into this I started installing on windows and... createDirectory is broken because it loses the drive part of the path and everything goes down the drain... :sob:
Title: Re: Admin menu disappearing
Post by: Spuds on June 15, 2022, 07:18:43 pm
Who uses windows ?? :eyes:
Title: Re: Admin menu disappearing
Post by: emanuele on June 16, 2022, 02:40:04 am
heh

You have no idea how painful it is to move from a system with 4TB of space to one with 1. :laughing:
And... I'm having troubles with this darn dual screen configuration and the fact that I can't get it to read the temperature of the CPU or the GPU... :-\

Anyway right now I have only to migrate the database... wait a moment, why the heck should I move the development stuff to the new system, I'll just keep it where it is now and mount it as a network thingy! :tada:
Title: Re: Admin menu disappearing
Post by: radu81 on June 16, 2022, 03:07:07 am
Emanuele  + >90% of the world  8)
Title: Re: Admin menu disappearing
Post by: Spuds on June 16, 2022, 08:49:27 am
:rofl: .... Conformists :tongue: Specifically meant run/install the software on IIS, but I guess it could be a LAMP stack that was not using windows Linux subsystem, you know the things you have to do when you don't have a real OS !
Quote from: emanuele – You have no idea how painful it is to move from a system with 4TB of space to one with 1
My dev system is only 1/2 TB, but I do have 8TB network mounted storage / docker containers, that is where all the data lives.  Going that route  makes swapping computers a lot easier.  I wish I had a nice GPU but I'm in the stone age when it comes to graphics, no way to mine for bitcoin !
Title: Re: Admin menu disappearing
Post by: emanuele on June 16, 2022, 03:45:39 pm
That's somehow where I'd like to go too, yeah.
The annoying thing is I wanted to use my old pc as server, but it consumes about 90W of power just to stay on... :-\
Title: Re: Admin menu disappearing
Post by: Spuds on June 16, 2022, 07:36:29 pm
Quote from: emanuele – consumes about 90W of power just to stay on
That is a bit, mine pulls 35W-40W in "idle", but can get up to ~150W when under a heavy load, which is almost never.  It lacks any GPU, and has a old Xeon processor, basic raid controller,  mostly a NAS with fast I/O so does what I need it to do. 
Title: Re: Admin menu disappearing
Post by: emanuele on June 18, 2022, 07:24:37 am
Okay, I couldn't reproduce it locally, so either is linked to some particular odd permission or it has been fixed.
Title: Re: Admin menu disappearing
Post by: Spuds on June 18, 2022, 08:17:15 am
Strange, it still does it on my local. 

Start a new topic, save, and then when I'm returned to the display page, admin and profile buttons are missing. :construction:
Title: Re: Admin menu disappearing
Post by: Spuds on June 18, 2022, 08:27:07 am
Looking again, my admin button changes to moderate, and my profile button disappears
Title: Re: Admin menu disappearing
Post by: emanuele on June 18, 2022, 03:53:11 pm
Weird.
At that point I ave the suspect it may be some kind of difference due to how windows and linux deal with something...
Title: Re: Admin menu disappearing
Post by: Spuds on June 18, 2022, 07:28:15 pm
Since it does it on this site, feel free to use it as a debug :race_car:
Title: Re: Admin menu disappearing
Post by: Spuds on June 20, 2022, 04:42:54 pm
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.
Title: Re: Admin menu disappearing
Post by: emanuele on June 20, 2022, 06:21:33 pm
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:
Title: Re: Admin menu disappearing
Post by: Spuds on June 20, 2022, 06:38:06 pm
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!
Title: Re: Admin menu disappearing
Post by: Spuds on June 21, 2022, 09:57:04 am
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
Title: Re: Admin menu disappearing
Post by: emanuele on June 21, 2022, 03:57:14 pm
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