Annnndddddddd, fixed

So I mentioned in my last update that I had spotted a validation issue in the admin section of the site, this was to do with creating a person to be tagged to a film. Originally this functionality and feature was only supposed to be used sparingly and was added about half way through building the site. As it turned out I started using it more and more as I was going along, far more than I had anticipated and then ran into an issue. This was to do with using characters with accents and such and took me a while to fix. I was never happy with that fix so then ended up removing my novel way of creating urls from the names and just added in a url field in the db. This sorted my issues and on I went, that is until now.

It all sounds ok and works fine but I did realise that my validation I had added in originally was only for the name field and didn't do anything with the url one... I know I know huge mistake. I had intended to fix this at the time but got sidetracked and forgot (excuses excuses).

So I have went back now and I have implemented extra error checking and validation to that part of the admin so, not only does it now check the name (if it already exists and you submit it wont create a duplicate entry) it also generates the url from the name and puts it into the url box and then also checks to see if a similar url already exists. Sounds complicated, I assure you it is not and makes me look even more foolish that I didn't do it way back when I altered everything.

So I have added double the functionality in there with the error checking, which is great but when I checked the database to see if I had any duplicate url's in it it did bring back 1. This confused me at first as I didn't see how I could have inputted 2 people with the same name seeing as the first part of form check see's if there is already someone with that name in the db.

Turns out the difference was in a full stop in front of the letter of the person's middle name. This allowed the entry or the duplication as it didn't match the original. But here is the great part, the error checking and prevention I have put in place on the url field now will stop this from happening again. as it wont let me submit the form if another url already exists that is the same as the one I want to add in. So the name would have to be similar but not exact (alphabetically)  for you to be able to submit the form. For example the name Adam S Wilson and Adam .S Wilson would both end up with the same url as the letters used in the name are the same in the same order so the url created would match. if it was Adam D Wilson and Adam D Wilson then those both could be added as they are different names.

So thankfully I have fixed this bug and removed the duplicate data as well as putting in place a way to make sure going forward this shouldn't happen again.

>>back<<