Talk about how I contributed the source code to laravel

Time:2021-11-25

origin

  • Solutions are always more difficult than difficulties, so finding problems is more difficult than solving them.
  • The origin of the event is that when debugging a model event, a string was casually inserted into the databaseID, not standarduuid。 Then I found that I can’t find the current model eventIDModel of.
  • Of course, we can’t always encounter problems, or we may encounter problems because of our own mistakes. We can go there at this timeLaravelofQuestion bankSee what problems you can solve

progress

  • First eliminate the errors in your own code, and then debug step by step

Talk about how I contributed the source code to laravel
Talk about how I contributed the source code to laravel
Talk about how I contributed the source code to laravel

  • Printed the return variable and foundbelongsToMany::syncMethodIDNot true.

Talk about how I contributed the source code to laravel

  • Further inspection shows that this integer size is very familiar. I think it should be an integer type size overflow. Then I looked at the source codeInteractsWithPivotTable::caseKey

Talk about how I contributed the source code to laravel

  • Basically, it is determined that the integer number overflows. Here, it is simply forced conversion according to the variable type, becausePHPIs a weakly typed language, so when the long character is a numeric string, it will lead to incorrect results.
  • But I have set the primary key type to string in the model, which should not be the result I want.

Talk about how I contributed the source code to laravel

  • Then I put a question to the frameissues
  • LaravelMembers of the organizationtillkrussTell me I can submit onePR
  • Then take action immediately. To be honest, it is very simple to solve this problem, because you only need to obtain the primary key type and then perform strong conversion
  • I submitted the code immediately and was rejected. It turned out that I forgot to write the test code
  • I checked the test code of other databases, found one that is more in line with me, and wrote a database test. Submit. Successfully merged.
  • The specific modified code can be viewed here5.7 Improve the return value of the caseKey method

end

  • First submission for large projectsPR, I really feel that I can’t be so casual.
  • When writing code, please clearly explain the reason for this code. You will find a lot of comments in the framework
  • Don’t forget to write test files
  • When you submitPRPlease describe in detail what changes you have made and what new functions have been added.
  • Express your ideas freely. There are many people in the community who will help you

lastWelcome to laravel learning exchange group, group number: 584453488

Recommended Today

Vue、Three. JS implementation panorama

1、 First, we need to create a Vue project This paper mainly records the process of building panorama in detail, so building Vue project is not described too much. 2、 Install three js npm install three –save npm install three-trackballcontrols –save npm install three-orbit-controls –save npm i three-obj-mtl-loader –save npm i three-fbx-loader –save npm i […]