nystudio107 / retour

DEPRECATED Retour allows you to intelligently redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website.
Other
168 stars 24 forks source link

CSV Import results in "PHP Notice – yii\base\ErrorException – Undefined index: redirectMatchType" #116

Closed maxstrebel closed 3 years ago

maxstrebel commented 3 years ago

Describe the bug

When I import a CSV, I get the error:

To reproduce

Steps to reproduce the behaviour:

  1. Import CSV
  2. Map Fields
  3. See error message "PHP Notice – yii\base\ErrorException – Undefined index: redirectMatchType"

Expected behaviour

Should import CSV and create redirects

Versions

Example CSV

Legacy URL Pattern,Redirect To,redirectMatchType,HTTP Status,Legacy URL Match Type
/quantencomputing-in-der-medizinischen-diagnostik/,/artikel/quantencomputing-in-der-medizinischen-diagnostik,exactmatch,301,pathonly

Stack Trace

yii\base\ErrorException: Undefined index: redirectMatchType in /var/www/.../vendor/nystudio107/craft-retour/src/services/Redirects.php:768
Stack trace:
#0 /var/www/.../vendor/craftcms/cms/src/web/ErrorHandler.php(75): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/var/www/html/s...', 768)
#1 /var/www/.../vendor/nystudio107/craft-retour/src/services/Redirects.php(768): craft\web\ErrorHandler->handleError(8, 'Undefined index...', '/var/www/html/s...', 768, Array)
#2 /var/www/.../vendor/nystudio107/craft-retour/src/controllers/FileController.php(342): nystudio107\retour\services\Redirects->saveRedirect(Array)
#3 /var/www/.../vendor/nystudio107/craft-retour/src/controllers/FileController.php(132): nystudio107\retour\controllers\FileController->importCsvApi9(Object(League\Csv\Reader), Array, Array)
#4 [internal function]: nystudio107\retour\controllers\FileController->actionImportCsvColumns()
#5 /var/www/.../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /var/www/.../vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#7 /var/www/.../vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('import-csv-colu...', Array)
#8 /var/www/.../vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('import-csv-colu...', Array)
#9 /var/www/.../vendor/craftcms/cms/src/web/Application.php(276): yii\base\Module->runAction('retour/file/imp...', Array)
#10 /var/www/.../vendor/craftcms/cms/src/web/Application.php(589): craft\web\Application->runAction('retour/file/imp...', Array)
#11 /var/www/.../vendor/craftcms/cms/src/web/Application.php(255): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#12 /var/www/.../vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#13 /var/www/.../web/index.php(21): yii\base\Application->run()
#14 {main}
khalwat commented 3 years ago

Addressed in: https://github.com/nystudio107/craft-retour/commit/c4b96f3d4fe859d3bcfb78bf2232ba8eda15f848

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-retour": "dev-develop as 3.1.61”,

Then do a composer clear-cache && composer update

maxstrebel commented 3 years ago

I did it. Import does not throw an error now, but the Redirects won't be imported either. Is my CSV wrong?

"Legacy URL Pattern","Redirect To","Match Type","HTTP Status","Site ID","Legacy URL Match Type",Hits,"Last Hit"
/test/,/artikel/test,exactmatch,301,,pathonly,4,"2021-08-20 08:05:14"