Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21788 Clean URLs (Proof of Concept) #123

Closed
wants to merge 7 commits into from

Conversation

christianwach
Copy link
Member

@christianwach christianwach commented Feb 22, 2018

This is one part of the required changes to implement Clean URLs (or at least parity with CiviCRM's URL schema in Drupal) in WordPress. Please refer to the Jira issue for accompanying changes to CiviCRM Core - or visit the PR directly since Jira doesn't seem to have picked it up.

Please note that I do not recommend this as a production-ready PR. I think there's going to be a lot of testing required since there are so many moving parts to this. Any takers? :-)


@kcristiano
Copy link
Member

@christianwach Fantastic work. I've built test sites with these patches and they work as expected.

I've run upgrades from 4.7.27 to latest master as well as fresh installs.

The code looks good and results are as expected.

We plan on further testing as this will need a good going through to find any issues. I'd recommend merging this PR and civicrm/civicrm-core#11708 early to get in the next RC.

@mlutfy
Copy link
Member

mlutfy commented Mar 8, 2018

Can someone test this with Mosaico?

The patch seems to work really well, but when testing Mosaico, CiviMail could not save drafts anymore. It would respond with "Unable to decode supplied JSON". I got lost debugging the json before/after, so before continuing further, I just wanted to make sure it was not a red herring.

(I did try to apply the patch, run tests, stash, run tests again, etc, every time with the same result)

Update:

It seems to be related to the escaping of double-quotes:

capture d ecran de 2018-03-08 19-14-02

In the above, the replyto_email is : replyto_email":"\"ACME org\"+<[email protected]>"

If I load the Mosaico UI, then apply the patch, then send a test, it fails. Likewise, if I apply the patch first, load the UI, remove the patch, then send a test, it works.

Update2: reverting these lines fixes it (from civicrm/civicrm.php):

    // reassign globals
    $_GET     = stripslashes_deep($_GET);
    $_POST    = stripslashes_deep($_POST);

civicrm.php Outdated
if (!empty($cs)) { $_REQUEST['cs'] = $_GET['cs'] = $cs; }
if (!empty($force)) { $_REQUEST['force'] = $_GET['force'] = $force; }

}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax: should be 2 spaces, not 2 tabs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah. Editor defaults to tab-indent. Will rectify.

@christianwach
Copy link
Member Author

@mlutfy Thanks for testing.

reverting these lines fixes it

Cheers, that's a help. I'll test this with Mosaico.

@christianwach
Copy link
Member Author

@mlutfy When you say:

reverting these lines fixes it

Do you mean "removing these lines"?

@mlutfy
Copy link
Member

mlutfy commented Mar 12, 2018

I used:

$_POST    = stripslashes_deep($_POST);

Instead of:

$_POST    = stripslashes_deep($this->civi_post);

Line 1249: https://github.com/civicrm/civicrm-wordpress/pull/123/files#diff-d1bc6ad2b4d05fe1a841fce94b11b8dbL1248

@christianwach
Copy link
Member Author

@mlutfy Thanks for clarifying.

@mlutfy
Copy link
Member

mlutfy commented Mar 28, 2018

I stumbled on this bug:

The registration works, and is saved in CiviCRM, however, the redirection seems to fail to show the ThankYou page:

https://example.org/civicrm/event/register/?_qf_ThankYou_display=true&qfKey=5b22c771b131249a1b40ab7ee6e7aee4_1884

I get a fatal error with: "Could not find valid value for id".

I tested with and without my revert of $_POST = stripslashes_deep($_POST);. I also tested that registration works correctly without this patch.

When inspecting the session, all the controller information is empty, i.e. $controller shows as:

_CRM_Event_Controller_Registration_5b22c771b131249a1b40ab7ee6e7aee4_1795_container:Array(
    [defaults] => Array       (      )

    [constants] => Array   (       )
    [values] => Array  (
            [Register] => Array               (               )
            [ThankYou] => Array               (               )
        )
    [valid] => Array  (
            [Register] =>
            [ThankYou] =>
        )
)

Backtrace:

#0 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(378): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php(120): CRM_Core_Error::fatal("Could not find valid value for id")
#2 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php(52): CRM_Utils_Request::retrieve("id", "Positive", Object(CRM_Event_Controller_Registration), TRUE)
#3 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php(47): CRM_Event_StateMachine_Registration->__construct(Object(CRM_Event_Controller_Registration), TRUE)
#4 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(304): CRM_Event_Controller_Registration->__construct("Inscription à l'événement", TRUE, "null", NULL, "false")
#5 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:15))
#6 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
#7 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/civicrm.php(1351): CRM_Core_Invoke::invoke((Array:4))
#8 /var/aegir/platforms/wordpress/wp-content/plugins/civicrm/includes/civicrm.basepage.php(141): CiviCRM_For_WordPress->invoke()
#9 /var/aegir/platforms/wordpress/wp-includes/class-wp-hook.php(286): CiviCRM_For_WordPress_Basepage->basepage_handler(Object(WP))
#10 /var/aegir/platforms/wordpress/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, (Array:1))
#11 /var/aegir/platforms/wordpress/wp-includes/plugin.php(515): WP_Hook->do_action((Array:1))
#12 /var/aegir/platforms/wordpress/wp-includes/class-wp.php(726): do_action_ref_array("wp", (Array:1))
#13 /var/aegir/platforms/wordpress/wp-includes/functions.php(960): WP->main("")
#14 /var/aegir/platforms/wordpress/wp-blog-header.php(16): wp()
#15 /var/aegir/platforms/wordpress/index.php(17): require("/var/aegir/platforms/wordpress/wp-blog-header.php")
#16 {main}

@christianwach
Copy link
Member Author

@mlutfy Thanks for reporting. Just to be sure - you definitely have this commit in core? That was causing the same problem for me by triggering a browser redirect on account of ?& in the initial URL. If so, then there must be other places in core that cause a redirect after the session has been cleared.

@christianwach
Copy link
Member Author

@mlutfy I see no reason not to do so, so I've reverted as per your debugging so that:

$_GET     = stripslashes_deep( $_GET );
$_POST    = stripslashes_deep( $_POST );
$_COOKIE  = stripslashes_deep( $_COOKIE );
$_REQUEST = stripslashes_deep( $_REQUEST );

Regarding your Event Registration difficulties, I simply cannot reproduce this locally. Have you been able to test your install to see if there is a redirect happening before you encounter the problem? A good place to start would be logging the URLs in the perform() method that I thought I had fixed in the commit I mentioned previously - or, more comprehensively, in CRM_Utils_System::redirect().

@kcristiano
Copy link
Member

@christianwach Do we want to close this and test off of your fork? It may be better to track as an issue until you feel it is ready to merge. I'd also like to see #125 in sooner rather than laster and that will require this to be rebased

cc @mlutfy

@christianwach christianwach changed the title CRM-21788 Clean URLs CRM-21788 Clean URLs (Proof of Concept) Sep 25, 2018
@kcristiano kcristiano closed this Oct 5, 2018
@christianwach christianwach deleted the clean-urls branch March 20, 2019 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants