New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Still a small issue on ObjectRegistry load aliasing #17620
Comments
The main issue I encounted while trying to fix this is that there are (IMO bad) existing behaviors and tests in place that fail here.. /**
* test loading helpers with dotted aliases
*/
public function testLoadPluginHelperDottedAlias(): void
{
$this->loadPlugins(['TestPlugin']);
$result = $this->Helpers->load('thing.helper', [
'className' => 'TestPlugin.OtherHelper',
]);
$this->assertInstanceOf(OtherHelperHelper::class, $result, 'Helper class is wrong.');
$this->assertInstanceOf(
OtherHelperHelper::class,
$this->Helpers->get('thing.helper'),
'Class is wrong'
); Why would we ever allow a dotted alias? That seems to break thing for no good reason. I fixed up the plugin for now ( dereuromark/cakephp-expose@738e89b ). If we are deadlocked for 5.0, I recommend we clean this up for 5.1? |
That example is indeed a bit of a doozy. I wouldn't mind getting rid of that in 5.1. So if |
I prepared a branch to see the issues we currently have for this: For an easier upgrade path we could also auto-switch existing dots to |
Because it enables usage like
This sounds like a good compromise. We can retain the short alias/classname specifier, and when you use options to define the className you can't use a dotted alias. |
Not exactly, as those are already normalized, even if config array is passed - as long as className is not set. The issue here is with things that are using both at the same time, see my last comment and the linked CI run. |
I just copy the result of the stricter test run here for easier review of the issues remaining:
|
Description
https://github.com/dereuromark/cakephp-expose/actions/runs/8236778340
shows that there is a regression if you load behaviors using
where the config does not contain a
className
key evenApparently, the behavior gets added with alias
'Expose.Superimpose'
instead of'Superimpose'
and thus the code later trying to remove it fails
I guess we need to check for the alias containing a dot and
CakePHP Version
5.0.6
PHP Version
8.2
The text was updated successfully, but these errors were encountered: