benjaminkott / benjaminkott/bootstrap_package

(1/1) TypeError strpos(): Argument #1 ($haystack) must be of type string, TYPO3\CMS\Core\Resource\FileReference given

Open
#1,439 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
355
Forks
212
Avg merge
1h 4m
Merged PRs (30d)
31

Description

# Bug Report

## Prerequisites

* [NO ] Can you reproduce the problem on TYPO3 v11.5 LTS
* [NO ] Can you reproduce the problem on TYPO3 v12.4 LTS
* [NO] Did you [perform a cursory search](https://github.com/issues?q=is%3Aissue+user%3Abenjaminkott+repo%3Abenjaminkott%2Fbootstrap_package)
to see if your bug or enhancement is already reported?

## Description

On some news-items the bootstrap-package throws an error when processing a svg-image as file-reference.
Other news-entries work.
The exception occurs in EXT:/bootstrap_package/Classes/ViewHelpers/Data/ImageInfoViewHelper.php::67 (version 14.0.7)

## Steps to Reproduce

Not really reproduceable.
But: the viewhelper get a file-reference (object) instead of the file-name (string)

### Expected behavior

no exception when the viewhelper processes a simple strpos-cmd.

### Actual behavior

excpetion, see screenshot

### Screenshots

![Screenshot 2023-10-26 at 17-09-36 TYPO3 Exception](https://github.com/benjaminkott/bootstrap_package/assets/9478590/7caa44e0-c372-40ef-8510-cb64a7aa7e59)

## Fix

change line 67:
from:
` if (strpos($src, $mediaName) !== false) {`
to:
`if (is_string($src) && strpos($src, $mediaName) !== false) {`
to make strpos typesafe.

## Versions

You can get this information from executing `composer show` at the command line
if your TYPO3 installation is composer based, otherwise the version number will
be shown in the extension manager.

Typo3 v11.5.32

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in EXT:/bootstrap_package/Classes/ViewHelpers/Data/ImageInfoViewHelper.php at line 67 and inspect how the viewhelper receives the image source for SVG file references. Confirm that the strpos call handles the reported object input without throwing a TypeError; the issue's expected behavior is no exception during processing.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, php
Domain
web-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.