hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
939 stars 558 forks source link

[config:export:content:type] Error: Class 'SplFileInfo' does not have a method 'serialize' #4006

Open FirstSanny opened 5 years ago

FirstSanny commented 5 years ago

Problem/Motivation

When trying to export my config the console runs into an error. That happens for every content type i'm trying to export.

Errors


 [ERROR] <em class="placeholder">Warning</em>: call_user_func_array() expects parameter 1 to be a valid callback,
         class 'SplFileInfo' does not have a method 'serialize' in <em
         class="placeholder">Drupal\Core\Extension\Extension-&gt;__call()</em> (line <em class="placeholder">160</em>
         of <em class="placeholder">core/lib/Drupal/Core/Extension/Extension.php</em>). <pre
         class="backtrace">Drupal\Core\Extension\Extension-&gt;__call(&#039;serialize&#039;, Array) (Line: 314)
         Drupal\Console\Extension\Manager-&gt;createExtension(Object) (Line: 251)
         Drupal\Console\Extension\Manager-&gt;getModule(&#039;address&#039;) (Line: 86)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;exportConfigToModule(&#039;address&#039;,
         &#039;Exporting content type&#039;) (Line: 183)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;execute(Object, Object) (Line: 255)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 978)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 255)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/var/app/current/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>

 [ERROR] <em class="placeholder">Warning</em>: call_user_func_array() expects parameter 1 to be a valid callback,
         class 'SplFileInfo' does not have a method 'unserialize' in <em
         class="placeholder">Drupal\Core\Extension\Extension-&gt;__call()</em> (line <em class="placeholder">160</em>
         of <em class="placeholder">core/lib/Drupal/Core/Extension/Extension.php</em>). <pre
         class="backtrace">Drupal\Core\Extension\Extension-&gt;__call(&#039;unserialize&#039;, Array) (Line: 314)
         Drupal\Console\Extension\Manager-&gt;createExtension(Object) (Line: 251)
         Drupal\Console\Extension\Manager-&gt;getModule(&#039;address&#039;) (Line: 86)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;exportConfigToModule(&#039;address&#039;,
         &#039;Exporting content type&#039;) (Line: 183)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;execute(Object, Object) (Line: 255)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 978)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 255)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/var/app/current/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>

Example Log

[ec2-user@ip-123-45-67-890 current]$ drupal config:export:content:type page
 Enter the module name [address]:
 >

 Export content type in module as an optional configuration (yes/no) [yes]:
 > no

 commands.config.export.content.type.questions.remove-uuid (yes/no) [yes]:
 >

 commands.config.export.content.type.questions.remove-config-hash (yes/no) [yes]:
 >

 Exporting content type
 - modules/contrib/address/config/install/node.type.page.yml
 - modules/contrib/address/config/install/field.field.node.page.body.yml
 - modules/contrib/address/config/install/field.storage.node.body.yml
 - modules/contrib/address/config/install/core.entity_form_display.node.page.default.yml
 - modules/contrib/address/config/install/core.entity_view_display.node.page.default.yml
 - modules/contrib/address/config/install/core.entity_view_display.node.page.teaser.yml
 - modules/contrib/address/config/install/core.entity_view_mode.node.teaser.yml

Solutions

Didn't tried something yet.

Eli-TW commented 5 years ago

I can replicate the same error on the latest dev branch of console and console-core

mandrius commented 5 years ago

I'm getting the same error during custom content entity generation (drupal generate:entity:content).

chandu7929 commented 5 years ago

I'm also getting the same error during custom content entity generation (drupal generate:entity:content).

tbenice commented 5 years ago

Having the same problem with gprr. The class is there but the yml file is not.

marcelgast commented 5 years ago

Getting the same errors when running drupal generate:command

LOBsTerr commented 5 years ago

So, the problem here that class \Drupal\Core\Extension\Extension doesn't implement Serializable interface anymore

8.6 https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension%21Extension.php/class/Extension/8.6.x

8.2 https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension%21Extension.php/class/Extension/8.2.x

I'm looking for a solution

LOBsTerr commented 5 years ago

PR https://github.com/hechoendrupal/drupal-console/pull/4013/files

It is a quick solution for now.

My proposal: I think we should create a proxy class and not directly extend \Drupal\Core\Extension\Extension This class will handle all extensions paths and will contain inside original extension object, but it will touch many modules.

@jmolivas Any ideas?

ludal74 commented 5 years ago

The PR proposed by @LOBsTerr seems to fix the issue, at least for the drupal generate:entity:content command.

codesquatch commented 5 years ago

For a temporary workaround until this is committed you can run drush entup or drupal upe after the failure to install the table(s) in the DB.

GuidoRobertone commented 5 years ago

I can't reproduce the issue:

Drupal version 8.6.15 Console version 1.8.0 Console Launcher version 1.8.0

guido@pavilion:~/Desktop/Guido/www/drupal8-local/web/sites $ drupal config:export:content:type page
 Enter the module name [webform_access]:
 > 

 Export content type in module as an optional configuration (yes/no) [yes]:
 > no

 Content Type to be exported without uuid key. (yes/no) [yes]:
 > 

 Content type to be exported without the default site hash key. (yes/no) [yes]:
 > 

 // config:export:entity

 commands.config.export.entity.questions.optional-config (yes/no) [yes]:
 > 

 commands.config.export.entity.messages.content-type-exported
 - modules/contrib/webform/modules/webform_access/config/optional/node.type.page.yml
 - modules/contrib/webform/modules/webform_access/config/optional/field.field.node.page.body.yml
 - modules/contrib/webform/modules/webform_access/config/optional/field.storage.node.body.yml
 - modules/contrib/webform/modules/webform_access/config/optional/core.entity_form_display.node.page.default.yml
 - modules/contrib/webform/modules/webform_access/config/optional/core.entity_view_display.node.page.default.yml
 - modules/contrib/webform/modules/webform_access/config/optional/core.entity_view_display.node.page.teaser.yml
 - modules/contrib/webform/modules/webform_access/config/optional/core.entity_view_mode.node.teaser.yml
FirstSanny commented 5 years ago

That's interessting. I can still reproduce it with exactly the version numbers you are reffering to. But that means, that the reason could be one of my installed modules?

[ec2-user@ip-123-45-67-890 current]$ drupal config:export:content:type page
 Enter the module name [address]:
 >

 Export content type in module as an optional configuration (yes/no) [yes]:
 > no

 commands.config.export.content.type.questions.remove-uuid (yes/no) [yes]:
 >

 commands.config.export.content.type.questions.remove-config-hash (yes/no) [yes]:
 >

 Exporting content type
 - modules/contrib/address/config/install/node.type.page.yml
 - modules/contrib/address/config/install/field.field.node.page.body.yml
 - modules/contrib/address/config/install/field.storage.node.body.yml
 - modules/contrib/address/config/install/core.entity_form_display.node.page.default.yml
 - modules/contrib/address/config/install/core.entity_view_display.node.page.default.yml
 - modules/contrib/address/config/install/core.entity_view_display.node.page.teaser.yml
 - modules/contrib/address/config/install/core.entity_view_mode.node.teaser.yml

 [ERROR] <em class="placeholder">Warning</em>: call_user_func_array() expects parameter 1 to be a valid callback,
         class 'SplFileInfo' does not have a method 'serialize' in <em
         class="placeholder">Drupal\Core\Extension\Extension-&gt;__call()</em> (line <em class="placeholder">160</em>
         of <em class="placeholder">core/lib/Drupal/Core/Extension/Extension.php</em>). <pre
         class="backtrace">Drupal\Core\Extension\Extension-&gt;__call(&#039;serialize&#039;, Array) (Line: 314)
         Drupal\Console\Extension\Manager-&gt;createExtension(Object) (Line: 251)
         Drupal\Console\Extension\Manager-&gt;getModule(&#039;address&#039;) (Line: 86)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;exportConfigToModule(&#039;address&#039;,
         &#039;Exporting content type&#039;) (Line: 183)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;execute(Object, Object) (Line: 255)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 978)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 255)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/var/app/current/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>

 [ERROR] <em class="placeholder">Warning</em>: call_user_func_array() expects parameter 1 to be a valid callback,
         class 'SplFileInfo' does not have a method 'unserialize' in <em
         class="placeholder">Drupal\Core\Extension\Extension-&gt;__call()</em> (line <em class="placeholder">160</em>
         of <em class="placeholder">core/lib/Drupal/Core/Extension/Extension.php</em>). <pre
         class="backtrace">Drupal\Core\Extension\Extension-&gt;__call(&#039;unserialize&#039;, Array) (Line: 314)
         Drupal\Console\Extension\Manager-&gt;createExtension(Object) (Line: 251)
         Drupal\Console\Extension\Manager-&gt;getModule(&#039;address&#039;) (Line: 86)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;exportConfigToModule(&#039;address&#039;,
         &#039;Exporting content type&#039;) (Line: 183)
         Drupal\Console\Command\Config\ExportContentTypeCommand-&gt;execute(Object, Object) (Line: 255)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 978)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 255)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/var/app/current/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>
LOBsTerr commented 5 years ago

@FirstSanny The fix proposed by me above is not merged to dev version. The problem is not in the specific module. It is related to the update of the core, some code was changed and now we need to adapt DC. Anyway, the command is still generating correctly the content types. If you check the log message above the warnings.

hjuarez20 commented 5 years ago

@LOBsTerr I can't reproduce the issue to review the PR

Drupal version 8.6.11 / 8.7.1 Console version 1.8.0 Console Launcher version 1.8.0

I run the following commands to check and everything was ok

drupal drupal config:export:content:type page
 Enter the module name [demo]:
 >

 Export content type in module as an optional configuration (yes/no) [yes]:
 > no

 commands.config.export.content.type.questions.remove-uuid (yes/no) [yes]:
 >

 commands.config.export.content.type.questions.remove-config-hash (yes/no) [yes]:
 >

 Exporting content type
 - modules/custom/demo/config/install/node.type.page.yml
 - modules/custom/demo/config/install/field.field.node.page.body.yml
 - modules/custom/demo/config/install/field.storage.node.body.yml
 - modules/custom/demo/config/install/core.entity_form_display.node.page.default.yml
 - modules/custom/demo/config/install/core.entity_view_display.node.page.default.yml
 - modules/custom/demo/config/install/core.entity_view_display.node.page.teaser.yml
 - modules/custom/demo/config/install/core.entity_view_mode.node.teaser.yml
drupal generate:entity:content

 // Welcome to the Drupal Content Entity generator
 Enter the module name [demo]:
 >

 Enter the class of your new content entity [DefaultEntity]:
 >

 Enter the machine name of your new content entity [default_entity]:
 >

 Enter the label of your new content entity [Default entity]:
 >

 Enter the base-path for the content entity routes [/admin/structure]:
 >

 Do you want this (content) entity to have bundles? (yes/no) [no]:
 >

 Is your entity translatable? (yes/no) [yes]:
 > no

 Is your entity revisionable? (yes/no) [yes]:
 > no

Generated or updated files
 Generation path: /Users/hjuarez/drupal/web
 1 - modules/custom/demo/demo.permissions.yml
 2 - modules/custom/demo/demo.links.menu.yml
 3 - modules/custom/demo/demo.links.task.yml
 4 - modules/custom/demo/demo.links.action.yml
 5 - modules/custom/demo/src/DefaultEntityAccessControlHandler.php
 6 - modules/custom/demo/src/Entity/DefaultEntityInterface.php
 7 - modules/custom/demo/src/Entity/DefaultEntity.php
 8 - modules/custom/demo/src/DefaultEntityHtmlRouteProvider.php
 9 - modules/custom/demo/src/Entity/DefaultEntityViewsData.php
 10 - modules/custom/demo/src/DefaultEntityListBuilder.php
 11 - modules/custom/demo/src/Form/DefaultEntitySettingsForm.php
 12 - modules/custom/demo/src/Form/DefaultEntityForm.php
 13 - modules/custom/demo/src/Form/DefaultEntityDeleteForm.php
 14 - modules/custom/demo/default_entity.page.inc
 15 - modules/custom/demo/templates/default_entity.html.twig

 Generated lines: "691"
drupal generate:command

 // Welcome to the Drupal Command generator
 Enter the extension name [demo]:
 >

 Enter the Command name. [demo:default]:
 >

 Do you want to add the initialize method? (yes/no) [no]:
 >

 Do you want to add the interact method? (yes/no) [no]:
 >

 Enter the Command Class. (Must end with the word 'Command'). [DefaultCommand]:
 >

 Is the command aware of the drupal site installation when executed? (yes/no) [no]:
 >

 Do you want to load services from the container? (yes/no) [no]:
 >

 Do you want to add a Generator class?. (yes/no) [no]:
 >

 Do you want proceed with the operation? (yes/no) [yes]:
 >

Generated or updated files
 Generation path: /Users/hjuarez/drupal/web
 1 - modules/custom/demo/src/Command/DefaultCommand.php
 2 - modules/custom/demo/console.services.yml
 3 - modules/custom/demo/console/translations/en/demo.default.yml

 Generated lines: "47"
enzolutions commented 5 years ago

Closing the issue, maybe the latest version of Drupal Solve the problem.

LOBsTerr commented 5 years ago

@enzolutions The problem is not in Drupal core, it is in the way we use https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension%21Extension.php/class/Extension/8.2.x class. There is a deep problem with structure of the code. We should have used a separate wrapper class around Extension core class, We still can do it, but it requires changes in many places of DC.

Let me one time review our code structure and I will try to find an easy solution

enzolutions commented 5 years ago

@LOBsTerr Awesome, please refresh your repositories, because we are working actively to try to so a new release 1.9.0 next week.

thuiban commented 5 years ago

Hi, I tried to run drupal generate:entity:content with last version of drupal console (1.9.0) but I always this error. Any have a idea ?

enzolutions commented 5 years ago

Hi @thuiban

Could you provide information about the environment and how are you testing the command?

Kind regards.

thuiban commented 5 years ago

Hi @enzolutions

My env is : Drupal 8.7.2 Drupal Console 1.9.0 Php: 7.3.4 Unix system : Debian

What do you mean about "how are you testing the command" ?

enzolutions commented 5 years ago

@thuiban how are you executing the command an under what parameters, how is your content type defined ( visually), your content type use any special module to add any field?

thuiban commented 5 years ago

Like that:

image
enzolutions commented 5 years ago

@thuiban

So the error is in generate:entity:content not in the config:export:content:type as this issue was open it, right? if that is the case is better to open a new issue.

The warning is because the module already exists and we cannot merge the code with the previous code already implemented, that is something that you have to do manually.

If there is another error that I can't see in the image, please attach the rest of the command in execution.

In case I misunderstood your error, please let me know.

thuiban commented 5 years ago

@enzolutions

The error:

[ERROR] Warning: call_user_func_array() expects parameter 1 to be a valid callback,
class 'SplFileInfo' does not have a method 'serialize' in <em
class="placeholder">Drupal\Core\Extension\Extension->call() (line 160
of core/lib/Drupal/Core/Extension/Extension.php). <pre
class="backtrace">Drupal\Core\Extension\Extension->
call('serialize', Array) (Line: 314)
Drupal\Console\Extension\Manager->createExtension(Object) (Line: 251)
Drupal\Console\Extension\Manager->getModule('palm_custom_module') (Line: 69)
Drupal\Console\Generator\EntityContentGenerator->generate(Array) (Line: 180)
Drupal\Console\Command\Generate\EntityContentCommand->execute(Object, Object) (Line: 255)
Symfony\Component\Console\Command\Command->run(Object, Object) (Line: 987)
Symfony\Component\Console\Application->doRunCommand(Object, Object, Object) (Line: 255)
Symfony\Component\Console\Application->doRun(Object, Object) (Line: 187)
Drupal\Console\Core\Application->doRun(Object, Object) (Line: 64)
Drupal\Console\Application->doRun(Object, Object) (Line: 148)
Symfony\Component\Console\Application->run() (Line: 89)
require('/var/www/html/vendor/drupal/console/bin/drupal.php') (Line: 4)

[ERROR] Warning: call_user_func_array() expects parameter 1 to be a valid callback,
class 'SplFileInfo' does not have a method 'unserialize' in <em
class="placeholder">Drupal\Core\Extension\Extension->call() (line 160
of core/lib/Drupal/Core/Extension/Extension.php). <pre
class="backtrace">Drupal\Core\Extension\Extension->
call('unserialize', Array) (Line: 314)
Drupal\Console\Extension\Manager->createExtension(Object) (Line: 251)
Drupal\Console\Extension\Manager->getModule('palm_custom_module') (Line: 69)
Drupal\Console\Generator\EntityContentGenerator->generate(Array) (Line: 180)
Drupal\Console\Command\Generate\EntityContentCommand->execute(Object, Object) (Line: 255)
Symfony\Component\Console\Command\Command->run(Object, Object) (Line: 987)
Symfony\Component\Console\Application->doRunCommand(Object, Object, Object) (Line: 255)
Symfony\Component\Console\Application->doRun(Object, Object) (Line: 187)
Drupal\Console\Core\Application->doRun(Object, Object) (Line: 64)
Drupal\Console\Application->doRun(Object, Object) (Line: 148)
Symfony\Component\Console\Application->run() (Line: 89)
require('/var/www/html/vendor/drupal/console/bin/drupal.php') (Line: 4)

chrisolof commented 5 years ago

Confirming the bug. I just installed v1.9.0 and now get four of those errors in a row when I add a new entity type to an existing module (drupal generate:entity:content).

thuiban commented 5 years ago

I create about that https://github.com/hechoendrupal/drupal-console/issues/4086

hjuarez20 commented 5 years ago

Hi @LOBsTerr Do you have any news about it?

kviolka commented 5 years ago

Seeing the error too, Drupal 8.7.8, Console 1.8.0

enzolutions commented 5 years ago

@kviolka could you try the latest version 1.9.3, please

lpeabody commented 4 years ago

@enzolutions After updating to console 1.9.4 I can report the SplFileInfo-related error has disappeared.