I'm currenty working on php that page settings and data stored on json file. Which the user able to modify the file, the explanation about the outdated file, if there was 2 user using these function at the same time.
function updateConfig() {
// get
// edit
// save
}
The first user call the first, but just before the first save the file, the second user get the file, which it make the second user get the unmodified file from first user (outdated), so after the the second user modify the file, the first user work will be unsaved or overwrite directly by the second user.
The logic that im understanding that the PHP run in single executable on the server, different with Javascript, that run on users. So the instruction or the code will be executed by its order right? one by one? user by user? the function that i writing are all sync, no async function.
Is there any posibility to this overwriting thing happend? I read few article about PHP multi threading and something similiar but i seems doesnt get the answer, is there any reference that i could ready? or probably some PHP configuration that i could set to prevent this?