Jump to content

Scary fluke: Sudden template name change to "1"


joe_g
 Share

Recommended Posts

Hi all,

I just had something scary happening (on my dev server luckily). I was working on an old project that has comparatively lots of data. ~1500 "event" pages, the event template has 30-40 fields. And I added another one, a repeater for a gallery.

Then suddenly, while working on some unrelated front end stuff the 'event' template had been rename to '1', and everything stopped working obviously. When looking at the '1' template it had all fields listed as strings, and not the usual draggable list of fields. I tried renaming it to 'event' again, but I got the prompt that 'event' was already taken. I then renamed it to 'eventa' - that worked, and could then rename it again to 'event'

Now things are back to normal, but I wonder - what happened? It can't be a keyboard slip since renaming a template needs a confirmation.......???

thanks for any insights in this mysterious matter,

j

Link to comment
Share on other sites

If you can build enough discipline in the way you write conditionals, you can avoid this by always putting the constant part first:

if ('xx' == $page->template->name) {

So if you accidentally miss an equals sign and do an assignment, you get an error from the runtime as you are trying to assign to a constant string literal.

I've tried to build this habit over the years and sometimes remember to do this - but I'm not there yet.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...