Skip to content

Commit

Permalink
Merge branch 'release/4.0.1' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Welch committed May 31, 2022
2 parents a31f7d2 + c1c2b18 commit a3df81b
Show file tree
Hide file tree
Showing 4,072 changed files with 304,851 additions and 201,151 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,18 @@
# SEOmatic Changelog

## 4.0.1 - 2022.05.31
### Added
* Added Schema.org v14 JSON-LD models, generated via [SchemaGen](https://github.com/nystudio107/schemagen) ([#1092](https://github.com/nystudio107/craft-seomatic/issues/1092))

### Changed
* Removed Bing from `SEARCH_ENGINE_SUBMISSION_URLS` due to it being deprecated ([#1043](https://github.com/nystudio107/craft-seomatic/issues/1043))

### Fixed
* Don't allow the autocomplete object inspection to recurse infinitely, set a cap of 10 levels deep ([#1132](https://github.com/nystudio107/craft-seomatic/issues/1132))

### Fixed
* Ensure the constant `Seomatic::SEOMATIC_PREVIEW_AUTHORIZATION_KEY` has `public` access

## 4.0.0 - 2022.05.16
### Added
* Initial Craft CMS 4 release
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "4.0.0",
"version": "4.0.1",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 2 additions & 2 deletions src/Seomatic.php
Expand Up @@ -110,12 +110,12 @@ class Seomatic extends Plugin

public const DEVMODE_CACHE_DURATION = 30;

public const SEOMATIC_PREVIEW_AUTHORIZATION_KEY = 'seomaticPreviewAuthorizationKey';

protected const FRONTEND_SEO_FILE_LINK = 'seomatic/seo-file-link/<url:[^\/]+>/<robots:[^\/]+>/<canonical:[^\/]+>/<inline:\d+>/<fileName:[-\w\.*]+>';

protected const FRONTEND_PREVIEW_PATH = 'seomatic/preview-social-media';

protected const SEOMATIC_PREVIEW_AUTHORIZATION_KEY = 'seomaticPreviewAuthorizationKey';

// Static Properties
// =========================================================================

Expand Down
31 changes: 20 additions & 11 deletions src/helpers/Autocomplete.php
Expand Up @@ -87,6 +87,8 @@ class Autocomplete
'Variable' => 4,
];

const RECURSION_DEPTH_LIMIT = 10;

// Public Static Methods
// =========================================================================

Expand All @@ -110,7 +112,7 @@ public static function generate($additionalCompletionsCacheKey = null): array
$type = gettype($value);
switch ($type) {
case 'object':
self::parseObject($completionList, $key, $value);
self::parseObject($completionList, $key, $value, 0);
break;

case 'array':
Expand Down Expand Up @@ -155,24 +157,30 @@ public static function generate($additionalCompletionsCacheKey = null): array
* @param array $completionList
* @param string $name
* @param $object
* @param int $recursionDepth
* @param string $path
*/
public static function parseObject(array &$completionList, string $name, $object, string $path = '')
public static function parseObject(array &$completionList, string $name, $object, int $recursionDepth, string $path = '')
{
// Only recurse `RECURSION_DEPTH_LIMIT` deep
if ($recursionDepth > self::RECURSION_DEPTH_LIMIT) {
return;
}
$recursionDepth++;
// Create the docblock factory
$factory = DocBlockFactory::createInstance();

$path = trim(implode('.', [$path, $name]), '.');
// The class itself
self::getClassCompletion($completionList, $object, $factory, $name, $path);
// ServiceLocator Components
self::getComponentCompletion($completionList, $object, $path);
self::getComponentCompletion($completionList, $object, $recursionDepth, $path);
// Class properties
self::getPropertyCompletion($completionList, $object, $factory, $path);
self::getPropertyCompletion($completionList, $object, $factory, $recursionDepth, $path);
// Class methods
self::getMethodCompletion($completionList, $object, $factory, $path);
// Behavior properties
self::getBehaviorCompletion($completionList, $object, $factory, $path);
self::getBehaviorCompletion($completionList, $object, $factory, $recursionDepth, $path);
}

// Protected Static Methods
Expand Down Expand Up @@ -222,9 +230,10 @@ protected static function getClassCompletion(array &$completionList, $object, Do
/**
* @param array $completionList
* @param $object
* @param $recursionDepth
* @param $path
*/
protected static function getComponentCompletion(array &$completionList, $object, $path)
protected static function getComponentCompletion(array &$completionList, $object, $recursionDepth, $path)
{
if ($object instanceof ServiceLocator) {
foreach ($object->getComponents() as $key => $value) {
Expand All @@ -235,7 +244,7 @@ protected static function getComponentCompletion(array &$completionList, $object
// That's okay
}
if ($componentObject) {
self::parseObject($completionList, $key, $componentObject, $path);
self::parseObject($completionList, $key, $componentObject, $recursionDepth, $path);
}
}
}
Expand All @@ -247,7 +256,7 @@ protected static function getComponentCompletion(array &$completionList, $object
* @param DocBlockFactory $factory
* @param string $path
*/
protected static function getPropertyCompletion(array &$completionList, $object, DocBlockFactory $factory, string $path)
protected static function getPropertyCompletion(array &$completionList, $object, DocBlockFactory $factory, $recursionDepth, string $path)
{
try {
$reflectionClass = new ReflectionClass($object);
Expand Down Expand Up @@ -347,7 +356,7 @@ protected static function getPropertyCompletion(array &$completionList, $object,
// Recurse through if this is an object
if (isset($object->$propertyName) && is_object($object->$propertyName)) {
if (!$customField && !in_array($propertyName, self::EXCLUDED_PROPERTY_NAMES, true)) {
self::parseObject($completionList, $propertyName, $object->$propertyName, $path);
self::parseObject($completionList, $propertyName, $object->$propertyName, $recursionDepth, $path);
}
}
}
Expand Down Expand Up @@ -451,12 +460,12 @@ protected static function getMethodCompletion(array &$completionList, $object, D
* @param DocBlockFactory $factory
* @param string $path
*/
protected static function getBehaviorCompletion(array &$completionList, $object, DocBlockFactory $factory, string $path)
protected static function getBehaviorCompletion(array &$completionList, $object, DocBlockFactory $factory, $recursionDepth, string $path)
{
if ($object instanceof Element) {
$behaviorClass = $object->getBehavior('customFields');
if ($behaviorClass) {
self::getPropertyCompletion($completionList, $behaviorClass, $factory, $path);
self::getPropertyCompletion($completionList, $behaviorClass, $factory, $recursionDepth, $path);
}
}
}
Expand Down
140 changes: 57 additions & 83 deletions src/models/MetaJsonLd.php
Expand Up @@ -49,105 +49,28 @@ class MetaJsonLd extends NonceItem
*
* @var string
*/
static public $schemaTypeName = 'JsonLd';
static public string $schemaTypeName = 'JsonLd';

/**
* The Schema.org Type Scope
*
* @var string
*/
static public $schemaTypeScope = 'https://schema.org/';
static public string $schemaTypeScope = 'https://schema.org/';

/**
* The Schema.org Type Description
*
* @var string
*/
static public $schemaTypeDescription = 'Generic JsonLd type.';
static public string $schemaTypeDescription = 'Generic JsonLd type.';

/**
* The Schema.org Type Extends
*
* @var string
*/
static public $schemaTypeExtends = '';

/**
* The Schema.org Property Names
*
* @var array
*/
static public $schemaPropertyNames = [];

/**
* The Schema.org Property Expected Types
*
* @var array
*/
static public $schemaPropertyExpectedTypes = [];

/**
* The Schema.org Property Descriptions
*
* @var array
*/
static public $schemaPropertyDescriptions = [];

/**
* The Schema.org Google Required Schema for this type
*
* @var array
*/
static public $googleRequiredSchema = [];

/**
* The Schema.org Google Recommended Schema for this type
*
* @var array
*/
static public $googleRecommendedSchema = [];

// Static Protected Properties
// =========================================================================

/**
* The Schema.org Property Names
*
* @var array
*/
static protected $_schemaPropertyNames = [
];

/**
* The Schema.org Property Expected Types
*
* @var array
*/
static protected $_schemaPropertyExpectedTypes = [
];

/**
* The Schema.org Property Descriptions
*
* @var array
*/
static protected $_schemaPropertyDescriptions = [
];

/**
* The Schema.org Google Required Schema for this type
*
* @var array
*/
static protected $_googleRequiredSchema = [
];
/**
* The Schema.org composed Google Recommended Schema for this type
*
* @var array
*/
static protected $_googleRecommendedSchema = [
];
static public string $schemaTypeExtends = '';

// Public Properties
// =========================================================================
Expand Down Expand Up @@ -248,6 +171,57 @@ public function __toString()
]);
}

/**
* Return the Schema.org Property Names
*
* @return array
*/
public function getSchemaPropertyNames(): array
{
return array_keys($this->getSchemaPropertyExpectedTypes());
}


/**
* Return the Schema.org Property Expected Types
*
* @return array
*/
public function getSchemaPropertyExpectedTypes(): array
{
return [];
}

/**
* Return the Schema.org Property Descriptions
*
* @return array
*/
public function getSchemaPropertyDescriptions(): array
{
return [];
}

/**
* Return the Schema.org Google Required Schema for this type
*
* @return array
*/
public function getGoogleRequiredSchema(): array
{
return [];
}

/**
* Return the Schema.org Google Recommended Schema for this type
*
* @return array
*/
public function getGoogleRecommendedSchema(): array
{
return [];
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -388,10 +362,10 @@ public function validateJsonSchema(
$params
)
{
if (!in_array($attribute, static::$schemaPropertyNames, true)) {
if (!in_array($attribute, $this->getSchemaPropertyNames(), true)) {
$this->addError($attribute, 'The attribute does not exist.');
} else {
$expectedTypes = static::$schemaPropertyExpectedTypes[$attribute];
$expectedTypes = $this->getSchemaPropertyExpectedTypes()[$attribute];
$validated = false;
$dataToValidate = $this->$attribute;
if (!is_array($dataToValidate)) {
Expand Down

0 comments on commit a3df81b

Please sign in to comment.