• Resolved zapappa

    (@lesarnott)


    I have the free version of WP Data Access (5.2.9) on ‘WordPress 6.1.1 running Astra Child theme’ with PHP 8.0 and I’m having a problem with URL shortcode parameters with wildcards.  I have tested with WA Data Access being the only active plugin.

    I am displaying event details and the issue I have is searching on a year which has to be extracted from a date string. This is a historical database and I have to work with it as is. The default WHERE clause is:

    YEAR(date) = YEAR(CURDATE())

    and the database date column is:

    date    tinytext    utf8mb4_unicode_520_ci   Yes    

    and that works just fine. In fact all the database accesses work fine in your Query Builder or in phpMyAdmin , for example:

    SELECT * FROM wpws_fhsc_calendar_events WHERE date LIKE “2022%”

    The shortcode I’m using is: 

    [wpdataaccess pub_name=”fhsc_calendar_events”]

    which works fine without any URL parameter overrides.  However, when I try to use URL parameters like this:

    …?wpda_search_column_date=2020%

    the rendering does not complete and the Chrome console shows an uncaught error in wpda_datatables.js at line 323. Looks like decodeURIComponent doesn’t like the trailing % character?  I tried 2020%25 to see if that would work and there was no error but nothing rendered.

    Uncaught Error

    wpda_datatables.js?ver=5.2.9:323 Uncaught URIError: URI malformed
        at decodeURIComponent (<anonymous>)
        at String.<anonymous> (wpda_datatables.js?ver=5.2.9:323:28)
        at Function.each (jquery.min.js?ver=3.6.1:2:3003)
        at data (wpda_datatables.js?ver=5.2.9:319:12)
        at Tt (jquery.dataTables.min.js?ver=5.2.9:4:25958)
        at Jt (jquery.dataTables.min.js?ver=5.2.9:4:32745)
        at Object.success (jquery.dataTables.min.js?ver=5.2.9:4:6431)
        at c (jquery.min.js?ver=3.6.1:2:28327)
        at Object.fireWith [as resolveWith] (jquery.min.js?ver=3.6.1:2:29072)
        at l (jquery.min.js?ver=3.6.1:2:80045)

    I also made a quick test with [wpdadiehard project_id=”2″ page_id=”6″] and the table did render but the same uncaught error occurred immediately afterwards.

    I’d appreciate any advice you have on getting this working because my initial testing with your plugin looks very, very promising!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @lesarnott,

    Thank you for reaching out. Can you share a link to this publication?

    I wonder if date (your column name) could be a reserved word in jQuery DataTables? Could you do just a quick test: create a view using a different column name and test if it works with your view?

    Thanks,
    Peter

    Plugin Contributor Kim L

    (@kimmyx)

    Hi there,

    I’m going to mark this as resolved as we haven’t heard from you in a while.

    Feel free to create a new thread if you have other questions.

    Thanks!

    Thread Starter zapappa

    (@lesarnott)

    I exchanged a few emails with Peter and I’m still waiting for a reply to the last email?

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @lesarnott,

    Sorry, I have no open mails! Nothing in my spam box as well.

    Can you please resent your last mail? And sent it through the contact page on the plugin website as well? Just to be sure I get it…

    Sorry for the inconvenience,
    Peter

    Thread Starter zapappa

    (@lesarnott)

    Sorry Peter I checked in my sent and it appears I replied to your email which had a no-reply destination! Here it is:

    Thanks for getting back.  I have another table (officers) that is simpler and doesn’t actually need a wild card because this table has a ‘year’ column, which is a text type. Here is the columns list:

    Again, if I use your Query Builder it works fine, both with and without the % character:

    SELECT * FROM wpws_fhsc_officers WHERE year LIKE “2021%”

    SELECT * FROM wpws_fhsc_officers WHERE year LIKE “2021”

    SELECT * FROM wpws_fhsc_officers WHERE year = “2021”In WPDA the default WHERE clause is year=YEAR(CURDATE()) and it displays the officers for the current year with no problem.  The shortcode is [wpdataaccess pub_name=”fhsc_officers”]

    When I add the URL parameter without the % I see “No matching records found” but no console error.

    https://fridayharborsailing.com/wp/view-officers/?wpda_search_column_year=2020

    If I add the % character I see the console error (URIError: URI malformed)

    https://fridayharborsailing.com/wp/view-officers/?wpda_search_column_year=2020%

    Note: the “/wp” folder is a separate WordPress system for my testing.

    Thanks, Les

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Les,

    Thanks for the follow up!

    The plugin expects a safe URL. A % is generally unsafe. You need to encode it to %25. If you create a search form, this happens automatically.

    Here is an example:
    https://wpdataaccess.com/publication-search-form-demo/

    Please enter clara% and press the submit button. You’ll see in the URL that clara% is encoded to clara%25. When you remove 25 from your URL you’ll get the same decodeURIComponent error on your console.

    Does this solve the issue?
    Peter

    Thread Starter zapappa

    (@lesarnott)

    I used 2022% at first because your documentation contains this example:

    YOUR-URL/?wpda_search_column_title=Last%

    but in the initial post you can see that I also tried %25:

    I tried 2020%25 to see if that would work and there was no error but nothing rendered.

    I re-ran the same tests on the main issue (accessing the calendar) that actually needs the %25 I have the same problems as before

    https://fridayharborsailing.com/wp/view-calendar/?wpda_search_column_date=2020%25

    However, I think I have found the cause of the problem. The calendar table is setup with the Data Publisher/Advanced Settings/WHERE Clause containing YEAR(date)=”YEAR(CURDATE())” and I guess I was expecting the URL parameter to override the Where clause if necessary but that appears to be not the case. If I remove the YEAR(date)=”YEAR(CURDATE())” from the WHERE clause and use the %25 it works perfectly. This means there is no configured default year but that’s an easy change.

    So, if you agree that this conclusion makes sense I thank you for your time and your patience.  You have a great plugin here!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Wildcard URL shortcode parameter’ is closed to new replies.