3

When i run script using this command php bin/magento setup:upgrade its gives this error

[ErrorException] array_key_exists() expects parameter 2 to be array, null given

setup:upgrade [--keep-generated] [--magento-init-params="..."]

In my module i am not using array_key_exists why this error generate,How to solve this error?

Installschema:

namespace Example\Blog\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;


class InstallSchema implements InstallSchemaInterface
{

public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
    $installer = $setup;

    $installer->startSetup();

    $table = $installer->getConnection()->newTable(
        $installer->getTable('blog_post')
    )->addColumn(
        'blogpost_id',
        \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
        null,
        ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
        'Blog Post ID'
    )->addColumn(
        'title',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
       ['nullable' => false],
        'Title'
    )->addColumn(
        'url_key',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
        ['nullable' => false],
        'URL key'
    )->addColumn(
        'content',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        '2M',
        ['nullable' => false],
        'Content'
    )->addColumn(
        'short_content',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        '2M',
        ['nullable' => false],
        'Short Content'
    )->addColumn(
        'image',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
        ['nullable' => false],
        'Featured Image'
    )->addColumn(
        'image_thumb',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
        ['nullable' => false],
        'Thumb Image'
    )->addColumn(
        'category',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
       ['nullable' => false],
        'category'
    )->addColumn(
        'tags',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        null,
        ['nullable' => false],
        'Tags'
    )->addColumn(
        'meta_title',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        '2M',
        ['nullable' => false],
        'Meta Keywords'
    )->addColumn(
        'meta_keywords',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        '2M',
        ['nullable' => false],
        'Meta Keywords'
    )->addColumn(
        'meta_description',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        null,
        ['nullable' => false],
        'Meta Description'
    )->addColumn(
        'publish_date',
        \Magento\Framework\DB\Ddl\Table::TYPE_DATE,
        null,
        [],
        'Publish Date'
    )->addColumn(
        'is_active',
        \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
        null,
        [],
        'Active Status'
    )->addColumn(
        'created_at',
        \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
        null,
        [],
        'Creation Time'
    )->addColumn(
        'update_time',
        \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
        null,
        [],
        'Modification Time'
    )->addColumn(
        'views',
        \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
        null,
        ['nullable' => false],
        'Views'
    )->addColumn(
        'store_id',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
        null,
        ['nullable' => false],
        'Store ID'
    )

    ->setComment(
        'Blog Table'
    );

    $installer->getConnection()->createTable($table);
    $installer->endSetup();

  }
  }
  • post your upgradeschema here – Keyur Shah Dec 14 '15 at 7:07
  • I am not upgrade my module i am install my module – Newbie Dec 14 '15 at 7:11
7

Problem is in below line in fourth argument ,Fourth argument must be array

->addColumn(
        'store_id',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        255,
        null,
        ['nullable' => false],
        'Store ID'
    )

It should be

->addColumn(
            'store_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            255,
            ['nullable' => false],
            'Store ID'
        )

When you look at this

  public function addColumn($name, $type, $size = null, $options = [], $comment = null)

This function accept fourth argument as array thats why it create issue in your setup script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.