I spent more time than I should have today debugging an issue (that turned out not to be a bug, just user confusion), due to my confusion resulting from some class inheritance behavior. Simplified, the situation was:
class A extends OurFrameworksControllerLikeClass
{
public function x()
{
// do some stuff, then...
$this->getDataservice()->foo();
// do some more stuff
return $something;
}
// bunch of other methods
}
class B extends A { } // this is not simplified, that's all it did: extended "A"
class C extends B
{
public function x()
{
// do some stuff, then...
$result = parent::x();
// ...do some stuff based on $result
}
}
Where I got confused was that each controller-type class can have a corresponding (singleton) model-like class that is automatically invoked by that getDataservice() method. So when I looked at the line in C::x() that called the parent::x() (from class and saw that class B did nothing but extend class A, I was then reading through A::x(). When it called $this->getDataservice->foo(), I was looking through class A's dataservice to figure out what it was trying to get from the DB, when all along I should have been looking at class B's dataservice. After probably 40-50 minutes of wondering why none of my die()'s in A's dataservice were executing, it finally dawned on me what I was doing wrong. At that point I found the query being executed in class B's dataservice that showed me where the issue was, and all was well (if maybe an hour later than it should have been).
Possibly that's all self-evident to some of you, but I figured it might be worth a giggle at my expense, at least, and might provide a cautionary tale to others.