After updating the diff module to 8.x-1.0-rc1, I get the following in my log:

Notice: Array to string conversion in Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build() (line 70 of /home/[anonymized]/public_html/modules/diff/src/Plugin/diff/Field/ImageFieldBuilder.php)
 #0 /home/[anonymized]/public_html/core/includes/bootstrap.inc(548): _drupal_error_handler_real(8, 'Array to string...', '/home/[anonymized]...', 70, Array)
 #1 [internal function]: _drupal_error_handler(8, 'Array to string...', '/home/[anonymized]...', 70, Array)
 #2 /home/[anonymized]/public_html/modules/diff/src/Plugin/diff/Field/ImageFieldBuilder.php(70): implode('\n', Array)
 #3 /home/[anonymized]/public_html/modules/diff/src/DiffEntityParser.php(94): Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build(Object(Drupal\file\Plugin\Field\FieldType\FileFieldItemList))
 #4 /home/[anonymized]/public_html/modules/diff/src/DiffEntityComparison.php(96): Drupal\diff\DiffEntityParser->parseEntity(Object(Drupal\node\Entity\Node))
 #5 /home/[anonymized]/public_html/modules/diff/src/Plugin/diff/Layout/SplitFieldsDiffLayout.php(115): Drupal\diff\DiffEntityComparison->compareRevisions(Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node))
 #6 /home/[anonymized]/public_html/modules/diff/src/Controller/PluginRevisionController.php(167): Drupal\diff\Plugin\diff\Layout\SplitFieldsDiffLayout->build(Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node))
 #7 /home/[anonymized]/public_html/modules/diff/src/Controller/NodeRevisionController.php(49): Drupal\diff\Controller\PluginRevisionController->compareEntityRevisions(Object(Drupal\Core\Routing\CurrentRouteMatch), Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), 'split_fields')
 #8 [internal function]: Drupal\diff\Controller\NodeRevisionController->compareNodeRevisions(Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), 'split_fields')
 #9 /home/[anonymized]/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
 #10 /home/[anonymized]/public_html/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
 #11 /home/[anonymized]/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
 #12 /home/[anonymized]/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
 #13 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
 #14 /home/[anonymized]/public_html/vendor/symfony/http-kernel/HttpKernel.php(139): call_user_func_array(Object(Closure), Array)
 #15 /home/[anonymized]/public_html/vendor/symfony/http-kernel/HttpKernel.php(62): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
 #16 /home/[anonymized]/public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #17 /home/[anonymized]/public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #18 /home/[anonymized]/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #19 /home/[anonymized]/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #20 /home/[anonymized]/public_html/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #21 /home/[anonymized]/public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #22 /home/[anonymized]/public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #23 /home/[anonymized]/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #24 /home/[anonymized]/public_html/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
 #25 /home/[anonymized]/public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #26 {main}.

Issue fork diff-2844337

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dhendriks created an issue. See original summary.

znak’s picture

The problem lies in the fact that the line "implode ($separator, $result[$field_key])" may as $separator arrive array and function will not work. Check it please.

VladimirMarko’s picture

Assigned: Unassigned » VladimirMarko
Status: Active » Postponed (maintainer needs more info)

@dhendriks:
From which Diff version did you update?

dhendriks’s picture

I updated from Diff 8.x-1.0-beta2 to Diff 8.x-1.0-rc1.

VladimirMarko’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Discussed this with @Berdir.
We don't see how that update could have caused this bug. None of the relevant code has been changed.

If you want, you can share your configuration file. That should make clear what's corrupted.
(admin/config/development/configuration/single/export: "Simple configuration" and "diff.plugins". You are looking for property_separator in the output. In a valid configuration, the value has to be a string, e.g., property_separator: 'nl'.)

You can then fix that manually in admin/config/content/diff/fields.
(Find the relevant item(s) in the list. Open its drop-down options. Set "Property separator" to whatever you want. Click "Update". Click "Save".)

Instead, you can also run this piece of code:

$result = [];
$root =  \Drupal::configFactory()->get('diff.plugins')->get('fields');
foreach ($root as $key_0 => $value_0) {
  foreach ($value_0 as $key_1 => $value_1) {
    if (isset($root[$key_0][$key_1]['settings'])) {
      if (isset($root[$key_0][$key_1]['settings']['property_separator'])) {
        $result['fields.' . $key_0 . '.'  . $key_1 . '.settings.property_separator'] = $root[$key_0][$key_1]['settings']['property_separator'];
      }
    }
  }
}

$replacement_separator = 'nl'; 
$config = \Drupal::configFactory()->getEditable('diff.plugins');
foreach ($result as $key => $value) {
  if (!is_string($value)) {
    $config->set($key, $replacement_separator);
  }
}
$config->save();

The first part should get you all configured property separators into $result. The second part sets non-string ones to $replacement_separator. This should fix the bug.

dhendriks’s picture

Status: Closed (cannot reproduce) » Active
StatusFileSize
new10.37 KB

OK, I checked my configuration. See attachment. I only see 'property_separator: nl', no other property separator values. I also checked this in an SQL dump of the configuration, and there I only see 's:18:"property_separator";s:2:"nl"'. I triple-checked it by checking the Diff configuration page on my website, and there it also lists 'New line' as 'Property separator'.

Then I tried to change all property separators to 'Space' and save that. Then I changed all of them back to 'New line' and saved that. This also did not help, I still get the log entries.

Since this does not appear to be the cause of the problem, I changed the 'Status' back to 'Active'.

dhendriks’s picture

Just to be sure I also tried your code. Adding a 'var_dump($result);' I get:

array(6) { ["fields.node.field_banner_afbeelding.settings.property_separator"]=> string(2) "nl" ["fields.node.field_bestand.settings.property_separator"]=> string(2) "nl" ["fields.node.field_bijlages.settings.property_separator"]=> string(2) "nl" ["fields.node.field_image.settings.property_separator"]=> string(2) "nl" ["fields.node.field_logo.settings.property_separator"]=> string(2) "nl" ["fields.node.field_sponsorlogos.settings.property_separator"]=> string(2) "nl" } 

I also included the second part, but let it print something instead of changing the configuration. It didn't print anything.

VladimirMarko’s picture

Assigned: VladimirMarko » Unassigned

Sorry, I can't figure out what's wrong. Maybe someone else can help you.

johnchque’s picture

I cannot reproduce the bug either. :(

VladimirMarko’s picture

Maybe it was just corrupted cache?

johnchque’s picture

Status: Active » Postponed (maintainer needs more info)

We cannot reproduce, can you check again please?

abhay.agarwal’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new74.95 KB
new53.04 KB
new1.23 KB

I was replicating this issue and found some more thumbnail related issues::

  • There was mismatch in thumbnails count and placement of thumbnails in diff preview (For images more than three)
  • Above mentioned notices were also coming

Attaching screenshots for the same and also the patch for the same issues.

Status: Needs review » Needs work

The last submitted patch, diff-remove-thumbnails-errors-2844337-12.patch, failed testing. View results

neelam.chaudhary’s picture

StatusFileSize
new1.15 KB

Fixing above mentioned notices and there were some other errors like::

  • Count of the thumbnails and the sequence is coming wrong (When there are more than three images uploaded)

Fixing these issues with the attached patch.

neelam.chaudhary’s picture

Status: Needs work » Needs review
johnchque’s picture

Status: Needs review » Needs work

Count of the thumbnails and the sequence is coming wrong (When there are more than three images uploaded)

Is better to fix this kind of bugs/problems in a specific issue so we don't get out of scope.

Test failing.

neelam.chaudhary’s picture

Fixing above mentioned issue.

neelam.chaudhary’s picture

Status: Needs work » Needs review
johnchque’s picture

Issue tags: +Needs tests

Thank you, we will need tests for this so we can know that the bug was fixed.
Don't forget to upload a test-only patch first. :)

johnchque’s picture

Status: Needs review » Needs work
valderama’s picture

Thanks for the patch @neelam.chaudhary !

I really works nicely and still applies to RC2.

trevorbradley’s picture

+1 to patch #17 here. Working great on rc2

jjancel’s picture

Hello
in 2021 with version 8.x-1.0 Stable release covered by the Drupal Security Team released 6 January 2020
I find the same error

Notice: Array to string conversion in Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build() (line 70 of modules/- dev/diff/src/Plugin/diff/Field/ImageFieldBuilder.php).
Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build(Object) (Line: 94)
Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 104)
Drupal\diff\DiffEntityComparison->compareRevisions(Object, Object) (Line: 115)
Drupal\diff\Plugin\diff\Layout\SplitFieldsDiffLayout->build(Object, Object, Object) (Line: 168)
Drupal\diff\Controller\PluginRevisionController->compareEntityRevisions(Object, Object, Object, 'split_fields') (Line: 49)
Drupal\diff\Controller\NodeRevisionController->compareNodeRevisions(Object, Object, Object, 'split_fields')
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: 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)
Notice: Array to string conversion in Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build() (line 70 of modules/- dev/diff/src/Plugin/diff/Field/ImageFieldBuilder.php).
Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build(Object) (Line: 94)
Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 105)
Drupal\diff\DiffEntityComparison->compareRevisions(Object, Object) (Line: 115)
Drupal\diff\Plugin\diff\Layout\SplitFieldsDiffLayout->build(Object, Object, Object) (Line: 168)
Drupal\diff\Controller\PluginRevisionController->compareEntityRevisions(Object, Object, Object, 'split_fields') (Line: 49)
Drupal\diff\Controller\NodeRevisionController->compareNodeRevisions(Object, Object, Object, 'split_fields')
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: 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)

The patch #17 or 8.x-1.x-dev not working
how to correct this problem?
thank you

joel_osc’s picture

+1 on patch fixing issue for me... thanks!

jaydub’s picture

I am seeing this locally as well and the patch in #17 still applies to the latest code in 8.x-1.x branch and the PHP notices go away.

chetan 11 made their first commit to this issue’s fork.

chetan 11’s picture

Status: Needs work » Needs review

Please check the above MR.

jonasanne’s picture

Patch reroll

makbay’s picture

This is also needed for 2.x

acbramley’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Needs review » Needs work
Issue tags: +Needs steps to reproduce

Lots of people unable to reproduce this issue, I'll need steps to reproduce before reviewing code changes.

heddn’s picture

Status: Needs work » Postponed (maintainer needs more info)

dieterholvoet made their first commit to this issue’s fork.

dieterholvoet changed the visibility of the branch 8.x-1.x to hidden.

dieterholvoet changed the visibility of the branch 2.x to hidden.

dieterholvoet’s picture

dieterholvoet’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: -Needs steps to reproduce

The problem is that $image_style is set implicitly and never unset after being used. That causes this issue, since that code runs in a loop. The issue only occurs when

  • thumbnails are enabled in Diff
  • the image is configured to be displayed in the form display with a preview image style
  • there's more than 1 image in the field

It could be fixed by unsetting $image_style after using it, but I changed the code a bit to be more readable. I opened a new MR.

acbramley’s picture

Status: Needs review » Needs work

tests are now failing

rosk0 made their first commit to this issue’s fork.

rosk0’s picture

Assigned: Unassigned » rosk0
Status: Needs work » Active
StatusFileSize
new37.74 KB
new55.7 KB

In attempt to fix tests I've manually replicated test steps in a clean Drupal 10.3.6 installation with only Diff module installed - the output I saw on page was identical to that of the pipeline job, attaching as a screenshot below:

To me it appeared that the output produced by the module changed at some point, but the test wasn't updated to accommodate that change. However tests are passing on the latest 2.x...

I've reverted the change introduced here and saw expected output and no errors:

this is really weird as I saw all the errors reported in this issue myself on a project where we want to use this module...

Will spent some more time on this

rosk0’s picture

Assigned: rosk0 » Unassigned
Status: Active » Needs review
Issue tags: -Needs tests
Related issues: +#2840566: Make rich diff pluggable

The problem lies in the multi-valued field handling - image field in our project allows multiple image uploads.

As soon as I've changed field_image to be multivalued in the test instance and uploaded new image to a test article the same error appeared on the diff page.

Added multi-valued support and test. Everything is rudimentary as proper implementation should be done in #2840566: Make rich diff pluggable.

acbramley’s picture

Status: Needs review » Needs work

Tests and linting are failing

rosk0’s picture

Status: Needs work » Needs review

All green now.

Please review.

acbramley changed the visibility of the branch 2844337-array-to-string to hidden.

acbramley’s picture

Status: Needs review » Needs work
rosk0’s picture

Status: Needs work » Needs review

All green again and review comments addressed.

Please review.

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

acbramley’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for everyone's hard work getting this across the line, this will be included in the next beta

makbay’s picture

Why would you ignore other people's contributions and haven't given credit to them?

acbramley’s picture

@makbay bit rude, but I credited everyone that provided valuable testing or contributions to this issue.

If I've missed someone then please let me know and I'll update it. You opened 2 MRs and immediately closed them.

Status: Fixed » Closed (fixed)

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