diff --git a/application/applicationextension.inc.php b/application/applicationextension.inc.php index 0aa141d48..67f3ed6a9 100644 --- a/application/applicationextension.inc.php +++ b/application/applicationextension.inc.php @@ -421,7 +421,7 @@ interface iApplicationObjectExtension * Invoked when an object is updated into the database. The method is called right after the object has been written to the * database. * - * Changes made to the object can be get using {@link $oObject::$m_aChanges}. Do not call {@link \DBObject::ListChanges} for this purpose ! + * Changes made to the object can be get using {@link $oObject::ListChangesUpdated()}. Do not call {@link \DBObject::ListChanges} for this purpose because it will be empty as the object has already be written to DB! * * @param \cmdbAbstractObject $oObject The target object * @param CMDBChange|null $oChange A change context. Since 2.0 it is fine to ignore it, as the framework does maintain this information @@ -429,7 +429,7 @@ interface iApplicationObjectExtension * * @return void * - * @since 2.7.0 N°2293 can access object changes by calling {@link $oObject::$m_aChanges} + * @since 2.7.0 N°2293 can access object changes by calling {@link $oObject::ListChangesUpdated()} */ public function OnDBUpdate($oObject, $oChange = null); diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 70ecea937..859a80ea4 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2396,6 +2396,24 @@ abstract class DBObject implements iDisplay } } + /** + * List the changed attributes that were persisted by an update. + * + * @see \DBObject::ListChanges() use DBObject::ListChanges() if your code is BEFORE the update + * + * @return array + */ + public function ListChangesUpdated() + { + if (empty($this->m_aChanges)) + { + return array(); + } + + return $this->m_aChanges; + } + + /** * Whether or not an object was modified since last read from the DB * (ie: does it differ from the DB ?)