User tests: Successful: Unsuccessful:
To be partnered with akeeba/fof#315
You will need to edit the appropriate files in FOF as here: akeeba/fof#315 to libraries/fof/table/behavior/ folder (note this can't be done with patchtester because it will go to the wrong path)
Install https://github.com/wilsonge/restaurant-fof/ Create a restaurant in the backend and save it. Now make a change to the restaurant and save it again and click on the versions button. You'll see several PHP errors.
Now apply #3375
Click on the versions button again and all the versions should appear happily and work as expected
OK Done that.
I did a RuntimeException for the JTableInterface - but our getInstance() method isn't actually in the Interface - so I'm not sure how much it matters - because if you input the wrong params into that method you're still screwed.
I really want to avoid if possible autoloading FOF on every single page. I'd rather load it when we need it if possible :/ So just done a more explicit check for FOF
The way I told you to implement it you are not autoloading FOF. You are only loading the autoloader. Unless you try accessing a FOF* class nothing is loaded. That's what an autoloader is all about. God forbid if we had to load into PHP memory all framework classes every time we wanted to use FOF!
Ahh consider it done then :) How would you feel about adding the getInstance method into JTableInterface?
Title |
|
Title |
|
Title |
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-08-03 16:13:49 |
George, instead of the yucky code you can modify /libraries/cms.php and have it include_once FOF's include.php right after it loads JLoader. You could actually do something like in cms.php:
if (!class_exists('FOFAutoloaderFof'))
{
include_once JPATH_PLATFORM . '/fof/include.php';
}
Moreover, I would change your if-block in contenttype.php to a more elegant two-liner:
$class = isset($tableInfo->special->class)) ? $tableInfo->special->class : 'JTable';
$result = $class::getInstance($tableInfo->special->type, $tableInfo->special->prefix);
It's more generic and doesn't look atrocious. Double win!
PS: If you want to be thorough maybe you can check if $class implements JTableInterface, i.e.
if (!class_implements($class, 'JTableInterface'))
{
// Maybe throw an exception, write something to the log...
}