How to waste 3 hours on a 5 minute task

Fred's picture

I was recently updating some features of the Missing List, specifically how the UK Postcodes are handled. Due to the nature of the site, it was requested that only certain roles had access to full postcodes not entered by the current user (i.e. only the main Administrator). Everyone else would only get the first part of the postcode (e.g. EC1V instead of EC1V 4PY). This was recently requested to be expanded to include other roles.

"No problem," I thought. "Won't take me long to quickly hack something together and then figure out how to add the ability to use the Roles Permissions form afterwards."

Then I realised that I had not setup my LAMP development environment after a re-install of freshly downloaded Ubuntu Intrepid CD (I had used a DVD from Linux Format, but it had included a load of KDE, XFCE cruft I never used). This time though, I thought ahead and decided to install xDebug as well. Make it a 'proper' dev setup. Who knows, maybe I'll finally work out how to use SVN or git later?!

Following the guidlines on the NetBeans site, I now have a working xDebug setup. Sweet. I hacked together a not very pretty but works in the meantime solution. Tested for logged in people. Tested it for various user roles, all seemed to be working as intended. Logged out. unregistered users could see the full postcode. Hmmm, okay. Let's see how xDebug works.

Clicked the Debug Project button in Netbeans, ran through options, site up and running. Set breakpoint in postcode function. View an appeal with a postcode - breakpoint Is ignored. WTF? What use is a debugger that ignores breakpoints! Logged in. Refreshed page with postcode - breakpoint is acknowledged, code halts at right point! Now I'm seriously confused. HTH does a debugger know or care if I'm logged in on a website?

I changed code, moved breakpoints, did everything I could think of. Debugger failed to kick in if I was not logged in.

Then it hit me. I had updated the local Dev DB with the latest dump of the Live DB. As the site was live, cacheing is enabled. This feature setting, as with all settings, is stored in the DB. I installed the Dev module and flushed the cache using Opera. Back in Firefox, my anonymous session now used the updated function! Only it would do it once per appeal. Reading the small print, Cacheing only affects anonymous users.

After turning off the cache feature, the page is regenerated every time the page is requested. Yay! Only I have now wasted so much time 'fixing' a non-issue, I will have to return to the Role Permissions enhancement for the Postcode Formatting function tomorrow.

Update:

I canno believe how simple it is to add Roles based permissions! I have added a complete step-by-step guide on my wiki.

0
Your rating: None