I installed (via composer) the version of the module for core 8.7 or higher (since I am running 8.9.2) and attempted to run an export of an existing taxonomy on my system. I got the following error regardless of no check boxes, or any combination of checkboxes selected.

ERROR DUMP:
Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\term_csv_export_import\Controller\ExportController->execute() (line 68 of modules/contrib/term_csv_export_import/src/Controller/ExportController.php).
Drupal\term_csv_export_import\Controller\ExportController->execute(0, 0, 0) (Line: 109)
Drupal\term_csv_export_import\Form\ExportForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('export_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

This error continues to repeat ...

I am running it as a non-production system where I am doing development of various components for eventual use. The configuration of the system I am running is as follows:

Checked
ACCESS TO UPDATE.PHP
Protected
CKEDITOR IFRAME
Plugin detected
CONFIGURATION FILES
Protected
DATABASE SYSTEM
MySQL, MariaDB, Percona Server, or equivalent
DATABASE SYSTEM VERSION
5.5.5-10.1.38-MariaDB
DATABASE UPDATES
Up to date
DRUPAL CORE SECURITY COVERAGE
Covered until 2021-Nov
Visit the release cycle overview for more information on supported releases.
DRUPAL CORE UPDATE STATUS
Up to date
ENTITY/FIELD DEFINITIONS
Up to date
FAKEOBJECTS
Plugin detected
FILE SYSTEM
Writable (public download method)
GD LIBRARY
bundled (2.1.0 compatible)
GD LIBRARY PNG SUPPORT
bundled (2.1.0 compatible)
IMAGE TOOLKIT
gd
GD2 image manipulation toolkit
MODULE AND THEME UPDATE STATUS
Up to date
NODE ACCESS PERMISSIONS
Disabled
If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to content and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed, content will automatically use the new permissions. Rebuild permissions
PHP
7.3.4 (more information)
PHP APCU CACHING
Not enabled
PHP APCu caching can improve your site's performance considerably. It is highly recommended to have APCu installed on your server.
PHP EXTENSIONS
Enabled
PHP MEMORY LIMIT
2048M
PHP OPCODE CACHING
Enabled
RANDOM NUMBER GENERATION
Successful
SEARCH INDEX PROGRESS
100% (0 remaining)
UNICODE LIBRARY
PHP Mbstring Extension
UPDATE NOTIFICATIONS
Enabled
UPLOAD PROGRESS
Not enabled
Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library.
WEB SERVER
Apache/2.4.39 (Unix) OpenSSL/1.0.2r PHP/7.3.4 mod_perl/2.0.8-dev Perl/v5.16.3

CommentFileSizeAuthor
#12 3162692-12.patch850 bytesel1_1el

Comments

emofsnead created an issue. See original summary.

emofsnead’s picture

I continue to get the errors I listed. But paging down through a huge redundant dump list of what I show the error saying, I actually find output in the display window at the end. Below I have pasted two views of what that output looks like [just part of what is a very extensive taxonomy to show the layout]. The first is a view of what the output looks like raw as I paste it into a Text Editor file. The second is a look after I import the text file as a CSV file [delimiter = comma, 'treat consecutive delimiters as one', and text qualifier = "] {Mac based Excel import].

Text File View of output:
name,status,description__value,description__format,weight,parent_name
African,1,,,0,
"East African",1,,,0,African;
Burund,1,,,0,"East African;"
Eritrean,1,,,1,"East African;"
Ethiopian,1,,,2,"East African;"
Kenyan,1,,,3,"East African;"
Somali,1,,,4,"East African;"
Tanzanian,1,,,5,"East African;"
Ugandan,1,,,6,"East African;"
Maasai,1,,,7,"East African;"
"North African",1,,,1,African;
Algerian,1,,,0,"North African;"
Egyptian,1,,,1,"North African;"
Libyan,1,,,2,"North African;"
Sudanese,1,,,3,"North African;"
Tunisian,1,,,4,"North African;"
"South African",1,,,2,African;
Botswana,1,,,0,"South African;"
Malagasy,1,,,1,"South African;"
Mauritian,1,,,2,"South African;"
Namibian,1,,,3,"South African;"
"South African",1,,,4,"South African;"
Zimbabwean,1,,,5,"South African;"
"West African",1,,,3,African;
Burkinabe,1,,,0,"West African;"
Ghanaian,1,,,1,"West African;"
Ivorian,1,,,2,"West African;"

CSV File View of Output:
name status description format weight parent_name
African 1 0
East African 1 0 African;
Burund 1 0 East African;
Eritrean 1 1 East African;
Ethiopian 1 2 East African;

Since this layout doesn't hold, the key thing is that the name, status, weight, and parent_name columns populate logically; the description and format columns are empty in all rows except the first header row when that checkbox option is selected.

el1_1el’s picture

Try against dev version. I may have time to look next week. Patches always welcome!

emofsnead’s picture

I tried the Dev version and got the same error and result.

el1_1el’s picture

So if you are on the dev version, the same error would be on line 92 so first verify that is the case.

As far as the object causing the error mentioned, that would be $parents = $this->termStorage->loadParents($term->tid); on line 87 of src/ExportController.php in the latest dev version (I really need to do real releases for 9 but have not gotten to it). So its probably something with a parent term.

Of note, Using 3x-dev and 8.9.2, I successfully imported:
African,1,,,0,
"East African",1,,,0,African;
Burund,1,,,0,"East African;"
Eritrean,1,,,1,"East African;"
Ethiopian,1,,,2,"East African;"
Kenyan,1,,,3,"East African;"
Somali,1,,,4,"East African;"
Tanzanian,1,,,5,"East African;"
Ugandan,1,,,6,"East African;"
Maasai,1,,,7,"East African;"
"North African",1,,,1,African;
Algerian,1,,,0,"North African;"
Egyptian,1,,,1,"North African;"
Libyan,1,,,2,"North African;"
Sudanese,1,,,3,"North African;"
Tunisian,1,,,4,"North African;"
"South African",1,,,2,African;
Botswana,1,,,0,"South African;"
Malagasy,1,,,1,"South African;"
Mauritian,1,,,2,"South African;"
Namibian,1,,,3,"South African;"
"South African",1,,,4,"South African;"
Zimbabwean,1,,,5,"South African;"
"West African",1,,,3,African;
Burkinabe,1,,,0,"West African;"
Ghanaian,1,,,1,"West African;"
Ivorian,1,,,2,"West African;"
at /admin/config/content/term-csv-import and got a three level taxonomy. The only warning on import was "More than 1 terms are named South African;. Cannot distinguish by name. Try using id export/import.", which makes sense since you have both a region term and a specific country term.

When that was imported, I successfully exported the following without error:
African,1,,,0,
"East African",1,,,0,African;
Burund,1,,,0,"East African;"
Eritrean,1,,,1,"East African;"
Ethiopian,1,,,2,"East African;"
Kenyan,1,,,3,"East African;"
Somali,1,,,4,"East African;"
Tanzanian,1,,,5,"East African;"
Ugandan,1,,,6,"East African;"
Maasai,1,,,7,"East African;"
"North African",1,,,1,African;
Algerian,1,,,0,"North African;"
Egyptian,1,,,1,"North African;"
Libyan,1,,,2,"North African;"
Sudanese,1,,,3,"North African;"
Tunisian,1,,,4,"North African;"
"South African",1,,,2,African;
Botswana,1,,,0,"South African;"
Malagasy,1,,,1,"South African;"
Mauritian,1,,,2,"South African;"
Namibian,1,,,3,"South African;"
"South African",1,,,4,"South African;"
"West African",1,,,3,African;
Burkinabe,1,,,0,"West African;"
Ghanaian,1,,,1,"West African;"
Ivorian,1,,,2,"West African;"
Zimbabwean,1,,,5,

and also did the same with term ids and uuids. If you could send more of your taxonomy i might be able to assist further.

el1_1el’s picture

Version: 8.x-3.0-alpha1 » 8.x-3.x-dev
Priority: Normal » Minor
Status: Active » Needs work

So I just checked logs and now see the warning you described. Since its just a php warning and not a fatal error I'll mark this as needs work and minor priority.

If it is a fatal error for you please change the status and priority.

Also feel free to write a patch for the warning. It would likely look something like:

-if (!empty($parents)) {
+if (!empty($parents) && (is_array($parents) || is_object($parents))) {

on line 91 of the dev version. thanks!

emofsnead’s picture

Here is the updated error code segment (meaning it repeats for pages). And you are correct that it is showing line number 92.

Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\term_csv_export_import\Controller\ExportController->execute() (line 92 of modules/contrib/term_csv_export_import/src/Controller/ExportController.php).
Drupal\term_csv_export_import\Controller\ExportController->execute(1, 1, 0) (Line: 109)
Drupal\term_csv_export_import\Form\ExportForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('export_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

It does appear to be exporting even with the error. I will try to do some more tests on other taxonomies and with reimporting some of my exports to see if they are working. I am NOT a php programmer, so I don't know if I will be much help on a patch. But I will take a look at the code and see if I piece enough together to come up with anything.

emofsnead’s picture

I am leaving your priority classification as you put it. My test was successful in using a copy of one of my exports to do an import with create new forum (giving it a different name). So the module is functional even though throwing the error.

Thanks for looking.

el1_1el’s picture

Thanks emofsnead!

It's a warning not an error. So it should be fixed for sure, but isn't really hurting anything atm.

emofsnead’s picture

Wanted to give you an update on what might be triggering the warning. It may have to do with the size or depth of the taxonomy structure. I did four additional taxonomies around meal occasions, dietary restrictions, and a few other much smaller classification concepts; these exporting with no warning. The one that is still triggering the warnings is centered around Cuisines and is extensive because it is meant to be international in scope. Thus is has Continent, Country, Region within Country and various subclassifications beyond that. The total line count on export is right at 400 without header. So while the breadth may stay within four, it combines with substantial depth per subgroup. These may be driving the issue... but, it is these very complex taxonomies you want to have a back up for more than any other. So they are definitely worth pursuing for import/export.

Thanks for you efforts on this module.

el1_1el’s picture

Title: Export not functioning: Drupal 8.9.2 - 8.x-3.0-alpha1 released 14 June 2019 » Remove php warning on nested taxonomies
Issue tags: -Non-functional export
el1_1el’s picture

Status: Needs work » Patch (to be ported)
StatusFileSize
new850 bytes

  • el1_1el authored 4a8f528 on 8.x-3.x
    Issue #3162692 by el1_1el: Remove php warning on nested taxonomies
    
el1_1el’s picture

Status: Patch (to be ported) » Fixed

This should be fixed. I had a mental error on the count that made it always true, so I just removed that part. Let me know if you still have issues and thanks for finding this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.