Ok…. so after trawling through the code for a while, I think I know what happens. And more importantly, how to fix it.
For the first two blocks above, call #4 is to the EE_Core->_initialize_cp() function which contains the block:
// make sure the theme exists, and shunt to default if it does not
// always add default as a fallback.
if ($cp_theme == 'default' OR ! is_dir(PATH_CP_THEME.$cp_theme))
{
$this->EE->load->_ci_view_path = PATH_CP_THEME.'default/';
$cp_theme = 'default';
}
else
{
$this->EE->load->_ci_view_path = array(
PATH_CP_THEME.$cp_theme.'/',
PATH_CP_THEME.'default/'
);
}
This is setting our variable to the array of custom and default CP theme paths.
And then in ‘EE_Accessories->generate_accessories()’ (system/expressionengine/libraries/Accessories.php:50) at line 105 we encounter this:
// switch the view and package path temporarily to the packages's folder
$orig_view_path = $this->EE->load->_ci_view_path;
$this->EE->load->_ci_view_path = PATH_THIRD.strtolower($name).'/views/';
$this->EE->load->add_package_path(PATH_THIRD.strtolower($name).'/');
This occurs immediately before our new Accessory is instantiated, hence the correct &package;=%package_name% in the first two lines of the first HTML block above.
In the problem cases, the function Addons_accessories->index() loads the classes with $ACC = new $accessories[$name][‘class’](); on line 96, which still has the CP value for $this->EE->load->_ci_view_path.
I believe that the above block of code to (as the comment says) “switch the view and package paths temporarily” is what is missing from this particular loading of the class and notably, this same block is used further down this class in the function process_request() when loading the class.
In short, I believe this patch closes this bug:
--- addons_accessories.php.orig 2011-02-13 14:00:45.000000000 +0000
+++ addons_accessories.php 2011-02-13 13:59:54.000000000 +0000
@@ -93,7 +93,14 @@
include $accessories[$name]['path'].$accessories[$name]['file'];
}
+ // add the package and view paths
+ $this->load->add_package_path(PATH_THIRD.strtolower($accessories[$name]['class']).'/');
+ $orig_view_path = $this->load->_ci_view_path;
+ $this->load->_ci_view_path = PATH_THIRD.strtolower($accessories[$name]['class']).'/views/';
$ACC = new $accessories[$name]['class']();
+ // switch the view path back to the original, remove package path
+ $this->load->_ci_view_path = $orig_view_path;
+ $this->load->remove_package_path(PATH_THIRD.strtolower($accessories[$name]['class']).'/');
$accessories[$name]['name'] = $ACC->name;
$accessories[$name]['version'] = $ACC->version;
It’s just a shame it has taken me a full day to track this down for such a simple fix. I guess over time I’ll get to know the EE code better.
/edit:
Note: This doesn’t solve the reason for the member group being named “5”, but I believe that to be unrelated to this error message.