Skip to content

Commit

Permalink
Merge branch 'release/5.1.4' into v5
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 29, 2024
2 parents 2d891a0 + f980e55 commit d70c6fd
Show file tree
Hide file tree
Showing 26 changed files with 1,664 additions and 1,215 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SEOmatic Changelog

## 5.1.4 - 2024.09.29
### Fixed
* Normalize the incoming `url` and `path` so that `mergUrlWithPath()` handles edge-cases properly ([#1512](https://github.com/nystudio107/craft-seomatic/issues/1512))
* Fixed an issue where the `ads.txt` wasn't renamed properly when requested via GraphQL ([#1513](https://github.com/nystudio107/craft-seomatic/issues/1513))
* Fixed an issue where the homepage metacontainer cache did not get properly cleared ([#1514](https://github.com/nystudio107/craft-seomatic/issues/1514))
* Fixed an exception caused by the wrong argument passed to `Asset::getAssetById()` in edge cases ([#1515](https://github.com/nystudio107/craft-seomatic/issues/1515))
* Removed vestigial sitemap rendering code in `SitemapTemplate` that had a code path that had a code path that could return a `503` ([#1437](https://github.com/nystudio107/craft-seomatic/issues/1437))

## 5.1.3 - 2024.09.10
### Changed
* Make the Content SEO listings better at eliminating duplicates by pruning sections that no longer exist ([#1499](https://github.com/nystudio107/craft-seomatic/issues/1499))
Expand Down
262 changes: 131 additions & 131 deletions buildchain/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 5. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "5.1.3",
"version": "5.1.4",
"minimum-stability": "dev",
"prefer-stable": true,
"keywords": [
Expand Down
939 changes: 707 additions & 232 deletions docs/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/gql/resolvers/FrontendContainerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function getContainerFiles($source, array $arguments, $context, Re
$typeMap = [
'robots' => 'robots.txt',
'humans' => 'humans.txt',
'ads' => 'humans.txt',
'ads' => 'ads.txt',
'security' => 'security.txt',
];

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ImageTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected static function assetFromAssetOrIdOrQuery($asset, $siteId = null)
return self::$cachedAssetsElements[$resolvedAssetId][$resolvedSiteId];
}

$asset = Craft::$app->getAssets()->getAssetById($asset, $siteId);
$asset = Craft::$app->getAssets()->getAssetById($resolvedAssetId, $siteId);
self::$cachedAssetsElements[$resolvedAssetId][$resolvedSiteId] = $asset;

return $asset;
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public static function siteUrl(string $path = '', $params = null, string $scheme
public static function mergeUrlWithPath(string $url, string $path): string
{
$overlap = 0;
$url = rtrim($url, '/') . '/';
$path = '/' . ltrim($path, '/');
$urlOffset = strlen($url);
$pathLength = strlen($path);
$pathOffset = 0;
Expand Down
48 changes: 5 additions & 43 deletions src/models/SitemapTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,14 @@ public function render(array $params = []): string
$siteId = $params['siteId'];
$page = $params['page'] ?? 0;

// If $throwException === false it means we're trying to regenerate the sitemap due to an invalidation
// rather than a request for the actual sitemap, so don't try to run the queue immediately
$throwException = $params['throwException'] ?? true;

$request = Craft::$app->getRequest();
$metaBundle = Seomatic::$plugin->metaBundles->getMetaBundleBySourceHandle($type, $handle, $siteId);
// If it doesn't exist, throw a 404
if ($metaBundle === null) {
if ($request->isCpRequest || $request->isConsoleRequest) {
return '';
}
if ($throwException) {
throw new NotFoundHttpException(Craft::t('seomatic', 'Page not found.'));
}
return '';
throw new NotFoundHttpException(Craft::t('seomatic', 'Page not found.'));
}
// Check to see if robots is `none` or `no index`
$robotsEnabled = true;
Expand All @@ -143,9 +136,7 @@ public function render(array $params = []): string
if ($request->isCpRequest || $request->isConsoleRequest) {
return '';
}
if ($throwException) {
throw new NotFoundHttpException(Craft::t('seomatic', 'Page not found.'));
}
throw new NotFoundHttpException(Craft::t('seomatic', 'Page not found.'));
}

$cache = Craft::$app->getCache();
Expand All @@ -155,10 +146,8 @@ public function render(array $params = []): string
$cacheKey = self::CACHE_KEY . $uniqueKey;
$result = $cache->get($cacheKey);

// If the sitemap isn't cached, start a job to create it
// Even if it is cached, if $throwException === false we should regenerate it, as it is part of
// an invalidation
if ($result === false || $throwException === false) {
// If the sitemap isn't cached, render it immediately
if ($result === false) {
$sitemap = Sitemap::generateSitemap([
'groupId' => $groupId,
'type' => $type,
Expand Down Expand Up @@ -194,35 +183,8 @@ public function render(array $params = []): string
$plugin->cache->clearAll();
}

// Try it again now
$sitemap = $cache->get($cacheKey);

if ($sitemap !== false) {
return $sitemap;
}
}

// Return a 503 Service Unavailable an a Retry-After so bots will try back later
$lines = [];
$response = Craft::$app->getResponse();
if (!$request->isConsoleRequest && $throwException) {
$response->setStatusCode(503);
$response->headers->add('Retry-After', '60');
$response->headers->add('Cache-Control', 'no-cache, no-store');
// Return an empty XML document
$lines[] = '<?xml version="1.0" encoding="UTF-8"?>';
$lines[] = '<?xml-stylesheet type="text/xsl" href="sitemap-empty.xsl"?>';
$lines[] = '<!-- ' . Craft::t('seomatic', 'This sitemap has not been generated yet.') . ' -->';
$lines[] = '<!-- ' . Craft::t('seomatic', 'If you are seeing this in local dev or an') . ' -->';
$lines[] = '<!-- ' . Craft::t('seomatic', 'environment with `devMode` on, caches only') . ' -->';
$lines[] = '<!-- ' . Craft::t('seomatic', 'last for 30 seconds in local dev, so it is') . ' -->';
$lines[] = '<!-- ' . Craft::t('seomatic', 'normal for the sitemap to not be cached.') . ' -->';
$lines[] = '<urlset>';
$lines[] = '</urlset>';
return $sitemap;
}
$lines = implode("\r\n", $lines);

return $lines;
} else {
if (Craft::$app instanceof ConsoleApplication) {
echo 'Found in cache' . PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions src/services/MetaBundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ public function invalidateMetaBundleByElement($element, bool $isNew = false)
if ($element && $invalidateMetaBundle) {
$uri = $element->uri ?? '';
// Normalize the incoming URI to account for `__home__`
if ($element->slug) {
$uri = ($element->slug === '__home__') ? '' : $uri;
if ($element->uri) {
$uri = ($element->uri === '__home__') ? '' : $uri;
}
// Invalidate sitemap caches after an existing element is saved
list($sourceId, $sourceBundleType, $sourceHandle, $sourceSiteId, $typeId)
Expand Down
798 changes: 798 additions & 0 deletions src/web/assets/dist/assets/dashboard-Br4rtrbC.js

Large diffs are not rendered by default.

Binary file not shown.
1 change: 1 addition & 0 deletions src/web/assets/dist/assets/dashboard-Br4rtrbC.js.map

Large diffs are not rendered by default.

Binary file not shown.
796 changes: 0 additions & 796 deletions src/web/assets/dist/assets/dashboard-CYvLkh4l.js

This file was deleted.

Binary file removed src/web/assets/dist/assets/dashboard-CYvLkh4l.js.gz
Binary file not shown.
1 change: 0 additions & 1 deletion src/web/assets/dist/assets/dashboard-CYvLkh4l.js.map

This file was deleted.

Binary file not shown.
Loading

0 comments on commit d70c6fd

Please sign in to comment.