With this patch you can select directly a material, don't need to use the index anymore.
I don't think this is the right solution, internally the particle system should still point to some index in the material slots. Otherwise there is no clear way to edit the material in the UI, and the material slots then no longer provide the list of all materials on some object or mesh. Further there is no version patch to keep old files working the same, and no proper initialization of particle materials for rendering of viewport drawing.
I'm not sure what the correct solution would be in this case, or what the person who proposed this quick hack had in mind. You can make some nicer way to choose a material slot, maybe by exposing the integer also as an enum property with dynamically generated items, one for each material slot. This can be done by creating an itemf callback that creates on item for each material slot, for example rna_TextureSlot_output_node_itemf does something similar.
In the UI, if the enum shows a material icon you can set text="". Also if the object has no materials it's probably best to hide the button and show a "No materials." label?
The empty material slots can't be skipped here, they need to be in the list too since it's valid to assign such an empty slot.
Perhaps add tmp.icon = ICON_MATERIAL_DATA; here (at least for non-empty material slots).
Looks good to me, I will commit it together with a fix for particle settings initialization, seems that was 0 instead of 1, showing an empty material menu when adding a new particle system.