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.