Uploaded image for project: 'translate5'
  1. translate5
  2. TRANSLATE-1363

Ensure that search and replace can not be sent without field to be searched

    XMLWordPrintable

Details

    Description

      problem

      On a client installation we got the below listed SQL error.
      The reason is, that the search was performed without a field in which should be searched.

      solution

      Always provide meaningful default values or a validation in the PHP world for values coming from userland! Although the JS Frontend should handle it, never trust the content coming from the user. For API usage for example there is no GUI which validates the content!

      Implement default values / validation for the search and replace call!

      Ensure in the JS of search and replace before the ajax call that the searchField can not be empty. If it is empty, set it to the first available field (also the combo box) so that the user notice a possible change.

      exception details

       

      ZfExtended_Log on XXXXXXXX: exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.ToSort' in 'field list'' in /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Statement/Pdo.php:228
      Stack trace:
      #0 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
      #1 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Statement.php(303): Zend_Db_Statement_Pdo->_execute(Array)
      #2 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
      #3 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array)
      #4 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Table/Abstract.php(1577): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select))
      #5 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Table/Abstract.php(1392): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select))
      #6 /webs/www.translate5.net/library/ZfExtended/Models/Entity/Abstract.php(231): Zend_Db_Table_Abstract->fetchAll(Object(Zend_Db_Table_Select))
      #7 /webs/www.translate5.net/application/modules/editor/Models/Segment.php(206): ZfExtended_Models_Entity_Abstract->loadFilterdCustom(Object(Zend_Db_Table_Select))
      #8 /webs/www.translate5.net/application/modules/editor/Controllers/SegmentController.php(340): editor_Models_Segment->search(Array)
      #9 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Controller/Action.php(516): Editor_SegmentController->searchAction()
      #10 /webs/www.translate5.net/library/ZfExtended/Controllers/AAARestController.php(275): Zend_Controller_Action->dispatch('searchAction')
      #11 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Controller/Dispatcher/Standard.php(308): ZfExtended_RestController->dispatch('searchAction')
      #12 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(REST_Controller_Request_Http), Object(Zend_Controller_Response_Http))
      #13 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
      #14 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Application.php(384): Zend_Application_Bootstrap_Bootstrap->run()
      #15 /webs/www.translate5.net/library/ZfExtended/BaseIndex.php(167): Zend_Application->run()
      #16 /webs/www.translate5.net/public/index.php(35): ZfExtended_BaseIndex->startApplication()
      #17 {main}

      Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.ToSort' in 'field list', query was: SELECT `LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`.`id`, `LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`.`segmentNrInTask`, `LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`.`ToSort`, `LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`.`editable` FROM `LEK_segment_view_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` WHERE (lower(`ToSort`) like lower('%isento%') COLLATE utf8_bin) AND (editable=1) ORDER BY `matchRate` DESC' in /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Statement/Pdo.php:235
      Stack trace:
      #0 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Statement.php(303): Zend_Db_Statement_Pdo->_execute(Array)
      #1 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
      #2 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array)
      #3 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Table/Abstract.php(1577): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select))
      #4 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Db/Table/Abstract.php(1392): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select))
      #5 /webs/www.translate5.net/library/ZfExtended/Models/Entity/Abstract.php(231): Zend_Db_Table_Abstract->fetchAll(Object(Zend_Db_Table_Select))
      #6 /webs/www.translate5.net/application/modules/editor/Models/Segment.php(206): ZfExtended_Models_Entity_Abstract->loadFilterdCustom(Object(Zend_Db_Table_Select))
      #7 /webs/www.translate5.net/application/modules/editor/Controllers/SegmentController.php(340): editor_Models_Segment->search(Array)
      #8 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Controller/Action.php(516): Editor_SegmentController->searchAction()
      #9 /webs/www.translate5.net/library/ZfExtended/Controllers/AAARestController.php(275): Zend_Controller_Action->dispatch('searchAction')
      #10 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Controller/Dispatcher/Standard.php(308): ZfExtended_RestController->dispatch('searchAction')
      #11 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(REST_Controller_Request_Http), Object(Zend_Controller_Response_Http))
      #12 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
      #13 /webs/mittagqi_meta/other/zend/ZendFramework-1.12.20-minimal/library/Zend/Application.php(384): Zend_Application_Bootstrap_Bootstrap->run()
      #14 /webs/www.translate5.net/library/ZfExtended/BaseIndex.php(167): Zend_Application->run()
      #15 /webs/www.translate5.net/public/index.php(35): ZfExtended_BaseIndex->startApplication()
      #16 {main}

      Aufgerufene URL inkl. ggf. vorhandener POST-Parameter als get-Parameter:

      /editor/segment/search/format/json/_dc/1531988645816/filter/[]/sort/[\{"property":"matchRate","direction":"DESC"}]/taskGuid/{XXXXXXX-XXXX-XXXX-8e75-XXXXXX}/searchType/normalSearch/searchField/isento/replaceField/livre/searchInField//matchCase/false/searchTopChekbox/false/saveCurrentOpen/true/searchInLockedSegments/false

       

      Attachments

        Activity

          People

            aleksandar Aleksandar Mitrev
            tlauria Thomas Lauria
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: