Skip to content

Commit

Permalink
Merge pull request mautic#13178 from escopecz/merging-5.1-into-5.x
Browse files Browse the repository at this point in the history
Merging 5.1 into 5.x
  • Loading branch information
escopecz authored Jan 9, 2024
2 parents f5e44fe + eb90aff commit b1f1e4a
Show file tree
Hide file tree
Showing 454 changed files with 3,750 additions and 643 deletions.
2 changes: 1 addition & 1 deletion .ddev/local.config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $parameters = [
'db_user' => 'db',
'db_password' => 'db',
'admin_email' => '[email protected]',
'admin_password' => 'mautic',
'admin_password' => 'Maut1cR0cks!',
'install_source' => 'DDEV',
'mailer_from_name' => 'DDEV',
'mailer_from_email' => '[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion .ddev/mautic-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ setup_mautic() {

tput setaf 2
printf "All done! Here's some useful information:\n"
printf "🔒 The default login is admin/mautic\n"
printf "🔒 The default login is admin / Maut1cR0cks!\n"
printf "🌐 To open the Mautic instance, go to ${MAUTIC_URL} in your browser.\n"
printf "🌐 To open PHPMyAdmin for managing the database, go to ${PHPMYADMIN_URL} in your browser.\n"
printf "🌐 To open MailHog for seeing all emails that Mautic sent, go to ${MAILHOG_URL} in your browser.\n"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
export DB_PORT="${{ job.services.database.ports[3306] }}"
if [[ "${{ matrix.php-versions }}" == "8.1" ]] && [[ "${{ matrix.db-types }}" == "mariadb" ]]; then
php -d pcov.enabled=1 bin/phpunit -d memory_limit=1G --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist --coverage-clover=coverage.xml --log-junit=junit.xml
php -d pcov.enabled=1 bin/phpunit -d memory_limit=2G --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist --coverage-clover=coverage.xml --log-junit=junit.xml
else
composer test
fi
Expand Down
10 changes: 5 additions & 5 deletions app/bundles/ApiBundle/Config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Mautic\CoreBundle\DependencyInjection\MauticCoreExtension;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\ref;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return function (ContainerConfigurator $configurator): void {
$services = $configurator->services()
Expand All @@ -26,10 +26,10 @@
$services->load('Mautic\\ApiBundle\\Entity\\oAuth2\\', '../Entity/oAuth2/*Repository.php');

$services->get(\Mautic\ApiBundle\Controller\oAuth2\AuthorizeController::class)
->arg('$authorizeForm', ref('fos_oauth_server.authorize.form'))
->arg('$authorizeFormHandler', ref('fos_oauth_server.authorize.form.handler.default'))
->arg('$oAuth2Server', ref('fos_oauth_server.server'))
->arg('$clientManager', ref('fos_oauth_server.client_manager.default'));
->arg('$authorizeForm', service('fos_oauth_server.authorize.form'))
->arg('$authorizeFormHandler', service('fos_oauth_server.authorize.form.handler.default'))
->arg('$oAuth2Server', service('fos_oauth_server.server'))
->arg('$clientManager', service('fos_oauth_server.client_manager.default'));

$services->alias('mautic.api.model.client', \Mautic\ApiBundle\Model\ClientModel::class);
};
3 changes: 3 additions & 0 deletions app/bundles/ApiBundle/Controller/CommonApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ public function newEntityAction(Request $request)
return $this->processForm($request, $entity, $parameters, 'POST');
}

/**
* @return FormInterface<mixed>
*/
protected function createEntityForm($entity): FormInterface
{
return $this->model->createForm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public function onPostAuthorizationProcess(PreAuthorizationEvent $event): void
*/
protected function getUser(PreAuthorizationEvent $event)
{
return $this->em->getRepository(\Mautic\UserBundle\Entity\User::class)->findOneByUsername($event->getUser()->getUsername());
return $this->em->getRepository(\Mautic\UserBundle\Entity\User::class)->findOneByUsername($event->getUser()->getUserIdentifier());
}
}
6 changes: 5 additions & 1 deletion app/bundles/ApiBundle/Form/Type/ClientType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mautic\ApiBundle\Form\Type;

use Mautic\ApiBundle\Entity\oAuth2\Client;
use Mautic\ApiBundle\Form\Validator\Constraints\OAuthCallback;
use Mautic\CoreBundle\Form\DataTransformer as Transformers;
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
Expand All @@ -21,6 +22,9 @@
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @extends AbstractType<Client>
*/
class ClientType extends AbstractType
{
public function __construct(
Expand Down Expand Up @@ -160,7 +164,7 @@ function (FormEvent $event): void {

public function configureOptions(OptionsResolver $resolver): void
{
$dataClass = \Mautic\ApiBundle\Entity\oAuth2\Client::class;
$dataClass = Client::class;
$resolver->setDefaults(
[
'data_class' => $dataClass,
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/ApiBundle/Form/Type/ConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* @extends AbstractType<mixed>
*/
class ConfigType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
7 changes: 0 additions & 7 deletions app/bundles/AssetBundle/Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
'tag' => \Doctrine\Bundle\FixturesBundle\DependencyInjection\CompilerPass\FixturesCompilerPass::FIXTURE_TAG,
],
],
'repositories' => [
'mautic.asset.repository.download' => [
'class' => Doctrine\ORM\EntityRepository::class,
'factory' => ['@doctrine.orm.entity_manager', 'getRepository'],
'arguments' => \Mautic\AssetBundle\Entity\Download::class,
],
],
],

'parameters' => [
Expand Down
4 changes: 3 additions & 1 deletion app/bundles/AssetBundle/Config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
$services->load('Mautic\\AssetBundle\\', '../')
->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}');

$services->load('Mautic\\AssetBundle\\Entity\\', '../Entity/*Repository.php');
$services->load('Mautic\\AssetBundle\\Entity\\', '../Entity/*Repository.php')
->tag(\Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
$services->alias('mautic.asset.helper.token', \Mautic\AssetBundle\Helper\TokenHelper::class);
$services->alias('mautic.asset.model.asset', \Mautic\AssetBundle\Model\AssetModel::class);
$services->alias(\Oneup\UploaderBundle\Templating\Helper\UploaderHelper::class, 'oneup_uploader.templating.uploader_helper');
$services->alias('mautic.asset.repository.download', \Mautic\AssetBundle\Entity\DownloadRepository::class);
};
3 changes: 3 additions & 0 deletions app/bundles/AssetBundle/Form/Type/AssetListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @extends AbstractType<mixed>
*/
class AssetListType extends AbstractType
{
public function __construct(
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/AssetBundle/Form/Type/AssetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @extends AbstractType<Asset>
*/
class AssetType extends AbstractType
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @extends AbstractType<mixed>
*/
class CampaignEventAssetDownloadType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/AssetBundle/Form/Type/ConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* @extends AbstractType<mixed>
*/
class ConfigType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @extends AbstractType<mixed>
*/
class FormSubmitActionDownloadFileType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @extends AbstractType<mixed>
*/
class PointActionAssetDownloadType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// All published campaigns
/** @var \Doctrine\ORM\Internal\Hydration\IterableResult $campaigns */
$campaigns = $this->campaignRepository->getEntities(['iterator_mode' => true]);
$campaigns = $this->campaignRepository->getEntities([
'iterator_mode' => true,
'orderBy' => 'c.dateAdded',
'orderByDir' => 'DESC',
]);

while (false !== ($next = $campaigns->next())) {
// Key is ID and not 0
Expand Down
37 changes: 0 additions & 37 deletions app/bundles/CampaignBundle/Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,43 +103,6 @@
],

'services' => [
'repositories' => [
'mautic.campaign.repository.campaign' => [
'class' => Doctrine\ORM\EntityRepository::class,
'factory' => ['@doctrine.orm.entity_manager', 'getRepository'],
'arguments' => [
\Mautic\CampaignBundle\Entity\Campaign::class,
],
],
'mautic.campaign.repository.lead' => [
'class' => Doctrine\ORM\EntityRepository::class,
'factory' => ['@doctrine.orm.entity_manager', 'getRepository'],
'arguments' => [
\Mautic\CampaignBundle\Entity\Lead::class,
],
],
'mautic.campaign.repository.event' => [
'class' => Doctrine\ORM\EntityRepository::class,
'factory' => ['@doctrine.orm.entity_manager', 'getRepository'],
'arguments' => [
\Mautic\CampaignBundle\Entity\Event::class,
],
],
'mautic.campaign.repository.lead_event_log' => [
'class' => Doctrine\ORM\EntityRepository::class,
'factory' => ['@doctrine.orm.entity_manager', 'getRepository'],
'arguments' => [
\Mautic\CampaignBundle\Entity\LeadEventLog::class,
],
],
'mautic.campaign.repository.summary' => [
'class' => Doctrine\ORM\EntityRepository::class,
'factory' => ['@doctrine.orm.entity_manager', 'getRepository'],
'arguments' => [
\Mautic\CampaignBundle\Entity\Summary::class,
],
],
],
'execution' => [
'mautic.campaign.contact_finder.kickoff' => [
'class' => \Mautic\CampaignBundle\Executioner\ContactFinder\KickoffContactFinder::class,
Expand Down
8 changes: 7 additions & 1 deletion app/bundles/CampaignBundle/Config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
$services->load('Mautic\\CampaignBundle\\', '../')
->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}');

$services->load('Mautic\\CampaignBundle\\Entity\\', '../Entity/*Repository.php');
$services->load('Mautic\\CampaignBundle\\Entity\\', '../Entity/*Repository.php')
->tag(\Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
$services->alias('mautic.campaign.model.campaign', \Mautic\CampaignBundle\Model\CampaignModel::class);
$services->alias('mautic.campaign.model.event', \Mautic\CampaignBundle\Model\EventModel::class);
$services->alias('mautic.campaign.model.event_log', \Mautic\CampaignBundle\Model\EventLogModel::class);
$services->alias('mautic.campaign.model.summary', \Mautic\CampaignBundle\Model\SummaryModel::class);
$services->alias('mautic.campaign.repository.campaign', \Mautic\CampaignBundle\Entity\CampaignRepository::class);
$services->alias('mautic.campaign.repository.lead', \Mautic\CampaignBundle\Entity\LeadRepository::class);
$services->alias('mautic.campaign.repository.event', \Mautic\CampaignBundle\Entity\EventRepository::class);
$services->alias('mautic.campaign.repository.lead_event_log', \Mautic\CampaignBundle\Entity\LeadEventLogRepository::class);
$services->alias('mautic.campaign.repository.summary', \Mautic\CampaignBundle\Entity\SummaryRepository::class);
};
23 changes: 23 additions & 0 deletions app/bundles/CampaignBundle/Entity/CampaignRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,4 +588,27 @@ public function fetchEmailIdsById($id): array

return $return;
}

/**
* @return array<int, int>
*/
public function getCampaignIdsWithDependenciesOnEmail(int $emailId): array
{
$query = $this->getEntityManager()
->createQueryBuilder()
->select($this->getTableAlias().'.id')
->distinct()
->from(Campaign::class, $this->getTableAlias(), $this->getTableAlias().'.id')
->leftJoin(
$this->getTableAlias().'.events',
'e',
Expr\Join::WITH,
"e.channel = '".Event::CHANNEL_EMAIL."'"
)
->where('e.channelId = :emailId')
->setParameter('emailId', $emailId)
->getQuery();

return array_unique(array_map(fn ($val): int => (int) $val, $query->getSingleColumnResult()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @extends AbstractType<mixed>
*/
class CampaignEventAddRemoveLeadType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* @extends AbstractType<mixed>
*/
class CampaignEventJumpToEventType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* @deprecated since Mautic 5.0, to be removed in 6.0 with no replacement.
*
* @extends AbstractType<mixed>
*/
class CampaignEventLeadChangeType extends AbstractType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* @extends AbstractType<mixed>
*/
class CampaignLeadSourceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/CampaignBundle/Form/Type/CampaignListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @extends AbstractType<mixed>
*/
class CampaignListType extends AbstractType
{
/**
Expand Down
6 changes: 5 additions & 1 deletion app/bundles/CampaignBundle/Form/Type/CampaignType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mautic\CampaignBundle\Form\Type;

use Mautic\CampaignBundle\Entity\Campaign;
use Mautic\CategoryBundle\Form\Type\CategoryListType;
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
use Mautic\CoreBundle\Form\EventListener\FormExitSubscriber;
Expand All @@ -18,6 +19,9 @@
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @extends AbstractType<Campaign>
*/
class CampaignType extends AbstractType
{
public function __construct(
Expand Down Expand Up @@ -117,7 +121,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => \Mautic\CampaignBundle\Entity\Campaign::class,
'data_class' => Campaign::class,
]);
}
}
3 changes: 3 additions & 0 deletions app/bundles/CampaignBundle/Form/Type/ConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @extends AbstractType<mixed>
*/
class ConfigType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @extends AbstractType<mixed>
*/
class EventCanvasSettingsType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/CampaignBundle/Form/Type/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @extends AbstractType<mixed>
*/
class EventType extends AbstractType
{
use PropertiesTrait;
Expand Down
Loading

0 comments on commit b1f1e4a

Please sign in to comment.