- Issue created by @blecheimer
- π³π±Netherlands johnv
Hmm,
I use Claro myself.When does the error appear?
- when you display the node form?
- when you press [Add exception]?
- when you enter data?
- when you press [save]?Where does your file 'js-editor' come from? (mentioned in your original post)
Which modules do you have installed? - π©πͺGermany blecheimer
I deleted the js-editor error because it does not is this error, it was something other in this module https://www.drupal.org/project/js_editor β . If I disable it the error with seasons is still there
When does the error appear?
when I press [Add exception]? - π³π±Netherlands johnv
did you check admin/config/development/logging, and set 'All messages, with backtrace information'?
then, after a new test, is there anything under admin/reports/dblog ? - π©πͺGermany blecheimer
Does this help?
Typ php
Datum Freitag, 3. November 2023 - 18:12
Standort https://---------------/node/14/edit?_wrapper_format=drupal_ajax&ajax_form=1
Referrer https://---------------/node/14/edit
Benachrichtigung LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep() (Zeile 1712 in /------------------my host ------------------/web/core/lib/Drupal/Core/Database/Connection.php).
Schweregrad Fehler - π³π±Netherlands johnv
Can you disable first one, then the other module?
I see no reason how the error should occur.You are not using Webform, correct?
- π©πͺGermany blecheimer
hi, yes I'm also using webform in this installation but not on this edit page.
ok I will test it on a test environment later. - π©πͺGermany blecheimer
Ok, I have tested it on the test environment with less modules than in the other drupal installation. I have the same problem there. (without Field Group https://www.drupal.org/project/field_group β and Display Suite https://www.drupal.org/project/ds β
a screenshot of the module list is attached - π©πͺGermany blecheimer
I have now disabled almost all custom modules. It is still the same.
New module list is attached. - π³π±Netherlands johnv
I see the program passes the serialize() code. This happens before the custom 'addMoreAjax' is done.
The form is cached, supposedly to fetch it later after the ajax call.
Do you use a special database type?
An alternative is that several fields are competing. Which fields are on your node? Does the error happen when the Node has only an Office Hours field (and Body). After the test, remove the Body field, too - π³π±Netherlands johnv
I also found this issue #2461063: AJAX forms using #ajax broken when page caching is enabled β .
Please check what happens if 'Internal Page Cache' is disabled. This should only have effect when you edit a node as Anonymous user.
This module has some problems with the 'Internal Page Cache' (page_cache) module.Do you edit as authenticated or anonymous user?
- π³π±Netherlands johnv
No, I cannot reproduce the error. I use an XAMPP stack.
- π©πͺGermany blecheimer
Ha! I've found it. it is something with the language
testspace https://master-e5ulyfnh0vsxlh4hzkzvqpvr1vy4y6tg.tugboatqa.com/de/node/2
(or try on your system:)
perhaps one thing:
enable language to german
set language german to standard and interface language.switch to german edit interface
perhaps the other thing:
add office hours field to contenttype article.
name the field "Γffungszeiten" (machinename will be transliterated to: field_offnungzeiten)
activate the widget "Office hours (week) with exceptions and seasons" with both seasons and exceptionsnow create a new article, try to add an exception. it fails.
- π³π±Netherlands johnv
interesting..
I added the German language and used the 'Language Switcher' block to switch to German.
Then, I opened the Node form. It is in German, but the button says 'Add exception'. (strange)
Upon clicking on the button, no new exception appears (strange)
But also, no message appears, even if I configured so (strange)The 'Last messages report' says your error:
LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep() (line 1712 of C:\damp\xampp\htdocs\drupal-10\core\lib\Drupal\Core\Database\Connection.php).
You did not mean that the translation (with Umlaut) is the problem, not, but the German Language in general?
- π³π±Netherlands johnv
I also happens when I change to Dutch.
My guess is it always happens when a language is added to the URL.
- http://localhost/drupal-10/nl/node/8/edit also does generate an error.
- http://localhost/drupal-10/node/8/edit does NOT genetare an error.
Strangely enough, I cannot add the language 'en' to the URL --> 'Page not found'I core, I see several issues with the same problem. Many are 'cannot reproduce', which is not strange, as we see.
LogicException problems β
Also with German, and with BigPipe. - π³π±Netherlands johnv
Disable BigPipe has no effect.
Setting user language to German.
http://localhost/drupal-10/de/node/8/edit gives error (with DE language from link)
http://localhost/drupal-10/node/8/edit gives error, too (with DE language from user)In /admin/config/regional/language/detection , link goes before user.
Setting user language to Dutch.
no change, same errors.Setting user language to English.
No error in http://localhost/drupal-10/node/8/edit (with DE language from user) :-)
Page not found in http://localhost/drupal-10/de/node/8/edit gives error (with DE language from link)t.b.c.
- π©πͺGermany blecheimer
My guess is it always happens when a language is added to the URL.
No! My standard language is german, here is no language snippet in the url
(Try it and set NL to standard language, then the snippet disappears)Also I don't think the Umlaut is a problem. Also not the german language but perhaps any language that is not english
Please could you tell me where the button is in the code?
and also the button of the seasons?
(File and line number?) - π©πͺGermany blecheimer
but don't forget, the error is only there when Seasons is enabled. what is the difference?
- π³π±Netherlands johnv
Indeed, thanks for the 'seasons' hint.
OK, so the problem is not with the URL, but it is still a problem with a non-EN form.
When I read through the related issues in #18, a t() function is called on the page, that is cached upon the ajax call. this t() function, (or other classes) depend on an open database connection - which shouldn't be on a cached page.
Solutions are to avoid this, by removing the requirements.It seems a fix like #2987548-15: LogicException: The database connection is not serializable. β may fix the problem (but not in this case). That is the fix as intended by the message - which is clearly unclear.
A test with disabling Internal Dynamic Page Cache and Internal Page Cache makes no difference.
You can look for 'addMoreAjax' in the module code to find the triggering code in OfficeHoursExceptionsWidget.
But OfficeHoursComplexWeekWidget::massageFormValues() combines both Exceptions and Seasons widgets in 1 form.Let me look what triggers the problem.
- π³π±Netherlands johnv
I found the problem and a solution - although the real solution should be in core.
This is a 'season', with a translated name , and a 'stringTranslation')
Drupal\office_hours\OfficeHoursSeason {#1874 βΌ #id: 100 #name: "Summer 2024" #from: 1719784800 #to: 1724968800 #stringTranslation: null }
The solution is to remove the 'stringTranslation', which causes the problem.
Several ways to get there, all in OfficeHoursSeason.php:
- do not use $this->t() but t();
- add use StringTranslationTrait;
- do not add the Season object to the form.Please check attached patch.
On that note, do you see any advantage in translating the Season title/name?
- π³π±Netherlands johnv
On a side note: I created π Add Translation context fallback for 'From', 'To' Active
- π©πͺGermany blecheimer
On that note, do you see any advantage in translating the Season title/name?
for me in this case, I don't need a translation, in other cases perhaps it could be useful.
I will test it tomorrow
- π©πͺGermany blecheimer
yes worked after I deleted/not aplied this part:
@@ -100,6 +102,7 @@ class OfficeHoursSeason { if (!is_numeric($this->to)) { $this->to = strtotime($this->to); } +dpm($this); }
- π³π±Netherlands johnv
That was quite some trip in core :-)
It is fixed here: π Remove translation from Season object (to avoid Ajax LogicException) Fixed
I will keep this open for a while, since I am now intrigued by this problem: "Why are developers 'encouraged' to use $this->t() instead of old-school t(), and then all have to fix core problems?"
Thanks for the fast cooperation. Please test dev-version.
- π©πͺGermany blecheimer
hey sorry for delay. The last dev (Last updated: 8 Nov 2023 at 13:40 CET) does not work for me. I get a WSOD.
I reverted back to working version with your patch. - π³π±Netherlands johnv
Yeah, I did a half commit. Should be OK now. Sorry .
- Status changed to Needs work
12 months ago 2:25pm 30 November 2023 - Status changed to Fixed
12 months ago 9:30am 1 December 2023 - π³π±Netherlands johnv
Should be fixed now with change in π Multiple Office Hours fields on same Content Type breaks Exceptions Fixed
Automatically closed - issue fixed for 2 weeks with no activity.