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

dev/joomla#26 - Fix path derivation when CMS is rooted in a subdir #16890

Merged
merged 4 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CRM/Upgrade/Incremental/sql/5.23.4.mysql.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{* file to handle db changes in 5.23.4 during upgrade *}
6 changes: 3 additions & 3 deletions Civi/Core/Paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public function __construct() {
->register('civicrm.packages', function () {
return [
'path' => \Civi::paths()->getPath('[civicrm.root]/packages/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/packages/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/packages/', 'absolute'),
];
})
->register('civicrm.vendor', function () {
return [
'path' => \Civi::paths()->getPath('[civicrm.root]/vendor/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/vendor/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/vendor/', 'absolute'),
];
})
->register('civicrm.bower', function () {
return [
'path' => \Civi::paths()->getPath('[civicrm.root]/bower_components/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/bower_components/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/bower_components/', 'absolute'),
];
})
->register('civicrm.files', function () {
Expand Down
9 changes: 9 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ Other resources for identifying changes are:
* https://github.com/civicrm/civicrm-joomla
* https://github.com/civicrm/civicrm-wordpress

## CiviCRM 5.23.4

Released March 24, 2020

- **[Synopsis](release-notes/5.23.4.md#synopsis)**
- **[Bugs resolved](release-notes/5.23.4.md#bugs)**
- **[Credits](release-notes/5.23.4.md#credits)**
- **[Feedback](release-notes/5.23.4.md#feedback)**

## CiviCRM 5.23.3

Released March 16, 2020
Expand Down
38 changes: 38 additions & 0 deletions release-notes/5.23.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# CiviCRM 5.23.4

Released March 24, 2020.

- **[Synopsis](#synopsis)**
- **[Bugs resolved](#bugs)**
- **[Credits](#credits)**
- **[Feedback](#feedback)**

## <a name="synopsis"></a>Synopsis

| *Does this version...?* | |
|:--------------------------------------------------------------- |:-------:|
| Fix security vulnerabilities? | no |
| Change the database schema? | no |
| Alter the API? | no |
| Require attention to configuration options? | no |
| Fix problems installing or upgrading to a previous version? | no |
| Introduce features? | no |
| **Fix bugs?** | **yes** |

## <a name="bugs"></a>Bugs resolved

** **_Various_: Fix malformed URLs when CMS root is a subdirectory ([dev/joomla#26](https://lab.civicrm.org/dev/joomla/issues/26): [#16887](https://github.com/civicrm/civicrm-core/pull/16887))**

## <a name="credits"></a>Credits

This release was developed by the following authors and reviewers:

Tadpole Collective - Kevin Cristiano; Stephen Palmstrom; Squiffle Consulting - Aidan
Saunders; Nicol Wistreich; JMA Consulting - Seamus Lee; howardshand; CiviCRM - Tim Otten;
Andy Burns; Andrew Thompson

## <a name="feedback"></a>Feedback

These release notes are edited by Tim Otten and Andrew Hunt. If you'd like to
provide feedback on them, please login to https://chat.civicrm.org/civicrm and
contact `@agh1`.
2 changes: 1 addition & 1 deletion sql/civicrm_generated.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ UNLOCK TABLES;

LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,'5.23.3',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,'5.23.4',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
51 changes: 51 additions & 0 deletions tests/phpunit/Civi/Core/PathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,55 @@ public function testGetUrl_ImplicitBase() {
$this->assertEquals("$cmsRoot/foo", $p->getUrl('foo'));
}

/**
* This test demonstrates how to (and how not to) compute a derivative path variable.
*/
public function testAbsoluteRelativeConversions() {
$gstack = \CRM_Utils_GlobalStack::singleton();
$gstack->push(['_SERVER' => ['HTTP_HOST' => 'example.com']]);
$cleanup = \CRM_Utils_AutoClean::with([$gstack, 'pop']);

$paths = new Paths();
$paths->register('test.base', function () {
return [
'path' => '/var/foo/',
'url' => 'http://example.com/foo/',
];
});
$paths->register('test.goodsub', function () use ($paths) {
// This is a stand-in for how [civicrm.bower], [civicrm.packages], [civicrm.vendor] currently work.
return [
'path' => $paths->getPath('[test.base]/good/'),
'url' => $paths->getUrl('[test.base]/good/', 'absolute'),
];
});
$paths->register('test.badsub', function () use ($paths) {
// This is a stand-in for how [civicrm.bower], [civicrm.packages], [civicrm.vendor] used to work (incorrectly).
return [
'path' => $paths->getPath('[test.base]/bad/'),
// The following *looks* OK, but it's not. Note that `getUrl()` by default uses `$preferFormat==relative`.
// Both registered URLs (`register()`, `$civicrm_paths`) and outputted URLs (`getUrl()`)
// can be in relative form. However, they are relative to different bases: registrations are
// relative to CMS root, and outputted URLs are relative to HTTP root. They are often the same, but...
// on deployments where they differ, this example will misbehave.
'url' => $paths->getUrl('[test.base]/bad/'),
];
});

// The test.base works as explicitly defined...
$this->assertEquals('/var/foo', $paths->getPath('[test.base]/.'));
$this->assertEquals('http://example.com/foo', $paths->getUrl('[test.base]/.', 'absolute'));
$this->assertEquals('/foo', $paths->getUrl('[test.base]/.', 'relative'));

// The test.goodsub works as expected...
$this->assertEquals('/var/foo/good', $paths->getPath('[test.goodsub]/.'));
$this->assertEquals('http://example.com/foo/good', $paths->getUrl('[test.goodsub]/.', 'absolute'));
$this->assertEquals('/foo/good', $paths->getUrl('[test.goodsub]/.', 'relative'));

// The test.badsub doesn't work as expected.
$this->assertEquals('/var/foo/bad', $paths->getPath('[test.badsub]/.'));
$this->assertNotEquals('http://example.com/foo/bad', $paths->getUrl('[test.badsub]/.', 'absolute'));
$this->assertNotEquals('/foo/bad', $paths->getUrl('[test.badsub]/.', 'relative'));
}

}
2 changes: 1 addition & 1 deletion xml/version.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
<version_no>5.23.3</version_no>
<version_no>5.23.4</version_no>
</version>