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

"Undefined index: site_url" warning when installing mautic #9139

Closed
gramakri opened this issue Aug 26, 2020 · 13 comments · Fixed by #9250
Closed

"Undefined index: site_url" warning when installing mautic #9139

gramakri opened this issue Aug 26, 2020 · 13 comments · Fixed by #9250
Assignees
Labels
bug Issues or PR's relating to bugs essential This must be done to close the milestone regression A bug that broke something in the last release T1 Low difficulty to fix (issue) or test (PR)
Milestone

Comments

@gramakri
Copy link

gramakri commented Aug 26, 2020

Bug Description

When installing mautic there is a warning Undefined index: site_url

Q A
Mautic version 3.1.0
PHP version 7.3
Browser CLI

Steps to reproduce

  1. Install mautic via the CLI. I am pasting the command from the Cloudron package:
    sudo -u www-data --preserve-env php /app/code/bin/console mautic:install \
        --db_host="${CLOUDRON_MYSQL_HOST}" \
        --db_port="${CLOUDRON_MYSQL_PORT}" \
        --db_name="${CLOUDRON_MYSQL_DATABASE}" \
        --db_user="${CLOUDRON_MYSQL_USERNAME}" \
        --db_password="${CLOUDRON_MYSQL_PASSWORD}" \
        --db_table_prefix=null \
        --db_backup_tables=false \
        --admin_email=admin@cloudron.local \
        --admin_password=changeme123 \
        -- "${CLOUDRON_APP_ORIGIN}"
  1. See warning messages like below:
  Mautic Install
==============

Parsing options and arguments...
0 - Checking installation requirements...
Ready to Install!
1 - Creating database...
PHP Notice:  Undefined index: site_url in /app/code/app/bundles/InstallBundle/Command/InstallCommand.php on line 500
1.1 - Creating schema...
PHP Notice:  Undefined index: site_url in /app/code/app/bundles/InstallBundle/Command/InstallCommand.php on line 500
1.2 - Loading fixtures...
PHP Notice:  Undefined index: site_url in /app/code/app/bundles/InstallBundle/Command/InstallCommand.php on line 500
2 - Creating admin user...
PHP Notice:  Undefined index: site_url in /app/code/app/bundles/InstallBundle/Command/InstallCommand.php on line 500
3 - Email configuration and final steps...

================
Install complete
================
  1. Note that mautic appears to install fine despite above warnings.
@gramakri gramakri added the needs-triage For new issues/PRs that need to be triaged label Aug 26, 2020
@gramakri
Copy link
Author

I have tried to debug this a bit:

  1. The message comes because of https://github.com/mautic/mautic/blob/staging/app/bundles/InstallBundle/Command/InstallCommand.php#L500 $siteUrl = $params['site_url'];

  2. The above function gets called from https://github.com/mautic/mautic/blob/staging/app/bundles/InstallBundle/Command/InstallCommand.php#L345, https://github.com/mautic/mautic/blob/staging/app/bundles/InstallBundle/Command/InstallCommand.php#L384 . Both dbParams and adminParam do not set have the site_url set. This is the reason for the above warning.

It looks like https://github.com/mautic/mautic/blob/staging/app/bundles/InstallBundle/Command/InstallCommand.php#L499 should only be done with EMAIL_STEP, no?

@gramakri gramakri changed the title "Undefined index: site_url" when installing mautic "Undefined index: site_url" warning when installing mautic Aug 26, 2020
@mabumusa1 mabumusa1 added the bug Issues or PR's relating to bugs label Aug 27, 2020
@mabumusa1 mabumusa1 added this to the 3.1.1 milestone Aug 27, 2020
@mabumusa1
Copy link
Member

@gramakri Thanks for reporting this issue. Would like to make a PR for this issue to fix it? I can support you in case you need help

@mabumusa1 mabumusa1 added regression A bug that broke something in the last release and removed needs-triage For new issues/PRs that need to be triaged labels Aug 31, 2020
@mabumusa1
Copy link
Member

@gramakri following up on this issue? do you mind contribute your code changes?

@gramakri
Copy link
Author

@mabumusa1 Yes, I am interested in getting this fixed. I found this issue when packaging mautic 3 for Cloudron (just recently announced - https://forum.cloudron.io/topic/3165/mautic-3-major-update). I will see if we hit any other issues, so I can work on the items together.

@mabumusa1
Copy link
Member

@gramakri thanks for the contribution, please submit a PR as soon as possible, hopefully, we can get it merged into the next release within a week

@RCheesley
Copy link
Sponsor Member

Also pinging @madmath03 as I think we flagged up this warning when we were testing the install at CLI PR but decided to look into it at a later date.

Bumping this to 3.1.2 - @gramakri if you'd like to work on this we'd need the PR to be submitted and tested before the 18th October.

@RCheesley RCheesley modified the milestones: 3.1.1, 3.1.2 Sep 21, 2020
@madmath03
Copy link
Contributor

Indeed we saw this warning during tests of #7395 with @RCheesley but left it for later as this warning does not seem to impact the install process.

As @gramakri mentioned, the final step could be moved into email step, but I think adding a new index for the final step might be more flexible.
I'm thinking about something like that:

/**
 * Class InstallService.
 */
class InstallService
{
    const CHECK_STEP    = 0;
    const DOCTRINE_STEP = 1;
    const USER_STEP     = 2;
    const EMAIL_STEP    = 3;
    const FINAL_STEP    = 4;

//...
/**
 * CLI Command to install Mautic.
 * Class InstallCommand.
 */
class InstallCommand extends ContainerAwareCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('mautic:install')
            ->setDescription('Installs Mautic')
            ->setHelp('This command allows you to trigger the install process.')
            ->addArgument(
                'site_url',
                InputArgument::REQUIRED,
                'Site URL.',
                null
            )
            ->addArgument(
                'step',
                InputArgument::OPTIONAL,
                'Install process start index. 0 for requirements check, 1 for database, 2 for admin, 3 for configuration, 4 for final step. Each successful step will trigger the next until completion.',
                0
            )
//...

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
//...

        switch ($step) {
//...

                // no break
            case InstallService::EMAIL_STEP:
                $output->writeln($step.' - Email configuration step...');
                $messages = $this->stepAction($installer, $allParams, $step);
                if (is_array($messages) && !empty($messages)) {
                    $output->writeln('Errors in email configuration:');
                    $this->handleInstallerErrors($output, $messages);

                    $output->writeln('Install canceled');

                    return -$step;
                }
                // Keep on with next step
                $step = InstallService::FINAL_STEP;

                // no break
            case InstallService::FINAL_STEP:
                $output->writeln($step.' - Final step..');
                $siteUrl  = $allParams['site_url'];
                $messages = $installer->createFinalConfigStep($siteUrl);

                if (is_bool($messages) && true === $messages) {
                    $installer->finalMigrationStep();
                } else {
                    $output->writeln('Errors in final migration:');
                    $this->handleInstallerErrors($output, $messages);

                    $output->writeln('Install canceled');

                    return -$step;
                }

        }
//...

I can submit a PR for this if you're interested.

@gramakri
Copy link
Author

@madmath03 I am happy to test it if you can submit a PR. Thanks!

@RCheesley
Copy link
Sponsor Member

Please do submit a PR if you are able - would be great to deal with the notice rather than leave folk worrying that something isn't going to work/something broke!

@madmath03
Copy link
Contributor

madmath03 commented Sep 28, 2020

@RCheesley I already did the modification mentioned before but did not had the time to send PR yet.
Will do asap: #9250

madmath03 added a commit to Monogramm/mautic that referenced this issue Sep 28, 2020
Signed-off-by: mathieu.brunot <mathieu.brunot@monogramm.io>
@RCheesley
Copy link
Sponsor Member

@madmath03 thanks for taking a look at that and making the PR! As this is technically a bugfix we could potentially consider it for 3.1.2 if we have enough testing etc :)

@RCheesley RCheesley added the T1 Low difficulty to fix (issue) or test (PR) label Sep 30, 2020
@npracht npracht added the essential This must be done to close the milestone label Sep 30, 2020
@gramakri
Copy link
Author

Thanks for the PR @madmath03 , I will test this today.

@npracht npracht modified the milestones: 3.1.2, 3.2 Oct 19, 2020
maxlawton pushed a commit to MauldinEconomics/mautic that referenced this issue Nov 4, 2020
* develop-3x: (77 commits)
  update release_metadata.json
  Fix Travis Composer config
  Downgrade Composer to 1.10
  Downgrade Composer to 1.10
  Fix Travis merge conflict
  Fix PHP Notice:  Trying to access array offset on value of type null
  Fix PHP notice on PHP 7.4
  Revert Doctrine ORM update (see mautic#8772 for details)
  Update composer hash
  Revert "Fix RequestStack on LeadModel for tests"
  Fix RequestStack on LeadModel for tests
  Fix for Travis trusty
  Force MariaDB to 10.2.23 due to access denied
  Doctrine ORM to 2.7.1 because Travis MariaDB fails
  Downgrade ocramius/package-versions for PHP 7.2
  Downgrade ocramius/proxy-manager to 2.2.3
  composer update to refresh supported PHP versions in .lock
  Removing ext-imap from composer.json requirements as Mautic has internal handling that check if the ext is installed or not
  PageHelperTest fixed
  PHP Notice:  Trying to access array offset on value of type null
  PHP Notice:  Trying to access array offset on value of type null
  PHP Notice:  Trying to access array offset on value of type bool
  Create PageHelper for common pagination calculations
  Fix PHP 7.4 warning
  Increasing max PHP version to PHP 7.4
  Include PHP 7.2
  Make CI 20 minutes faster
  php bin/console mautic:assets:generate content
  Update release_metadata.json
  update readme to add 3.1 branch EOL
  Add comment to clonedId
  Add clonedId to email entity
  Fix error dynamic content without variants
  Refactor method and add unit tests
  Typo
  URL validation improvement
  Fix Codecov in Travis
  Fix CS
  Added test case to cover bugfix
  replace getName() to getBlockPrefix()
  Fix removeDncForLead from contact preference page
  add solution based on evgu comment
  Remove z-index from focus preview to avoid issue without website
  Revert "Fix  cache key contains reserved characters with API limiter"
  Focus preview even If website url doesn't exist
  Fixes a bug where mailer errors are not properly handled in campaign action
  Fix core integrations in windows
  Apply suggestion to add KERNEL_DIR
  Revert "Test preserving global state"
  Test preserving global state
  Isolate only problematic tests
  Optimize Travis config
  Test with Ubuntu Bionic 18.04
  Check if things also work on Focal (20.04)
  Fix ReportBuilder PHP 7.3 warning
  Enable PHPUnit processIsolation
  Exclude all segment tests from LeadBundle
  Looks like this is the problematic test
  Another attempt to fix MariaDB on Travis
  Fix Travis for MariaDB
  Fix typo in PHPUnit config
  Update Travis to Xenial
  Fix parameters var name
  Fix install warnings from mautic#9139
  ...
@npracht npracht removed this from the 3.2.0 milestone Nov 23, 2020
@npracht
Copy link
Member

npracht commented Nov 24, 2020

fixed in 3.1.2

@npracht npracht closed this as completed Nov 24, 2020
@npracht npracht added this to the 3.1.2 milestone Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs essential This must be done to close the milestone regression A bug that broke something in the last release T1 Low difficulty to fix (issue) or test (PR)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants