/** * @param AbstractRevision $revision * @return MWTimestamp * @throws Exception * @throws TimestampException * @throws \Flow\Exception\DataModelException */ protected function getUpdateTimestamp(AbstractRevision $revision) { $timestamp = $revision->getRevisionId()->getTimestampObj(); if (!$revision instanceof PostRevision) { return $timestamp; } foreach ($revision->getChildren() as $child) { // go recursive, find timestamp of most recent child post $comparison = $this->getUpdateTimestamp($child); $diff = $comparison->diff($timestamp); // invert will be 1 if the diff is a negative time period from // child timestamp ($comparison) to $timestamp, which means that // $comparison is more recent than our current $timestamp if ($diff->invert) { $timestamp = $comparison; } } return $timestamp; }