contao-community-alliance/dc-general

Edit template references non-implemented version model

gmpf opened this issue · 2 comments

gmpf commented

Checklist before I submit this issue report

I confirm that:

My environment is:

Key Value Comments
PHP version: 7.2
Contao version: 4.4.50
DC_General version: 2.1.8 Patches from PR #552 applied
Installation via composer: yes

Issue description

Editing a record based on a DCA that uses versioning causes this exception:

Attempted to call an undefined method named "isCurrent" of class "ContaoCommunityAlliance\DcGeneral\Data\DefaultModel".

Steps to reproduce

  1. Change any DCA that uses versioning to DC_General.
  2. Apply the patches from #552 to even get to this issue.
  3. Edit any record.

Cause/Background

dcbe_general_edit.html5 includes the following code added in b909a20:

<?php foreach($this->versions as $objVersion): /** @var \ContaoCommunityAlliance\DcGeneral\Data\VersionModelInterface $objVersion */ ?>
	<option value="<?php echo $objVersion->getId(); ?>"<?php if($objVersion->isCurrent()): ?> selected="selected"<?php endif; ?>>
	<?php echo $GLOBALS['TL_LANG']['MSC']['version']; ?> <?php echo $objVersion->getVersion(); ?> (<?php echo $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $objVersion->getDateTime()->getTimestamp()); ?>)
	/* ... */
	</option>
<?php endforeach; ?>

$this->versions is assumed to be an instance of VersionModelInterface, however, there is no implementation of that interface. What is actually passed to the template is a DefaultModel.

As this is my first time working with DC_General, this initially caused me to think that versioning support is so far incomplete. However, after applying the fixes provided in PR #552 and reverting the template code to what it was before b909a20, versioning seems to be available without any issue.

As I'm not particularly deep into the DC_General lore, I don't know whether this would be considered a bug or simply a result of versioning support being a work in progress.

Yes, versioning is not fully implemented yet.

We discussed this internally and came to the following conclusions:

  • We disable versioning for 2.1.9 and trigger a warning that the flag is being ignored.
  • We implement the missing parts of version handling in 2.2.0.

We implement the missing parts of version handling in 2.2.0.

=> We implement the missing parts of version handling (probably) in 2.3.0.