Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Code inquiry!

chanhchanh OngETC.com - CMS Researcher ✭✭
edited February 2014 in Vanilla 2.0 - 2.8

I notice in Vanilla master branch and it uses code like this where it assign a string of text into an array element which mapped into a table with the data type of int which very likely to trip the Mysql strict mode where text can't be insert into an int field.

$PermissionModel->Define(array(
   'Garden.Email.View' => 'Garden.SignIn.Allow', (this in particular)
   'Garden.Settings.Manage',
   'Garden.Settings.View',
   'Garden.Messages.Manage',
   'Garden.SignIn.Allow' => 1,
   'Garden.Users.Add',
   'Garden.Users.Edit',
   'Garden.Users.Delete',
   'Garden.Users.Approve',
   'Garden.Activity.Delete',
   'Garden.Activity.View' => 1,
   'Garden.Profiles.View' => 1,
   'Garden.Profiles.Edit' => 'Garden.SignIn.Allow', (this in particular)
   'Garden.Curation.Manage' => 'Garden.Moderation.Manage', (this in particular)
   'Garden.Moderation.Manage',
   'Garden.PersonalInfo.View' => 'Garden.Moderation.Manage', (this in particular)
   'Garden.AdvancedNotifications.Allow'
   ));

I might miss something very obvious but not sure how this code would actually do during setup!

Thank you.

Comments

  • Options
    hgtonighthgtonight ∞ · New Moderator

    And the question is?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    chanhchanh OngETC.com - CMS Researcher ✭✭

    What is the code suppose to do?
    If it suppose to assign the value of 'Garden.SignIn.Allow' to 'Garden.Email.View' then I don't see how it is accomplished.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    Arrays in php can be mixed types. That is, they can be indexless (implicit numerical indexed), numerical indexed, or ask associative. All in the same array.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    chanhchanh OngETC.com - CMS Researcher ✭✭

    I agree about array but the problem it when it is updating the database with wrong type and with strict mode it just cause the setup to "bonk". It took me sometime to figure this out on where it causes the bonk!

  • Options
    hgtonighthgtonight ∞ · New Moderator

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Besides of that, why should anybody do something like that? 'Garden.Email.View' => 'Garden.SignIn.Allow',

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @R_J You mean in context of the framework, or in the context of any development?

    They might be using as a reference to something else later on in the code. Only the person that wrote it could tell you why they did it for this specific situation.

    Non-empty strings evaluate as true when cast to a bool.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    LincLinc Detroit Admin

    When adding new permissions to core, you can assign it the value of an existing permission which it will use as the default assignment for roles. For instance, when we added Garden.Curation.Manage, we wanted all existing moderators to have permission for it without the administrator needing to set it. It doesn't literally set the column to a string.

  • Options
    chanhchanh OngETC.com - CMS Researcher ✭✭

    I don't see any where in the code that do the remapping of the fields. I look at the Define() where it just make the assignment and replace the records which cause the setup to fail immediately when MySQL is set in strict mode.

  • Options
    chanhchanh OngETC.com - CMS Researcher ✭✭

    I found the code that does the substitution so just change this line from 'Garden.Moderation.Manage', to 'Garden.Moderation.Manage' => 0, then it will run just fine when MySQL is set in strict mode.

  • Options

    What does Garden.Email.View do?

Sign In or Register to comment.