Skip to content

Instantly share code, notes, and snippets.

@dennisameling
Last active May 4, 2021 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennisameling/169983c167f9e409e3b0970f19c89aa2 to your computer and use it in GitHub Desktop.
Save dennisameling/169983c167f9e409e3b0970f19c89aa2 to your computer and use it in GitHub Desktop.
Mautic 3 upgrade script debug
<?php
/*
===========
PLEASE DELETE THIS FILE WHEN YOU'VE FINISHED DEBUGGING!
Run on the CLI with:
php m3-upgrade-debug.php
===========
*/
define('MAUTIC_ROOT', __DIR__);
// Data we fetch from a special JSON file to control upgrade behavior, like e.g. the download URL.
$data = make_request('https://updates.mautic.org/upgrade-configs/m2-to-m3.json', 'GET');
$updateData = json_decode($data, true);
var_dump($updateData);
function make_request($url, $method = 'GET', $data = null)
{
$method = strtoupper($method);
$ch = curl_init();
$timeout = 15;
if ($data && 'POST' == $method) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
// The CA file doesn't exist while we move all Mautic 2 files to a temp folder. We won't need it anyway on most servers nowadays.
if (file_exists(MAUTIC_ROOT . '/vendor/joomla/http/src/Transport/cacert.pem')) {
curl_setopt($ch, CURLOPT_CAINFO, MAUTIC_ROOT . '/vendor/joomla/http/src/Transport/cacert.pem');
}
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment