Support » Plugin: PTA Volunteer Sign Up Sheets » BUG: Copy Sheet runs 2 Times

  • Resolved jonhuck

    (@jonhuck)



    When I click Copy to create a duplicate sheet it runs twice and generates 2 copies.

    I am using the Groups extension with the core plugin.

    • This topic was modified 6 months, 3 weeks ago by  jonhuck.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author DBAR Productions

    (@dbar-productions)

    I believe you have some sort of conflict or something wrong with your system. The copy feature works just fine here on my system, and nobody else is reporting any issues with it. Something on your system is causing that action to get triggered twice.

    If you are using any plugins that customize the admin area, I would try disabling those first. Otherwise, you’ll need to do a process of elimination, turning off other plugins one at a time to see if the issue stops happening. When it does, you’ll know it is some kind of conflict with the last plugin you deactivated. If it’s not a plugin, could maybe some weird server configuration issue.

    Hard to say what’s causing it, but it is NOT a bug in the code, as that copy features has been around for a long time and nobody has ever had any issues with it. It’s a pretty simple function overall. However, if your refresh the page, or something else causes the page to refresh, right after you did a copy operation, then, yes, it will dutifully copy the sheet again as the arguments that make it copy a sheet are appended to the URL: action=copy&sheet_id=12&_sus_nonce=710a08f91a

    I think it is actually a bug.

    After I copy the Sheet I need to find the sheet to edit it – so I was sorting the columns to find it (as there is no search etc)

    So if I click any action that causes that page to refresh e.g. click any column sort link the action=copy is re-executed. (the action=copy is in the sort url)

    Even if I click the Pagination it executes the copy again. (the action=copy is in the pagination url)

    A filter to remove the action=copy from Column sort links and Pagination links will fix this 😀

    Plugin Author DBAR Productions

    (@dbar-productions)

    For now, if you just click on the “All Sheets” submenu item after copying a sheet, it will reload the page without any action arguments.

    The table filtering and pagination are handled by the List Table class of WordPress, so I would have to do some digging to see if there is a filter hook or other way to alter the URLs for filtering and pagination to first set any of my plugin’s actions to false (assuming it’s using the add query arguments function). Been a while since I looked at that, but the code I use to extend the List Table class just specifies things like which columns are sortable, but those column headings and associated arguments added to the URL for filtering are all handled by the main List Table class, which I didn’t write.

    Ok – so maybe looking at removing the action=copy from the completed copy page URL would do the trick? I wish I had more time to work on this / help = but I have to launch this site Monday (one of those projects 😉 so am in the data entry stage – will definitely do the extra click workaround for now and later on take a closer look at the code and post back if I can find solution / help out.

    Plugin Author DBAR Productions

    (@dbar-productions)

    Doesn’t work that way, you can’t just remove it like that. It has to be in the URL that you click on, so that info is passed in the GET or REQUEST variable as the page is loading in order for the code to know what to do. You can’t then manipulate the URL in the web browser after, or even while, the page is loading. You just have to have other links to click on where those arguments (like action) are not there. But, as already stated, I don’t control the links in the sort/filtering output of the pagination, so I can’t change how those links are generated unless that parent List Table class has filter hooks on those links to allow me to further manipulate them before they are output to your browser.

    I could possibly change my code to just show some sort of message after you copy a sheet, and NOT show the list table of sheets, and then you would be forced to click a button that I would have to add after the message to then reload the page a second time (with a link that is the same as the “All Sheets” page). But, you can already do that by just clicking on “All Sheets” anyway. Or, alternately, do the copying via more complex jQuery and Ajax so the page never reloads and we don’t even need any actions in the URL to figure out what it was you are trying to do.

    At this point, it’s not worth my time to do either of those things, as this has never even come up as an issue until now. Not too many people are using the copy function and then immediately trying to filter/sort the sheets, I guess. So, probably not going to go too high on my priority list. Maybe read this as to why:
    https://stephensherrardplugins.com/support/topic/more-features-or-reworked-pro-version/

    Sure – I understand PHP / WordPress pretty well – though don’t write many plugins or manipulate WP default admin tables very much.

    AJAX would be the best way – though setting location to the plain View All Sheets url without action=copy AFTER the copy action was performed should to the trick. It’s a double page load but would take care of the problem.

    I hear what you are saying about “not worth my time” as I’m always spending 1-2+ hours fixing someone elses coding problem and not getting paid for it. 😉

    Really good job for a free plugin – kudos and thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘BUG: Copy Sheet runs 2 Times’ is closed to new replies.