3

My module was implemented and working on Magento 2.2.

We are moving to Magento 2.3, but failed in Declarative Schema.

I follow this. Created db_schema.xml. Following is the example

    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">

   <table name="options" resource="default" engine="innodb" comment="Option entities">
        <column xsi:type="int" name="option_id" padding="10" unsigned="true" identity="true" nullable="false" comment="Option Id"/>
        <column xsi:type="varchar" name="name" nullable="false" length="255" comment="Option name"/>
        <column xsi:type="varchar" name="value" nullable="false" length="255" comment="Option value"/>
        <column xsi:type="timestamp" name="created" comment="Time of event"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="option_id"/>
        </constraint>
    </table>
</schema>

Then, whatever commands I tried to run returns the same error..

PHP Fatal error:  Uncaught TypeError: Return value of Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder::processTable() must be an instance of Magento\Framework\Setup\Declaration\Schema\Dto\Table, boolean returned in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php:251
Stack trace:
#0 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php(148): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->processTable(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema), Array)
#1 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\SchemaConfig.php(78): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->build(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema))
#2 C:\xampp\htdocs\magento23\setup\src\Magento\Setup\Model\DeclarationInstaller.php(57): Magento\Framework\Setup\Declaration\Schema\SchemaConfig->getDeclarationConfig()
#3 C:\ in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php on line 251

Fatal error: Uncaught TypeError: Return value of Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder::processTable() must be an instance of Magento\Framework\Setup\Declaration\Schema\Dto\Table, boolean returned in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php:251
Stack trace:
#0 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php(148): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->processTable(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema), Array)
#1 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\SchemaConfig.php(78): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->build(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema))
#2 C:\xampp\htdocs\magento23\setup\src\Magento\Setup\Model\DeclarationInstaller.php(57): Magento\Framework\Setup\Declaration\Schema\SchemaConfig->getDeclarationConfig()
#3 C:\ in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php on line 251

Commands which produces the above error:

bin/magento setup:db-declaration:generate-whitelist   
bin/magento module:upgrade

I tried to install the module on a fresh installed Magento 2.3

Can anyone please help?

  • 1
    Please check my ans and let me know if you have any issue. – Aasim Goriya Feb 7 at 5:25
6

I had the exact same issue and discovered it was caused in a custom module. The problem was that setAreaCode() was called in the constructor. I relocated setAreaCode() into the execute() method and the issue was fixed.

  • 1
    Seems like any php or Magento functions can cause this output error. So I traced all the module code to find the bugs. The error did not even related to the declarative schema... After fix the error, upgrade can run. – BlueTong Feb 13 at 7:15
  • @BlueTong Could you tell us more about the bug you found that causes this? I also ran into this problem while following Alan Storm's tutorial on Object Repositories and the solution in this answer made the error go away. – Spencer Williams Sep 16 at 19:19

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.