Yii2 and PHP (reverse) serialization Stomp Pits

Source: Internet
Author: User
Tags stomp
Yii2 Notes on recording roles

Today writes YII2 RBAC application, intends to simply modify the original about the role of the record, you can switch to the new permissions, and then an error occurred:

    • Unserialize (): Error at offset 127 bytes

After the issue of the permission structure (permission name, role name, type of AuthManager used) is excluded, I think the data for the record role has been changed to a problem. The permission data for the original record is as follows:

    • O:30: "Console\rbac\profileaccessrule": 3:{s:4: "Name"; s:14: "Viewownprofile"; S:9: "Createdat"; I:1460293714;s:9: " Updatedat "; i:1460293714;}

Since it is a serialized array of PHP, the original array, regardless of subscript or value, is serialized in the form of values (strings) whose subscripts are their own length (so it also explains that o:30 refers to Console\rbac\profileaccessrule These words have a total of 30 letters, and the numbers indicate no need to mark their length, such as i:1460293714;). The solution is very simple, mainly the problem of serialization format. The modified permission records are as follows:

    • O:28: "Console\rbac\adminaccessrule": 3:{s:4: "Name"; s:10: "Visitadmin"; S:9: "Createdat"; I:1460293714;s:9: " Updatedat "; i:1460293714;}

Write code this matter, that is to figure out what is inside is a what, and then from the work step by a children ~ hope that these fine-grained problems will not bother us, after all, pondering so long, if not wrong, it is possible to write more innovative code.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the Yii2 and PHP (anti) serialization of the pit, including the yii,php aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.