fnagel / beautyofcode

TYPO3 CMS Extension beautyofcode
https://extensions.typo3.org/extension/beautyofcode/
GNU General Public License v2.0
6 stars 8 forks source link

[BUG] No highlighting in TYPO3 8.7 #17

Open ste101 opened 6 years ago

ste101 commented 6 years ago

After upgrading to 8.7 I have no highlighting anymore. The flexform isn't filled anymore. I think the problem is in file FlexformRepository.php in function reconstituteByContentObject.

fnagel commented 6 years ago

Which version are you using? From which did you upgrade?

Did you follow the upgrade guide? https://github.com/fnagel/beautyofcode/blob/master/Documentation/AdministratorManual/Index.rst

Extension is tested in 8.x and should work as expected.

susannemoog commented 6 years ago

As you asked in #18: we are currently using 8LTS (and always did in this project, so no upgrade) with PHP 7.0 at the moment on the live system. I just checked and there seems to be at least "something" wrong from the quick look I took. In the backend the content element has a filled flexform (with javascript selected for example) but the frontend generates "language- " as css class (for example on https://typo3.com/blog/how-to-install-typo3-using-composer-in-less-than-5-minutes/ - the json extra is configured as javascript). If you don't have an idea, I can debug that tomorrow and get back to you.

fnagel commented 6 years ago

Thanks a lot for the feedback!

Did some tests myself and now I'm pretty confused.

It seems to work on a local VM with TYPO3 8.7.1 (Introduction Package) instance I'm using for development and testing of my extensions.

It seems to work in another VM I'm using for developing my website. The STAGE environment of that website (hosted at Uberspace) works fine too, but the PROD instance (same server) does not work.

Same issue as you pointed out (rendering language-undefined for some reason). Without the language set, the JS doesn't kick in.

Both instances using the same composer based TYPO3 8.7.8 git repository. DBs have been synced lately (as I upgraded to 8.7 days ago). There is hardly a difference other then the domain and the TYPO3 context.

Issue seems to occur when using TYPO3 8.x only. Never experienced anything similar with 7.6.

@ste101 Can you explain what exactly you find out when debugging?

Update I was playing around a little and suddenly it worked. Without any actual changes. Feels like some strange cache issue or something similar. Even worse, I'm no longer able to reproduce this on any instance. Any help appreciated.

ste101 commented 6 years ago

Hello Felix, I'm using 8.7.8. With debug messages I can see the 'c_lang' is set in $flexformValues in line 72 but in $flexform[0] 'cLang' is 'null'. Also cCollaps and cGutter is 'null'.

susannemoog commented 6 years ago

Debugged a bit more and had the exact same behaviour as @ste101 - found out that the datamap for the model in the database was wrongly generated without columns (therefore no values set after reconstitution). Clearing the cache (all caches) and reloading the frontend solved the problem in this instance - but I don't know where the wrong cache entry is coming from in the first place. To debug look at the result of \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getDataMap and whether a columnMap is set or not in the resulting dataMap object.

fnagel commented 6 years ago

Any idea how to force this error to happen? I'm no longer able to reproduce it, which makes it hard to debug.

Seems typo3.com still has issues: https://typo3.com/blog/how-to-install-typo3-using-composer-in-less-than-5-minutes/

susannemoog commented 6 years ago

I'm having the same problem, I can't reproduce it on any test instance, after debugging it the first time I was not able to get it ever again. :(

ste101 commented 6 years ago

I can give you access to my system.

fnagel commented 6 years ago

@psychomieze @ste101 Please take a look at the latest commit in master!

@mmunz Created a PR which should fix this issue!

fnagel commented 5 years ago

Any feedback on this issue?

mmunz commented 5 years ago

@fnagel time has shown that my PR alone doesn't solve the issue, i'm still missing the syntax highlighting from time to time on my site. I will have a closer look if needed, but this will probably need some days/weeks.

fnagel commented 5 years ago

Any input would be very welcome as the nature of this bug makes it very hard to debug it!

mmunz commented 5 years ago

After some debugging i think this is related to the datamapper used in https://github.com/fnagel/beautyofcode/blob/master/Classes/Domain/Repository/FlexformRepository.php#L76 Under some conditions TCA for the Flexform is unknown which means no properties can be mapped from the flexform array. There are some bugreports about similar problems with the the datamapper cache, e.g. https://forge.typo3.org/issues/78091

I'll look into that, but i'm still not able to reproduce the bug, this is why it takes some time. Currently i'm testing if disabling cache for datamaps helps:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap']['backend'] = \TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';

emmguyot commented 5 years ago

Hi, I had the same problem : The rendered HTML has no language <pre class="brush: ; "> I've installed the latest master code and now it works fine.

fnagel commented 5 years ago

@mmunz Any news on this issue? @dreadwarrior I know, you are no longer involved in this project, but as you implemented this in the first time: any idea what the issue could be?

dreadwarrior commented 5 years ago

@fnagel To me it looks like the $highlighterConfiguration instance of Domain\Model\Flexform doesn't make it into the cache. But this is only an assumption, as I have no TYPO3 instance currently for testing. If I remember correctly, the implementations of the interface behind this member variable are responsible for rendering the proper class / data-attribute strings, depending upon which highlighter (Prism / SH) you selected.

It looks like the cache in TYPO3 DataMapper doesn't cache/serialize all dependent objects. Something like "first instance in the object graph, but not more".

Because this is conceptionally wrong (a service in a domain value object), I would suggest to try to refactor this out of the FlexForm value object and introduce some kind of Domain or Application service which "joins together" the flexform data and the Highlighter\ConfigurationInterface implementation / service.

Another option would be to investigate the TYPO3 cache backends and find out if they support some kind of Serializable interfaces and implement the serialize/deserialize method-pairs/logic in all classes in the object graph (Flexform + injected services) and see if that will work.

What do you think?

emmguyot commented 4 years ago

Hi,

I've just debugged the process when the bug occurs on my site.

Here is what I've found :

Of course, as a workaround, I can set again $GLOBALS['TCA']['tx_beautyofcode_domain_model_flexform'] in renderAction. But there must be a better way.

I hope this helps you to find a clean fix.

emmguyot commented 2 years ago

This bug occurs with recent Typo3 release too (currently using 10.4.15). I've got it back while I was fixing another bug (#14) in my PR #39.

Work in progress to rewrite FlexformRepository.reconstituteByContentObject in order to remove the dataMapper and the tx_beautyofcode_domain_model_flexform model

fnagel commented 2 years ago

Thanks for the feedback and trying to fix the issue!

Work in progress to rewrite FlexformRepository.reconstituteByContentObject in order to remove the dataMapper and the tx_beautyofcode_domain_model_flexform model

Sounds like you plan to simplify things? Sounds good to me as the current implementation feels a little too complex :-/

fnagel commented 2 years ago

Merged #39 which might fix this issue due to removal of fake TCA and usage of data mapper.

fnagel commented 2 years ago

Might be fixed with: https://github.com/fnagel/beautyofcode/commit/fed4dd2182107d9c58872cfcc847854fed486ea0