Skip to content
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

Show notice for non existent controller property. #12593

Merged
merged 5 commits into from
Sep 26, 2018

Conversation

ADmad
Copy link
Member

@ADmad ADmad commented Sep 24, 2018

@ADmad ADmad added this to the 3.6.12 milestone Sep 24, 2018
@@ -371,6 +371,19 @@ public function __get($name)

list($plugin, $class) = pluginSplit($this->modelClass, true);
if ($class !== $name) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe reverse if and explain:

if ($class === $name) {
   // Autoload table if $name matches controller name
   return $this->loadModel($plugin . $class);
}

// notice

return false; // remove or explicitly return null at 4.x

@markstory
Copy link
Member

Looks like we have a few undefined properties being used by our tests 😢

@ADmad
Copy link
Member Author

ADmad commented Sep 25, 2018

Not really, the error doesn't make sense. It's complaining about missing Controller::$viewClass but that property is available through the ViewVarsTrait.

@garas
Copy link
Member

garas commented Sep 25, 2018

Controller::$viewClass is defined in ViewVarsTrait, but it is unset() after first use.

#12035 I've added an unset() for viewClass to avoid a permanent deprecation warning when RequestHandlerComponent is used.

if ($viewClass === null && $builder->getClassName() === null) {
$builder->setClassName($this->viewClass);
unset($this->viewClass);
}

If second render() tries access value, it is no more available. It should probably leave property set.

@ADmad
Copy link
Member Author

ADmad commented Sep 25, 2018

@garas Good find, I'll adjust the code to mitigate this.

This avoid triggering Controller::__get() on subsequent access to ViewVarsTrait::$viewClass.
@ADmad
Copy link
Member Author

ADmad commented Sep 25, 2018

PHPUnit\Framework\Error\Notice is not available in phpunit 5.7 🙁

@garas
Copy link
Member

garas commented Sep 25, 2018

Add alias in tests/phpunit_aliases.php

@ADmad
Copy link
Member Author

ADmad commented Sep 25, 2018

Meh, took care of it with a class_exists() check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants