Fixed Fatal Error when executing queries using command

Dadparvar

Well-known member
This is my Setup.php file:
PHP:
<?php

namespace Dadparvar\FloatingMenu;

use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
use XF\Db\Schema\Alter;
use XF\Db\Schema\Create;

class Setup extends AbstractSetup
{
    use StepRunnerInstallTrait;
    use StepRunnerUpgradeTrait;
    use StepRunnerUninstallTrait;

    public function installStep1()
    {
        $this->schemaManager()->alterTable('xf_user_option', function (Alter $table)
        {
            $table->addColumn('dadparvar_floatingmenu_show', 'tinyint', 3)->setDefault(1);
        });
    }

    public function installStep2()
    {
        $this->schemaManager()->createTable('xf_dadparvar_floatingmenu_item', function (Create $table)
        {
            $table->addColumn('item_id', 'int')->autoIncrement();
            $table->addColumn('parent_id', 'int')->setDefault(0);
            $table->addColumn('title', 'varchar', '150');
            $table->addColumn('icon', 'varchar', '150')->setDefault('');
            $table->addColumn('link', 'varchar', '200')->setDefault('');
            $table->addColumn('description', 'varchar', '250')->setDefault('');
            $table->addColumn('user_criteria', 'mediumblob');
            $table->addColumn('page_criteria', 'mediumblob');
            $table->addColumn('display_order', 'int')->setDefault(0);
            $table->addColumn('target_blank', 'tinyint', 3)->setDefault(0);
            $table->addColumn('open_overlay', 'tinyint', 3)->setDefault(0);
            $table->addColumn('active', 'tinyint', 3)->setDefault(1);
        });
    }
}

And this is the command I use:
Code:
php cmd.php xf-addon:setup-step Dadparvar/FloatingMenu install

The result is:
  • installStep1 correctly executed and the column added
  • installStep2 didn't execute (I get the error below, in PowerShell)
Code:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in C:\wamp64\www\xf2\src\XF\Db\Mysqli\Statement.php on line 122
I should add that memory_limit and upload_max_filesize and post_max_size are set to 1024M.

Questions:
  • Is something wrong with my settings?
  • according to THIS, I couldn't Run a specific Setup step. When I set the step number it says: "Too many arguments, expected arguments "command" "id" "step-type".". Am I doing something wrong?
Thanks in advance
 
What version of MySQL are you using? PHP?

Can you look at your PHP info and report all of the info from the mysqli section and, if present, the mysqlnd section?
 

Attachments

  • mysql.webp
    mysql.webp
    37.4 KB · Views: 4
  • mysqli.webp
    mysqli.webp
    39.2 KB · Views: 5
  • mysqlnd.webp
    mysqlnd.webp
    32.5 KB · Views: 4
I think we've figured this out and it's essentially that the command is being used wrong, but obviously the fact that it is allowed to be used like that is a bug.

The documentation is correct in the parameters it lists, although the ver option is not needed unless you're doing an upgrade.

The correct commands to run in your case would be:
Code:
php cmd.php xf-addon:setup-step Dadparvar/FloatingMenu install --step 1
Code:
php cmd.php xf-addon:setup-step Dadparvar/FloatingMenu install --step 2
etc.

However, it's possible this command will change when this issue is fixed to make it more clear or at least we'll be preventing the issue whereby the step is not required.
 
This has been resolved for the next release.

We've split the command up into several distinct ones depending on the action and changed the input requirements so that it uses arguments rather than options in all cases.
Code:
  xf-addon:install-step <id> <step>
  xf-addon:upgrade-step <id> <version> <step>
  xf-addon:uninstall-step <id> <step>
 
This has been resolved for the next release.

We've split the command up into several distinct ones depending on the action and changed the input requirements so that it uses arguments rather than options in all cases.
Code:
  xf-addon:install-step <id> <step>
  xf-addon:upgrade-step <id> <version> <step>
  xf-addon:uninstall-step <id> <step>

I’m assuming the standard non step commands are still available and are just blocked if the step runner trait is used?

Liam
 
The non-step commands were never supposed to be available through those commands. If you aren't using the step runner trait, just use the standard add-on install/upgrade/uninstall. These commands are specifically for development to ease change imports between developers/environments.
 
Back
Top Bottom