Skip to content

Commit

Permalink
Fixed #12881 part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Mar 14, 2023
1 parent ac5c4bb commit 3d34607
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/elements/conditions/ElementCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use craft\elements\db\ElementQueryInterface;
use craft\errors\InvalidTypeException;
use craft\fields\conditions\FieldConditionRuleInterface;
use yii\base\InvalidConfigException;

/**
* ElementCondition provides an element condition.
Expand Down Expand Up @@ -62,6 +63,10 @@ class ElementCondition extends BaseCondition implements ElementConditionInterfac
*/
public function __construct(?string $elementType = null, array $config = [])
{
if (!class_exists($elementType) || !is_subclass_of($elementType, ElementInterface::class)) {
throw new InvalidConfigException("Invalid element type: $elementType");
}

$this->elementType = $elementType;
parent::__construct($config);
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/ProjectConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ private function _getElementSourceData(array $sourceConfigs): array
if ($config['type'] === ElementSources::TYPE_CUSTOM && isset($config['condition'])) {
try {
$config['condition'] = $conditionsService->createCondition($config['condition'])->getConfig();
} catch (InvalidArgumentException) {
} catch (InvalidArgumentException|InvalidConfigException) {
// Ignore it
}
}
Expand Down

0 comments on commit 3d34607

Please sign in to comment.