craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.21k stars 624 forks source link

[4.x]: project-config/rebuild wipes out custom condition rule in custom source #13679

Closed wsydney76 closed 12 months ago

wsydney76 commented 12 months ago

What happened?

Description

For our starter project https://github.com/wsydney76/craft4-ddev-starter, there is a custom condition rule https://github.com/wsydney76/craft4-ddev-starter/blob/main/modules/main/conditions/HasDraftsConditionRule.php, attached to a custom element index source, (showing all drafts, regular and provisional, created by the current author):

image

Seems to work fine, but we got reports that this condition disappears once in a while.

Looks like it is reproducable by running craft project-config/rebuild, resulting in this compare from project.yaml :

image

(The code was obviously created back then without in-depth knowledge/docs, so something may be wrong. Should not result in such an error anyway.)

/Karla

Steps to reproduce

  1. Create a custom condition rule type and attach it to a custom element index source
  2. or install our starter :-)
  3. run craft project-config/rebuild

Expected behavior

Nothing changes

Actual behavior

The condition is gone.

Craft CMS version

4.5.3

PHP version

8.1.21

Operating system and version

Linux 5.15.90.1-microsoft-standard-WSL2

Database type and version

MariaDB 10.4.30

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

wsydney76 commented 12 months ago

Ah, looks like this happens because the Condition Rule Type was only registered for CP requests.

Going to close (assuming this behavior is intentional...)

/Karla

brandonkelly commented 11 months ago

Yeah, you’d probably want to adjust that to include it for console requests as well.