In the db table toolbar_user there is a line uid=0 and name=set-default. that gets created on module install, i guess? The toolbar is visible even for anonymous users, until I manually change the value in the table to uid=1

Hope that helps.

CommentFileSizeAuthor
#2 toolbar_install_fix.patch439 bytesldweeks

Comments

dankh’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

On toolbar install, example/sample toolbar is created (set-default) and the toolbar is assigned to the user that installed the module. In the most common case ("user 1" installs the module),toolbar_user table has only 1 entry :

uid     | name
------------------------
1       | set-default

The anonymous user has id 0. This is the expected behaviour of the module if you have created a toolbar and enabled it for the anonymous user (uid=0). This is not a bug, the toolbar can be configured to be visible for anonymous users. Also you don't need to manually edit the database record, you can change the per role permissions at admin/settings/toolbar and deactivate the toolbar for anonymous role.


The toolbar is visible even for anonymous users, until I manually change the value in the table to uid=1

What is the context in which you run _toolbar_set_user_toolbar ? Do you provide a valid $user object to _toolbar_set_user_toolbar ? Do the anonymous user can run the action which triggers _toolbar_set_user_toolbar ? If it's not much pain can you paste some code.

Thanks,

ldweeks’s picture

StatusFileSize
new439 bytes

Thanks for your work!

I have run into the same problem. It occurs when the toolbar module is installed via an installation profile. The only custom code that I have that includes anything about the toolbar module is in my installation profile. In my function HOOK_profile_modules, I simply list 'toolbar' as one of the modules that it needs to enable. Thats it.

My guess is that the "user" that is active during a drupal installation is the anonymous user. Here's what I did to test: I noticed that you make a call to _toolbar_set_user_toolbar() from within toolbar_install() in your toolbar.install file. I simply removed the call to _toolbar_set_user_toolbar, and that fixed the issue for me.

I'd recommend that you simply remove those lines from your install file. It means a tiny bit more work for the admin user, but I think it's a better solution.

I've attached a patch...

ldweeks’s picture

Status: Postponed (maintainer needs more info) » Needs review

Sorry... forgot to mark this as needs review.

dankh’s picture

Status: Needs review » Reviewed & tested by the community

I don't know much about installation profile development, but the only reasonable conclusion (as you stated) is that there is no $user available when installation profile enables modules.

There is another question hidden in this issue, do we need default/example profile created on install. I'll create an issue for that.

Patch accepted.

Thanks for your work on this.

dankh’s picture

Version: 6.x-2.2 » 6.x-2.3
Status: Reviewed & tested by the community » Closed (fixed)