Giter Site home page Giter Site logo

SQL Error in Redirect Module about nawork-uri HOT 3 OPEN

SicorDev avatar SicorDev commented on June 14, 2024
SQL Error in Redirect Module

from nawork-uri.

Comments (3)

thommyhh avatar thommyhh commented on June 14, 2024

@SicorDev This one is unfortunately not that easy. The problem is that TYPO3 saves the record on type change. In that cases all validations in the form are skipped, probably because the fields might change with the type change.

I tried to improve the behaviour by removing the empty default option in the domain select, so the redirect would in any case show in in the list and would not disappear. Unfortunately this could also lead to that duplicate key sql error because the url to the homepage has an empty path.

I also made the path required, so this might help the user to understand, that this field must be filled. But as I said, I currently can't find a way to avoid TYPO3 from saving the record in type change.

I update all 3.x branches. Please try the change and let me know what you think.

from nawork-uri.

SicorDev avatar SicorDev commented on June 14, 2024

@thommyhh
I've tried the current master branch, but I couldn't find any difference in the behaviour.

I've got another idea, how to prevent the error in all cases:
You could add a "afterSaveHook", that sets a default path value, if no value is set.
(Untested example)

ext_tables.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:' . $_EXTKEY . '/Classes/Hooks/Hook.php:Hook';

Hook.php

function processDatamap_afterDatabaseOperations($status, $table, $id, &$fieldArray, &$pObj) {
  if ($table == 'tx_naworkuri_uri' && $status === 'new') {
    if(!$fieldArray['path']) {
       $fieldArray['path'] = 'default-value' . time();
    }
  }
}

from nawork-uri.

thommyhh avatar thommyhh commented on June 14, 2024

@SicorDev The problem is, that the SQL errors occurs when saving, meaning a default value must be set before. On the other hand, it could theoretically be possible to have an empty path. If I remember correctly, the url for the homepage has an empty path, which doesn't really makes sense.

Maybe the fix is, to not allow empty paths at all, and handle an empty path as the homepage. Adding the default value, if the record was saved by the type change with an empty path.

from nawork-uri.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.