stcr / subscribe-to-comments-reloaded

Subscribe to Comments Reloaded allows commenters to sign up for e-mail notifications of subsequent replies.
56 stars 32 forks source link

Cannot manage subscriptions: `Cannot read properties of undefined (reading '_setter')` #678

Open bramus opened 2 years ago

bramus commented 2 years ago

When I visit /wp-admin/admin.php?page=stcr_manage_subscriptions, the page remains empty.

This is due to a JS error that's thrown, which breaks further execution.

In the JS console I read:

jquery.dataTables.min.js:23 Uncaught TypeError: Cannot read properties of undefined (reading '_setter')
    at m (VM475 jquery.dataTables.min.js:23:213)
    at Ha (VM475 jquery.dataTables.min.js:23:334)
    at HTMLTableRowElement.<anonymous> (VM475 jquery.dataTables.min.js:16:485)
    at load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils,regenerator-runtime,wp-polyfill,wp-hooks&ver=5.8.3:2:1567
    at Function.map (load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils,regenerator-runtime,wp-polyfill,wp-hooks&ver=5.8.3:2:3536)
    at s.fn.init.map (load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils,regenerator-runtime,wp-polyfill,wp-hooks&ver=5.8.3:2:1535)
    at ma (VM475 jquery.dataTables.min.js:16:465)
    at e (VM475 jquery.dataTables.min.js:92:154)
    at HTMLTableElement.<anonymous> (VM475 jquery.dataTables.min.js:92:342)
    at Function.each (load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils,regenerator-runtime,wp-polyfill,wp-hooks&ver=5.8.3:2:3003)

Using StCr 211130 with WP 5.8.3.

BobaWebDev commented 2 years ago

Most likely a conflict with another plugin. Can you let me know which plugins you have active?

bramus commented 2 years ago

Apologies for taking a while to get back to you about this, but I found the culprit: HTML in the post title that gets trimmed incorrectly, leaving the markup all jumbled.

Normally, you'd have rows like this:

<tr role="row">
    <td>
        <label for="sub_75505" class="hidden">Subscription 75505</label>
        <input class="checkbox" type="checkbox" name="subscriptions_list[]" value="XXX,XXX%40yahoo.com" id="sub_75505">
        <a href="admin.php?page=stcr_manage_subscriptions&amp;sra=edit-subscription&amp;srp=XXX&amp;sre=XXX%40yahoo.com" alt="Edit"><i class="fas fa-edit" style="font-size: 1.1em;color: #ffc53a;"></i></a>
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="admin.php?page=stcr_manage_subscriptions&amp;sra=delete-subscription&amp;srp=XXX&amp;sre=XXX%40yahoo.com" onclick="return confirm(&quot;Please remember: this operation cannot be undone. Are you sure you want to proceed?&quot;);" alt="Delete"><i class="fas fa-trash-alt" style="font-size: 1.1em;color: #ff695a;"></i></a>
    </td>
    <td><a href="admin.php?page=stcr_manage_subscriptions&amp;srf=post_id&amp;srt=equals&amp;srv=XXX">The Large, Small, and Dynamic Viewp.. (XXX)</a> </td>
    <td><a href="admin.php?page=stcr_manage_subscriptions&amp;srf=email&amp;srt=equals&amp;srv=XXX%40yahoo.com" title="email unique key: ( XXX )">XXX@yahoo.com</a> </td>
    <td data-sort="20210810075559">August 10, 2021 7:55 am</td>
    <td>All Comments</td>
</tr>

For one of my posts, the post title is The Future of CSS: <span style="white-space: nowrap">Scroll-Linked Animations</span> with <code style="white-space: nowrap">@scroll-timeline</code> <small><em>(Part 1)</em></small>

In StCR, this title gets trimmed to The Future of CSS: <span style="whi.. which, as a result, breaks the HTML to define a row (see line 8 in the snippet below):

<tr>
    <td>
        <label for="sub_XXX" class="hidden">Subscription XXX</label>
        <input class="checkbox" type="checkbox" name="subscriptions_list[]" value="XXX,XXX%40gmail.com" id="sub_XXX">                                                        
        <a href="admin.php?page=stcr_manage_subscriptions&amp;sra=edit-subscription&amp;srp=XXX&amp;sre=XXX%40gmail.com" alt="Edit"><i class="fas fa-edit" style="font-size: 1.1em;color: #ffc53a;"></i></a>
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="admin.php?page=stcr_manage_subscriptions&amp;sra=delete-subscription&amp;srp=XXX&amp;sre=XXX%40gmail.com" onclick="return confirm(&quot;Please remember: this operation cannot be undone. Are you sure you want to proceed?&quot;);" alt="Delete"><i class="fas fa-trash-alt" style="font-size: 1.1em;color: #ff695a;"></i></a>
    </td>
    <td><a href="admin.php?page=stcr_manage_subscriptions&amp;srf=post_id&amp;srt=equals&amp;srv=XXX">The Future of CSS: <span style="whi.. (XXX)</a> </td>
    <td><a href='admin.php?page=stcr_manage_subscriptions&amp;srf=email&amp;srt=equals&amp;srv=XXX%40gmail.com' title='email unique key: ( XXX )'>XXX@gmail.com</a> </td>
    <td data-sort='20210726235247'>July 26, 2021 11:52 pm</td>
    <td>All Comments</td>
</tr>

As a result the dataTables JS plugin breaks on it.