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}.
Comments
Comment #2
znak commentedThe 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.
Comment #3
VladimirMarko commented@dhendriks:
From which Diff version did you update?
Comment #4
dhendriks commentedI updated from Diff 8.x-1.0-beta2 to Diff 8.x-1.0-rc1.
Comment #5
VladimirMarko commentedDiscussed 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 forproperty_separatorin 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:
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.Comment #6
dhendriks commentedOK, 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'.
Comment #7
dhendriks commentedJust to be sure I also tried your code. Adding a 'var_dump($result);' I get:
I also included the second part, but let it print something instead of changing the configuration. It didn't print anything.
Comment #8
VladimirMarko commentedSorry, I can't figure out what's wrong. Maybe someone else can help you.
Comment #9
johnchqueI cannot reproduce the bug either. :(
Comment #10
VladimirMarko commentedMaybe it was just corrupted cache?
Comment #11
johnchqueWe cannot reproduce, can you check again please?
Comment #12
abhay.agarwal commentedI was replicating this issue and found some more thumbnail related issues::
Attaching screenshots for the same and also the patch for the same issues.
Comment #14
neelam.chaudhary commentedFixing above mentioned notices and there were some other errors like::
Fixing these issues with the attached patch.
Comment #15
neelam.chaudhary commentedComment #16
johnchqueIs better to fix this kind of bugs/problems in a specific issue so we don't get out of scope.
Test failing.
Comment #17
neelam.chaudhary commentedFixing above mentioned issue.
Comment #18
neelam.chaudhary commentedComment #19
johnchqueThank 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. :)
Comment #20
johnchqueComment #21
valderama commentedThanks for the patch @neelam.chaudhary !
I really works nicely and still applies to RC2.
Comment #22
trevorbradley commented+1 to patch #17 here. Working great on rc2
Comment #23
jjancel commentedHello
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
The patch #17 or 8.x-1.x-dev not working
how to correct this problem?
thank you
Comment #24
joel_osc commented+1 on patch fixing issue for me... thanks!
Comment #25
jaydub commentedI 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.
Comment #28
chetan 11 commentedPlease check the above MR.
Comment #29
jonasanne commentedPatch reroll
Comment #30
makbay commentedThis is also needed for 2.x
Comment #35
acbramley commentedLots of people unable to reproduce this issue, I'll need steps to reproduce before reviewing code changes.
Comment #36
heddnComment #40
dieterholvoet commentedComment #42
dieterholvoet commentedThe problem is that
$image_styleis set implicitly and never unset after being used. That causes this issue, since that code runs in a loop. The issue only occurs whenIt could be fixed by unsetting
$image_styleafter using it, but I changed the code a bit to be more readable. I opened a new MR.Comment #43
acbramley commentedtests are now failing
Comment #45
rosk0In 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
Comment #46
rosk0The 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.
Comment #47
acbramley commentedTests and linting are failing
Comment #48
rosk0All green now.
Please review.
Comment #50
acbramley commentedComment #51
rosk0All green again and review comments addressed.
Please review.
Comment #52
acbramley commentedComment #54
acbramley commentedThanks for everyone's hard work getting this across the line, this will be included in the next beta
Comment #55
makbay commentedWhy would you ignore other people's contributions and haven't given credit to them?
Comment #56
acbramley commented@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.