Skip to content
Open
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
23 changes: 23 additions & 0 deletions Civi/Standalone/WebEntrypoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public static function invoke(): void {
// Remove empty path segments, a//b becomes equivalent to a/b
$args = array_values(array_filter($args));

// Redirect urls from WP mailings
self::wpredirect($parts[0] ?? '', $parts[1] ?? '');

// if request is for any path that doesn't start civicrm,
// throw 404 before we waste any effort doing anything else
// (may well be spam)
Expand Down Expand Up @@ -95,6 +98,26 @@ public static function invoke(): void {
print \CRM_Core_Invoke::invoke($args);
}

/**
* Redirect URLs from old mailings sent before migration from WordPress
*
* @param string $path
* @param string $params
* @return void
*/
public static function wpredirect($path, $params) {
if (preg_match('@^/wp-content/uploads/civicrm/persist/contribute/images/(.*)@', $path, $matches)) {
\CRM_Utils_System::redirect('/public/media/images/' . $matches[1]);
}
if (preg_match('@^/wp-content/uploads/civicrm/(mosaico_tpl/.*)@', $path, $matches)) {
\CRM_Utils_System::redirect('/public/' . $matches[1]);
}
if ($path === '/civicrm/' && $params &&
preg_match('@^civiwp=CiviCRM\&q=civicrm/mailing/url\&(u=\d+\&qid=\d+)@', $params, $matches)) {
\CRM_Utils_System::redirect('/civicrm/mailing/url?' . $matches[1]);
}
}

public static function installer(): void {
\Civi\Setup::assertProtocolCompatibility('1.0');

Expand Down