Implementing caching for getRootId() to save queries

The method getRootId() is executed numerous times per page load, for example when editing an article around 20 times. At the same time, that method always returns the same value. By adding a static variable as cache, we save us all those duplicate queries and they are only run once per table.