Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$incomingFieldArray['colPos'] is accessed before checking if it's available #107

Open
magicHatOfTYPO3 opened this issue Sep 27, 2022 · 16 comments
Labels

Comments

@magicHatOfTYPO3
Copy link

When using PHP 8.1 the DatamapDataHandlerHook fails with an backend error message if colPos is not explicitly provided.

Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1476107295: PHP Warning: Undefined array key "colPos" in /var/www/html/public/typo3conf/ext/content_defender/Classes/Hooks/DatamapDataHandlerHook.php line 51

@subnoodle
Copy link

subnoodle commented Dec 19, 2022

Hi Nicole, i hit the same issue in your and another extension.
Please see:
typo3-content-defener-bug
Can you tell me is the fix is already released?
(Don't get a clue how to overwatch that here).

I added E_WARNING to be excluded from PHP error reporting, but that did not help:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING

Any clue for a workarround until next release?

Thx, Sam

@IchHabRecht
Copy link
Owner

Hi,
I would love to understand the situation and get in insight how to reproduce the problem. If anyone could tell me how to trigger the warning, I can try to fix it.

@subnoodle
Copy link

Hi Nicole,
it's a while ago, but as far as i remember:

  • let php "warn" (do not exclude from setting "ERROR_REPORTING in php.ini
  • use php 8.1.x
  • enable production settings in Typo3
  • let it run: open a page with a backendlayout, maybe leaving out some defined colPos or not selected a backendlayout (there i do not know exactly the constellation)

General problem i've got with another ext: the PHP-Warning leads to a Typo3-Exception: The current prozess stops working then. So, best is to avoid warning from the code then, i suggest.

Thank you very much for the awesome content defender!

Cheers, Thomas

@IchHabRecht
Copy link
Owner

Hi @subnoodle

Thank you for your answer. The problem is that I run locally an instance with complete error reporting. But I'm not able to trigger any warning. So I really need some configuration that helps me to run into the problem. I'm using the provided test fixtures (https://github.com/IchHabRecht/content_defender/tree/main/Tests/Functional/Fixtures/TSconfig/BackendLayouts) in my local system.

@subnoodle
Copy link

Hi Nicole,
here it comes again...
Screenshot 2023-01-17 Exception Content Defender

In this case, it occures whenever i add a content element, enter some content and click the save button.

The configuration is:
Typo3: 11.5.22
PHP: 8.1.x

Details from Typo3's system -> log
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1476107295: PHP Warning: Undefined array key "colPos" in /html/typo3/Public/typo3conf/ext/content_defender/Classes/Hooks/DatamapDataHandlerHook.php line 51 | TYPO3\CMS\Core\Error\Exception thrown in file /html/typo3/Public/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 137. Requested URL: https://amer2.bs-dev.work/typo3/record/edit?token=--AnonymizedToken--&edit%5Btt_content%5D%5B313%5D=new&returnUrl=%2Ftypo3%2Fmodule%2Fweb%2Flayout%3Ftoken%3D--AnonymizedToken--%26id%3D313&defVals%5Btt_content%5D%5BCType%5D=header&defVals%5Btt_content%5D%5BcolPos%5D=0&defVals%5Btt_content%5D%5Bsys_language_uid%5D=0&route=%2Frecord%2Fedit

[SYS][belogErrorReporting] = 30711 (chaning it to 0 does not change anything)

Two backendlayouts:
default.typoscript.txt
subpage.typoscript.txt

(renamed for uoload only)

Worked all fine with PHP 8.0. (as far as i remember)

Some automatic typecasts are gone so far i understand possibly the problem, so invalid array keys got critical since then.
Content defender is not the only extension suffering from that.

Any solution & feedback is very appreciated.

Many thanks!
Thomas

@subnoodle
Copy link

Addition: I discoverd and fixed an error on my provided file subpage.typosript:7 and change the line from
rowCount = 3
to correct value:
rowCount = 2

I tought it might help, but the behavior stayed the same (after clearing cache, etc).

@anderlk
Copy link

anderlk commented Jan 23, 2023

Same Problem here, but only when Configuration Preset is in Debug Mode. In Live Mode there is no Problem.
PHP 8.2
TYPO3 11.5.19

Bildschirmfoto 2023-01-23 um 12 01 03

Regards Andreas

@IchHabRecht
Copy link
Owner

Hi all,

I still don't know how to reproduce the problem. Open questions:

  • what are you doing, e.g. edit an existing record, saving a new record?
  • are you using an admin user or any kind of editor? if an editor role is used, does it have access to the colPos field?

It seems the colPos is missing from the request but I'm unable to reproduce and understand it. I don't want to commit anything "blindly", so I need to be able to trigger the warning by myself. Any hint would be really appreciated.

@anderlk
Copy link

anderlk commented Jan 23, 2023

Hi Nicole,
I've debugged around a bit.

In Configuration Preset "Live" there is no problem. The problem only comes up in Debug mode.

  • When editing an existing record, there is no problem.
  • When creating a new record and saving them, the error comes up!

No Matter wich Role. The problem exists for Admins, too.

The PHP version seems to be decisive. With PHP 7.4 the problem does not exist. From PHP 8.0 and up it exists.

I don't know if this helps, but I use content defender in conjunction with the extension: container

But the problem is still here although I have uninstalled the container extension.

@IchHabRecht
Copy link
Owner

IchHabRecht commented Jan 24, 2023

Hi @anderlk

Thank you for the further information. I'm still not able to trigger a warning with the current given information. Maybe you can give some additional help.

  • can you trigger the warning in a fresh typo3 installation using content_defender (and maybe introduction package)?
  • which backend layout is used?
  • which user is used?
  • which content element is inserted in which column?

Furthermore: a warning isn't any "real" problem. This is why the exception is shown in debug mode only but not in live configuration. This is how TYPO3 works when notices and/or warnings (or other PHP related problems) are triggered.

@anderlk
Copy link

anderlk commented Jan 24, 2023

Hi Nicole, I have now installed a test system with a fresh typo3 installation with content_defender and introduction package. After the problem did not exist here, I have rebuilt piece by piece my template extension until I found the bug.

Sorry, but it was my own fault. In a completely different TSconfig file the command TCEFORM.tt_content.colPos.disabled = 1 was set.

Why this didn't work with your Extesnion, only in debug mode and how this is related to the PHP version is really a mystery to me?

Thanks for your great help, without which I would not have found the bug.

Maybe has the other reporter a similar problem. Then the bugreport can be closed by me.

Regards Andreas

@IchHabRecht
Copy link
Owner

@anderlk

Thank you very much for all your effort. With the additional information about the disabled colPos field I was finally able to reproduce and fix the issue!

@anderlk
Copy link

anderlk commented Jan 25, 2023

Hi Nicole, thanks for the Fix und your good work for this helpful Extension.

Regards Andreas

@subnoodle
Copy link

Hi Nicole, thank you very much for your engagement!
Regards, Thomas

@kitzberger
Copy link

@IchHabRecht, thanks for already having looked into this issue 💪

But I'm afraid your solution isn't covering all cases. My scenario is:

  • TCEFORM.tt_content.colPos.disabled = 1
  • Create new CE (without wizard!) and change CType to one of my EXT:container CEs
  • Boom -> exception from above.

@kitzberger
Copy link

@IchHabRecht, just stumped upon this again with a different scenario:

  • TCEFORM.tt_content.colPos.disabled = 1
  • Edit an existing CE, hitting the "+ New" button
  • Exception from above.

image

#150 is fixing the issue for this btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants