Skip to content
Snippets Groups Projects
Commit 8a16e93c authored by Nikita Hovratov's avatar Nikita Hovratov Committed by Stefan Bürk
Browse files

[BUGFIX] Stabilize AbstractDomainObject _isDirty check

Accessing static properties as non-static has always
triggered a notice in PHP. However, since PHP 8.0
accessing undefined properties (which always comes with
the former notice) is now a warning. This will be
caught by the error handler in debug mode.

To fix this, the more robust _getProperty method is
backported from #100120 and used in the _isDirty method.

Resolves: #101488
Related: #100120
Releases: 11.5
Change-Id: I5f9ccb411f02f0dcc164d0d14917ecd631dc1178
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80280


Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent d50216f5
Branches
Tags
No related merge requests found
......@@ -128,7 +128,9 @@ abstract class AbstractDomainObject implements DomainObjectInterface, ObjectMoni
*/
public function _getProperty(string $propertyName)
{
return $this->{$propertyName};
return $this->_hasProperty($propertyName) && isset($this->{$propertyName})
? $this->{$propertyName}
: null;
}
/**
......@@ -262,7 +264,7 @@ abstract class AbstractDomainObject implements DomainObjectInterface, ObjectMoni
}
}
} else {
if ($this->isPropertyDirty($this->_getCleanProperty($propertyName), $this->{$propertyName}) === true) {
if ($this->isPropertyDirty($this->_getCleanProperty($propertyName), $this->_getProperty($propertyName)) === true) {
return true;
}
}
......
......@@ -133,4 +133,13 @@ class IsDirtyTest extends FunctionalTestCase
$updatedBlogOne = $this->blogRepository->findByUid(3);
self::assertSame($updatedBlogOne->getAdministrator()->getUid(), $blogTwo->getAdministrator()->getUid());
}
/**
* @test
*/
public function undefinedPropertyIsAlwaysClean(): void
{
$blogOne = $this->blogRepository->findByUid(1);
self::assertFalse($blogOne->_isDirty('undefinedProperty'));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment