parse-community / parse-php-sdk

The PHP SDK for Parse Platform
https://parseplatform.org/
Other
811 stars 346 forks source link

destroy() changes URL #377

Closed andresteves closed 6 years ago

andresteves commented 6 years ago

Issue Description

Hi, I have a form with a POST action

$queryDelete = new ParseQuery("Contents");
        try {
            $storyObject = $queryDelete->get($_POST['objectID']);
            $storyObject->destroy();
        } catch (ParseException $ex) {
            echo 'Failed to create new object, with error message: ' + $ex->getMessage();
        }

After that the page refresh but lost the url value. Wanted to destroy without deleting the url value like the save() method

Steps to reproduce

~~ Please provide the necessary steps here to reproduce this when possible ~~

Environment Details

Logs/Traces

~~ Include any relevant logs/traces here ~~

montymxb commented 6 years ago

If you want to preserve a particular value in a request from $_POST or $_GET you can always add it to $_SESSION to hold onto it across subsequent page loads.

andresteves commented 6 years ago

Hi @montymxb,

Thanks for helping but I really want to keep the url unchanged after destroying an object.

Before destroy /contentTrigger.php?id=VsgvdzkEOh After destroy /contentTrigger.php

And it does not happen after an object save().

davidtavarez commented 6 years ago

@andresteves paste here the var_dump before and after, please.

andresteves commented 6 years ago

@davidtavarez var_dump of what variable?

davidtavarez commented 6 years ago

@andresteves can you share a code to reproduce the issue?

montymxb commented 6 years ago

If the user just refreshes the page (without changing the url) the same GET params will be present. I imagine that's not your case otherwise you wouldn't have this issue. If you're reloading the page from code you can append the same ?objectID=asfd to keep your GET vars.

But I'm not entirely sure how you're reloading the page, or if this a user causing a page load instead without your GET vars? Some details on what's happening would help regarding that.

You can also cheat if you want by modifying $_GET to contain the values you expect it to (like from $_SESSION). This is cutting corners a bit though and may get you into trouble if you really expect the key/values to come from the url in the first place.

montymxb commented 6 years ago

@andresteves any progress with this one?

andresteves commented 6 years ago

@montymxb I ended up following your suggestion of $_SESSION.