georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
264 stars 358 forks source link

Undefined array key var/cache/code/news/tx_news_controller_newscontroller.php line xxx #2203

Closed DanielSiepmann closed 1 year ago

DanielSiepmann commented 1 year ago

Bug Report

Current Behavior A PHP Warning is logged for PHP 8.1 when defining a TypoScript property with applied stdWrap that does only have subkeys but no content on main level, e.g.:

lib.page.section.news < lib.news.list
lib.page.section.news {
  settings {
    useStdWrap = categories
    categories.override.cObject = CONTENT
    categories.override.cObject {
     # … some logic
    }
  }
}

The code only properly checks for categories. but expects categories to exist as well.

Expected behavior/output Proper checks for existing entries with proper fallback, instead of a warning.

Environment

Possible Solution Add proper null Coalescing operator to define fallback. The operator exists since PHP 7.0: https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op The oldest supported TYPO3 version is v10 which requires at least PHP 7.2.

Additional context I'll provide a PR for this issue. I just created this Issue as reference.

DanielSiepmann commented 1 year ago

Looks like I had blind eyes, this got already fixed that way: https://github.com/georgringer/news/blob/main/Classes/Controller/NewsController.php#L652 I could swear I checked that line before creating the issue.

georgringer commented 1 year ago

;)