Skip to content

Commit

Permalink
Merge branch 'release/3.2.14' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Mar 25, 2024
2 parents 92fa008 + 5bd1f5b commit f974c1c
Show file tree
Hide file tree
Showing 22 changed files with 78 additions and 43 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ jobs:
fail-fast: false
matrix:
actions:
-
name: 'PHPStan'
- name: 'PHPStan'
run: composer phpstan
-
name: 'Coding Standards'
- name: 'Coding Standards'
run: composer fix-cs
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
Expand All @@ -33,7 +31,7 @@ jobs:
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.1
extensions: 'ctype,curl,dom,iconv,imagick,intl,json,mbstring,openssl,pcre,pdo,reflection,spl,zip'
ini-values: post_max_size=256M, max_execution_time=180, memory_limit=512M
tools: composer:v2
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Retour Changelog

## 3.2.14 - 2024.03.25
### Fixed
* Added the unused `static` to the Tailwind CSS `blocklist` to avoid a name collision with a Craft CSS class ([#1412](https://github.com/nystudio107/craft-seomatic/issues/1412))
* Fixed an issue with impropertly text-encoded characters in URLs potentially causing a db exception ([#291](https://github.com/nystudio107/craft-retour/issues/291))
* Fixed an issue where an empty redirect in the `excludePatterns` list could cause redirects to stop functioning, add logging when a redirect is excluded ([#297](https://github.com/nystudio107/craft-retour/issues/297))

## 3.2.13 - 2024.02.05
### Added
* Add `phpstan` and `ecs` code linting
Expand Down
3 changes: 3 additions & 0 deletions buildchain/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default {
'../src/templates/**/*.{twig,html}',
'./src/vue/**/*.{vue,html}',
],
blocklist: [
'static',
],
theme: {},
plugins: [],
};
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-retour",
"description": "Retour allows you to intelligently redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website",
"type": "craft-plugin",
"version": "3.2.13",
"version": "3.2.14",
"keywords": [
"craftcms",
"craft-plugin",
Expand Down Expand Up @@ -32,14 +32,20 @@
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main",
"craftcms/rector": "dev-main",
"codeception/codeception": "^3.0",
"codeception/codeception": "^4.1.29",
"codeception/module-asserts": "^1.3.1",
"codeception/module-datafactory": "^1.1.0",
"codeception/module-phpbrowser": "^1.0.2",
"codeception/module-rest": "^1.4.2",
"codeception/module-yii2": "^1.1.5",
"markhuot/craftql": "^1.0.0",
"vlucas/phpdotenv": "^3.0"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
"fix-cs": "ecs check --fix --ansi",
"test": "codecept run unit --coverage-xml"
},
"config": {
"allow-plugins": {
Expand Down
7 changes: 5 additions & 2 deletions docs/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export default defineConfig({
},
algolia: {
appId: 'PBLZ7FT9Z3',
apiKey: 'ab56b755c575dc94a58f7d1cae6e4e0e',
indexName: 'retour'
apiKey: '953923b236f39535b8553f4143cab98d',
indexName: 'retour',
searchParameters: {
facetFilters: ["version:v3"],
},
},
lastUpdatedText: 'Last Updated',
sidebar: [
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- vendor/craftcms/phpstan/phpstan.neon
- %currentWorkingDirectory%/vendor/craftcms/phpstan/phpstan.neon

parameters:
level: 5
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function actionImportCsvColumns()
if (!ini_get('auto_detect_line_endings')) {
ini_set('auto_detect_line_endings', '1');
}
$csv = null;
$this->requirePostRequest();
$filename = Craft::$app->getRequest()->getRequiredBodyParam('filename');
$columns = Craft::$app->getRequest()->getRequiredBodyParam('columns');
Expand Down Expand Up @@ -137,7 +138,7 @@ public function actionImportCsvColumns()
}
$hasErrors = false;
// If we have headers, then we have a file, so parse it
if ($headers !== null) {
if ($csv && $headers) {
switch (VersionHelper::getLeagueCsvVersion()) {
case 8:
$hasErrors = $this->importCsvApi8($csv, $columns, $headers);
Expand Down
40 changes: 21 additions & 19 deletions src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Craft;
use craft\db\Migration;
use nystudio107\retour\widgets\RetourWidget;
use yii\base\NotSupportedException;

/**
* @author nystudio107
Expand Down Expand Up @@ -71,13 +72,14 @@ public function safeDown()

/**
* @return bool
* @throws NotSupportedException
*/
protected function createTables(): bool
{
$tablesCreated = false;

$tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_redirects}}');
if ($tableSchema === null) {
$tableSchema = $this->getDb()->getSchema()->getTableSchema('{{%retour_redirects}}');
if ($tableSchema) {
$tablesCreated = true;
$this->createTable(
'{{%retour_redirects}}',
Expand All @@ -103,8 +105,8 @@ protected function createTables(): bool
);
}

$tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_static_redirects}}');
if ($tableSchema === null) {
$tableSchema = $this->getDb()->schema->getTableSchema('{{%retour_static_redirects}}');
if ($tableSchema) {
$tablesCreated = true;
$this->createTable(
'{{%retour_static_redirects}}',
Expand All @@ -130,8 +132,8 @@ protected function createTables(): bool
);
}

$tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_stats}}');
if ($tableSchema === null) {
$tableSchema = $this->getDb()->schema->getTableSchema('{{%retour_stats}}');
if ($tableSchema) {
$tablesCreated = true;
$this->createTable(
'{{%retour_stats}}',
Expand Down Expand Up @@ -165,70 +167,70 @@ protected function createTables(): bool
protected function createIndexes()
{
$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_static_redirects}}',
'redirectSrcUrlParsed',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_redirects}}',
'redirectSrcUrlParsed',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_static_redirects}}',
'redirectSrcUrl',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_redirects}}',
'redirectSrcUrl',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_stats}}',
'redirectSrcUrl',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_static_redirects}}',
'redirectMatchType',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_redirects}}',
'redirectMatchType',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_redirects}}',
'siteId',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_static_redirects}}',
'siteId',
false
);

$this->createIndex(
$this->db->getIndexName(),
$this->getDb()->getIndexName(),
'{{%retour_stats}}',
'siteId',
false
Expand All @@ -241,7 +243,7 @@ protected function createIndexes()
protected function addForeignKeys()
{
$this->addForeignKey(
$this->db->getForeignKeyName(),
$this->getDb()->getForeignKeyName(),
'{{%retour_redirects}}',
'associatedElementId',
'{{%elements}}',
Expand All @@ -251,7 +253,7 @@ protected function addForeignKeys()
);

$this->addForeignKey(
$this->db->getForeignKeyName(),
$this->getDb()->getForeignKeyName(),
'{{%retour_static_redirects}}',
'siteId',
'{{%sites}}',
Expand All @@ -261,7 +263,7 @@ protected function addForeignKeys()
);

$this->addForeignKey(
$this->db->getForeignKeyName(),
$this->getDb()->getForeignKeyName(),
'{{%retour_stats}}',
'siteId',
'{{%sites}}',
Expand Down
19 changes: 16 additions & 3 deletions src/services/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use nystudio107\retour\events\RedirectResolvedEvent;
use nystudio107\retour\events\ResolveRedirectEvent;
use nystudio107\retour\fields\ShortLink;
use nystudio107\retour\helpers\Text as TextHelper;
use nystudio107\retour\helpers\UrlHelper;
use nystudio107\retour\models\StaticRedirects as StaticRedirectsModel;
use nystudio107\retour\Retour;
Expand Down Expand Up @@ -706,11 +707,11 @@ public function getStaticRedirect(string $fullUrl, string $pathOnly, $siteId, bo
'or',
['and',
['redirectSrcMatch' => 'pathonly'],
['redirectSrcUrlParsed' => $pathOnly],
['redirectSrcUrlParsed' => TextHelper::cleanupText($pathOnly)],
],
['and',
['redirectSrcMatch' => 'fullurl'],
['redirectSrcUrlParsed' => $fullUrl],
['redirectSrcUrlParsed' => TextHelper::cleanupText($fullUrl)],
],
];

Expand Down Expand Up @@ -860,7 +861,7 @@ public function getRedirectByRedirectSrcUrl(string $redirectSrcUrl, int $siteId
// Query the db table
$query = (new Query())
->from(['{{%retour_static_redirects}}'])
->where(['redirectSrcUrl' => $redirectSrcUrl]);
->where(['redirectSrcUrl' => TextHelper::cleanupText($redirectSrcUrl)]);
if ($siteId) {
$query
->andWhere(['or', [
Expand Down Expand Up @@ -1209,9 +1210,21 @@ public function excludeUri($uri): bool
$uri = '/' . ltrim($uri, '/');
if (!empty(Retour::$settings->excludePatterns)) {
foreach (Retour::$settings->excludePatterns as $excludePattern) {
if (empty($excludePattern['pattern'])) {
continue;
}
$pattern = '`' . $excludePattern['pattern'] . '`i';
try {
if (preg_match($pattern, $uri) === 1) {
Craft::info(
Craft::t(
'retour',
'Excluded URI: {uri} due to match of pattern: {pattern}',
['uri' => $uri, 'pathOnly' => $pattern]
),
__METHOD__
);

return true;
}
} catch (\Exception $e) {
Expand Down
6 changes: 4 additions & 2 deletions src/services/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use craft\db\Query;
use craft\helpers\Db;
use craft\helpers\UrlHelper;
use DateTime;
use nystudio107\retour\helpers\Text as TextHelper;
use nystudio107\retour\models\Stats as StatsModel;
use nystudio107\retour\Retour;
use yii\db\Exception;
Expand Down Expand Up @@ -193,7 +195,7 @@ public function incrementStatistics(string $url, $handled = false, $siteId = nul
// Find any existing retour_stats record
$statsConfig = (new Query())
->from(['{{%retour_stats}}'])
->where(['redirectSrcUrl' => $stats->redirectSrcUrl])
->where(['redirectSrcUrl' => TextHelper::cleanupText($stats->redirectSrcUrl)])
->one();
// If no record is found, initialize some values
if ($statsConfig === null) {
Expand All @@ -211,7 +213,7 @@ public function incrementStatistics(string $url, $handled = false, $siteId = nul
$stats->exceptionMessage = $exceptionMessage;
$stats->exceptionFilePath = $exceptionFilePath;
$stats->exceptionFileLine = (int)$exceptionFileLine;
$stats->hitLastTime = Db::prepareDateForDb(new \DateTime());
$stats->hitLastTime = Db::prepareDateForDb(new DateTime());
$stats->handledByRetour = (int)$handled;
$stats->hitCount++;
$statsConfig = $stats->getAttributes();
Expand Down
1 change: 1 addition & 0 deletions src/translations/en/retour.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@
'Some errors occured .' => 'Some errors occured .',
'Some errors occured importing the CSV file.' => 'Some errors occured importing the CSV file.',
'Select the priority that will determine the order of mathching the redirect.' => 'Select the priority that will determine the order of mathching the redirect.',
'Excluded URI: {uri} due to match of pattern: {pattern}' => 'Excluded URI: {uri} due to match of pattern: {pattern}'
];
1 change: 1 addition & 0 deletions src/web/assets/dist/assets/retour-0lLzocvu.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/web/assets/dist/assets/retour-0lLzocvu.css.gz
Binary file not shown.
2 changes: 0 additions & 2 deletions src/web/assets/dist/assets/retour-GsbkZ0RI.js

This file was deleted.

1 change: 0 additions & 1 deletion src/web/assets/dist/assets/retour-GsbkZ0RI.js.map

This file was deleted.

1 change: 0 additions & 1 deletion src/web/assets/dist/assets/retour-axBeLE34.css

This file was deleted.

Binary file removed src/web/assets/dist/assets/retour-axBeLE34.css.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions src/web/assets/dist/assets/retour-mao8V0mm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/web/assets/dist/assets/retour-mao8V0mm.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/web/assets/dist/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
},
"src/js/Retour.js": {
"css": [
"assets/retour-axBeLE34.css"
"assets/retour-0lLzocvu.css"
],
"file": "assets/retour-GsbkZ0RI.js",
"file": "assets/retour-mao8V0mm.js",
"isEntry": true,
"src": "src/js/Retour.js"
},
Expand Down
Binary file modified src/web/assets/dist/manifest.json.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/stats.html

Large diffs are not rendered by default.

0 comments on commit f974c1c

Please sign in to comment.