User tests: Successful: Unsuccessful:
This is redo #37636
Create a _db
without use of magic __get
.
The magic get
changes behavior of the object A LOT, example if any model have created a property "on fly" it crashes.
Like:
class FooBar{
public function __get($name){ return null; }
}
$c = new FooBar;
$c->_cache[1] = 'foobar';
var_dump($c->_cache[1] ); // Will be NULL instead of "foobar"
That what happen in
joomla-cms/administrator/components/com_modules/src/Model/ModuleModel.php
Lines 676 to 679 in dd91072
Because it is an alternative fix, it still should work as before.
Addittionaly, please test any 3d component, wich use _db
in its model.
As part of #37095
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
hm, how to ignore this in PHPCS?
Property name "$_db" should not be prefixed with an underscore to indicate visibility
@Fedik You can add your file to the list of exceptions here https://github.com/joomla/joomla-cms/blob/4.2-dev/ruleset.xml#L37 or you can put a comment at the top of your file at the same place as here https://github.com/joomla/joomla-cms/blob/4.2-dev/tests/Unit/bootstrap.php#L13 , but of course with another rule:
// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
I would prefer to do it in the XML, but a recent discussion in my closed PR #38168 has shown that at least @HLeithner would prefer to do it in the PHP file but with an explaining comment why it's needed. @laoneo was also involved in the discussion. Maybe they can tell you in which of the 2 ways it shall be done.
Labels |
Added:
?
|
Nope, there need separated fix.
There are a couple of core models which are still using _db like the back end plugins model.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-03-22 10:45:08 |
Closed_By | ⇒ | Fedik |
hm, how to ignore this in PHPCS?