dev/wordpress#73 - Be more forgiving about slash in wpBasePage
authorTim Otten <totten@civicrm.org>
Wed, 2 Sep 2020 23:34:27 +0000 (16:34 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 3 Sep 2020 01:10:55 +0000 (18:10 -0700)
commit11eed11026ff92154af770dc3743d0ad617a244e
tree9f840fac167697a467e5d681566e663810303b5f
parent2baacb1762abf600f6c3dca38c368b5bb1c52cb0
dev/wordpress#73 - Be more forgiving about slash in wpBasePage

Overview
--------

The correct functioning of `wpBasePage` depends on whether the administrator
omitted or added a trailing slash.  This is apparent on URLs with a trailing slash, eg

```
http://wpmaster.bknix:8001/civicrm/contribute/transact/?reset=1&id=1
```

Make it less sensitive.

Before
------

URL is OK with default setting `wpBasePage=civicrm`

URL fails with setting `wpBasePage=civicrm/`

After
-----

URL is OK with either setting `wpBasePage=civicrm` or `wpBasePage=civicrm/`

Technical Details
-----------------

I believe the old symptom arose because of the formula which produces the WP
rewrite rules (`'^' .  $config->wpBasePage .  '/([^?]*)?'`) expects that
there is no trailing slash. You could theoretically patch there, but this
seems like it'll provide more thorough normalization.

When testing, the results affect the WP rewrite rules, so you may need to be particularly
aggressive about clearing caches whenever you make a change in code or settings, eg

```
wp cache flush ; cv flush;  wp rewrite flush
```
CRM/Core/Config/MagicMerge.php
CRM/Utils/System/WordPress.php