Possible bug in Editor 2.0.7 when uploading a file after having updated DataTables and Editor

Possible bug in Editor 2.0.7 when uploading a file after having updated DataTables and Editor

stevevancestevevance Posts: 58Questions: 6Answers: 1

Link to test case:
The Editor has uploading and is private.

Debugger code (debug.datatables.net):
I couldn't get the bookmarklet to upload the data (is this because the page has so many DataTables instantiated?

Error messages shown:

undefined is not an object (evaluating 'data[source]') in datatables.js:1934

Description of problem:
I updated to Editor 2.0.7 to use SearchPanes 2.0.0 so I can use the cascade.
I also use Editor to be able to upload files to my database.

When I submit the form to create the new record, I get the above error message.

The DT versions are below:

<!-- DataTables (needs to be loaded on all modes, not just $chosen mode) -->
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.11.4/date-1.1.2/b-2.1.0/b-html5-2.1.0/b-print-2.1.0/sl-1.2.6/sp-2.0.0/datatables.min.css"/>
    <script type="text/javascript" src="https://cdn.datatables.net/v/bs/dt-1.11.4/date-1.1.2/b-2.1.0/b-html5-2.1.0/b-print-2.1.0/sl-1.2.6/sp-2.0.0/datatables.js"></script>

This question has an accepted answers - jump to answer

Answers

  • stevevancestevevance Posts: 58Questions: 6Answers: 1

    I should add that the error message doesn't appear when I'm editing existing records.
    It appears when I'm creating a new record (and in this editor, that requires including an image to upload, so I can't test it without an image to upload).

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    Sorry you've hit a problem here. We've not seen that locally I'm afraid, so I'll need a bit more information to try and be able to reproduce the issue. Can you show me your Editor and DataTables initialisation for the table that is having issues, the response from the server when you attempt the create action and also the server-side script?

    If possible, you could private message me the link / login information which would help us narrow it down?

    Thanks,
    Allan

  • stevevancestevevance Posts: 58Questions: 6Answers: 1
    edited March 2022

    For some essential pages that I need to keep uploading files with, I downgraded the JS to 1.9.6. and it works.

    Here's what works:
    * Editor JS 1.9.6
    * DataTables JS 1.11.5
    * Editor PHP 2.0.7

    Here's what doesn't work:
    * Editor JS 2.0.7
    * DataTables JS 1.11.5
    * Editor PHP 2.0.7

    I can't create a testing environment right now but here's the full error stack:

    The errors appear AFTER uploading the file and BEFORE grabbing the new data from the Editor PHP script I use.

    Here's what the Editor PHP reports after uploading the file:

    {"data":[],"files":{"files":{"3511":{"id":3511,"filename":"Screen Shot 2022-03-01 at 12.28.49 .png","filesize":"174468","web_path":"\/uploads\/21eac17d30aafeeb58057dff0dabdaf9_3511.png","mime_type":"image\/png; charset=binary"}}},"upload":{"id":3511},"debug":[{"query":"INSERT INTO  \"files\"  ( \"filename\", \"filesize\", \"web_path\", \"mime_type\" ) VALUES (  :filename,  :filesize,  :web_path,  :mime_type )","bindings":[{"name":":filename","value":"Screen Shot 2022-03-01 at 12.28.49 .png","type":null},{"name":":filesize","value":174468,"type":null},{"name":":web_path","value":"-","type":null},{"name":":mime_type","value":"image\/png; charset=binary","type":null}]},{"query":"UPDATE  \"files\" SET  \"web_path\" = :web_path WHERE \"id\" = :where_0 ","bindings":[{"name":":where_0","value":3511,"type":null},{"name":":web_path","value":"\/uploads\/21eac17d30aafeeb58057dff0dabdaf9_3511.png","type":null}]},{"query":"SELECT  \"id\" as \"id\", \"filename\" as \"filename\", \"filesize\" as \"filesize\", \"web_path\" as \"web_path\", \"mime_type\" as \"mime_type\" FROM  \"files\" WHERE \"id\" IN (:wherein1) ","bindings":[{"name":":wherein1","value":3511,"type":null}]}]}
    

    Thus, I can't show you the PHP/SQL errors because the JS doesn't seem to have asked for that data yet.

    Here's line 4879 in dataTables.editor.js:

    if (multiGet[idSrc] === undefined) {
                            var originalVal = field.valFromData(edit.data);
                            builder(allRowData, originalVal);
                            return;
                        }
    

    Here's line 1892 in datatables.js

    // Array or flat object mapping
                    return function(data, type) {
                        // row and meta also passed, but not used
                        return data[source];
                    };
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thank you!

    The errors appear AFTER uploading the file and BEFORE grabbing the new data from the Editor PHP script I use.

    To confirm - there is a gap between the two, right? You upload the file, then need to click the submit button and at that point the error happens? But this error only happens if you upload a file?

    The data return looks sensible and reading over the code it isn't standing out to me what would cause the error. I'm sorry to say, I think I will need a test case to be able to solve this one.

    Allan

  • stevevancestevevance Posts: 58Questions: 6Answers: 1

    I think I've found a second, related bug. And now I have a test case for you to try. https://www.chicagocityscape.com/list_item.php

    The second bug occurs when trying to submit the form in the linked page.

    The JavaScript error is triggered before any data is sent to the server.

    The goal is to be able to add an item to a wishlist, and use the nested DataTable to create a new wishlist "on the fly". The user may also want to upload an image that corresponds with the item they're adding to a wishlist.

    The bugs are doing two things:
    1. Preventing new wishlists from being added.
    2. Preventing the item from being added to a wishlist.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Interesting one this. It is due to the wishlists_items.status field not having a value selected. If you add def: null (or possibly change the No status to be an empty string and set the default to match) then that should resolve this.

    Another option is to set the unselectedValue option for radio to be null or empty string.

    Regards,
    Allan

  • stevevancestevevance Posts: 58Questions: 6Answers: 1
    edited May 2022

    Welp, I think that solved it, Allan.
    Just that hint of knowing that some of my fields were not submitting any values helped me clean up the code in this script and some of my other scripts.

    Thank you!

Sign In or Register to comment.