Skip to content

fix(imap_client): avoid array-to-string warning in getNamespaces#48

Merged
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/getnamespaces-array-to-string
Jul 21, 2026
Merged

fix(imap_client): avoid array-to-string warning in getNamespaces#48
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/getnamespaces-array-to-string

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

Motivation

IMP forwards the backend namespace setting from backends.php as getNamespaces()’s $additional argument. Calling array_map('strval', …) on a nested array value emits “Array to string conversion” on every request with no useful side effects. A related long-standing bug compared namespace name lengths instead of names when deciding which additional namespaces still needed probing.

Changes

  • Skip array/object values that are not Stringable before normalizing $additional.
  • Use array_map('strval', iterator_to_array($ns)) when building the already-detected set.
  • Document that non-scalar $additional entries are ignored.
  • New GetNamespacesTest covering nested-array input, duplicate skip, and Mailbox/Stringable input.

Test plan

  • phpunit test/Unit/Base/GetNamespacesTest.php (3 tests)
  • Confirm a misconfigured IMP namespace entry no longer logs the warning
  • Confirm a flat string list (array('#shared/', …)) still adds unadvertised namespaces as before

Skip non-scalar additional namespace entries instead of passing them to
strval(), which triggered "Array to string conversion" when IMP forwarded
a nested backends.php namespace config (horde/imp#94). Also compare
namespace names with strval rather than strlen when filtering already
detected namespaces.
@what-the-diff

what-the-diff Bot commented Jul 20, 2026

Copy link
Copy Markdown

PR Summary

  • Enhanced Documentation in Base.php
    The documentation for the script Base.php has been updated to make it clear that nested structures or non-basic data types are ignored when extra namespaces are being added.

  • Introducing Method to Normalize Additional Array
    A new function has been developed that normalizes the additional namespace array in the getNamespaces() function. This includes filtering out non-scalar or non-stringable values, which will prevent errors in the latest versions of PHP (version 8 and above).

  • Refined Namespace Processing Logic
    Updates have been made to how namespaces are processed. This involves using a conversion function on the namespace list, ensuring that any previously identified namespaces are passed over correctly.

  • Added New Unit Test File GetNamespacesTest.php
    A new testing script called GetNamespacesTest.php has been introduced. The tests included in this script focus on:

    • Confirming nested arrays as additional namespaces do not trigger warnings.
    • Ensuring already recognized namespaces are properly skipped.
    • Validating stringable values as acceptable additional namespaces.

@github-actions

Copy link
Copy Markdown

🔍 CI Results

Overall: ❌ 10/10 lanes failed

TL;DR: ❌ Quality issues: PHPUnit: 6 tests failed; PHPStan: 16 unique errors in 8 lanes; PHP-CS-Fixer: 1 file.

Summary by PHP Version

PHP dev stable
8.1
8.2
8.3
8.4
8.5

Quality Metrics

  • PHPUnit: 0 failures, 6 errors out of 1093 tests in 8 lanes ❌
    Per-test detail in the table below. Raw JUnit XML and JSON are uploaded as workflow artifacts.

    Which tests failed
    Type Test Lanes Message
    ⚠️ error Horde\Imap\Client\Test\Unit\DateTimeTest::testDateTimeParsing php8.3-dev, php8.3-stable [Error] Cannot create dynamic property DateMalformedStringException::$xdebug_message
  • PHPStan: 16 unique errors in 8 lanes ⚠️

  • PHP-CS-Fixer: 1 unique file with issues (of 250 checked) ⚠️

❌ Failed Lanes

php8.1-dev

  • PHPUnit: ❌ Setup failed (No result file found)
  • PHPStan: ❌ Setup failed (No result file found)

php8.1-stable

  • PHPUnit: ❌ Setup failed (No result file found)
  • PHPStan: ❌ Setup failed (No result file found)

php8.2-dev

  • PHPStan: 16 errors found

php8.2-stable

  • PHPStan: 16 errors found

php8.3-dev

  • PHPUnit: 0 failures, 3 errors
  • PHPStan: 16 errors found

php8.3-stable

  • PHPUnit: 0 failures, 3 errors
  • PHPStan: 16 errors found

php8.4-dev

  • PHPStan: 16 errors found
  • PHP-CS-Fixer: 1 file with issues

php8.4-stable

  • PHPStan: 16 errors found

php8.5-dev

  • PHPStan: 16 errors found

php8.5-stable

  • PHPStan: 16 errors found

CI powered by horde-componentsView full results

@ralflang

Copy link
Copy Markdown
Member

See also horde/imp#95 - Defending at (legacy) library level is OK but we should eliminate the problem at the source, too.

@ralflang
ralflang merged commit 2c766e4 into FRAMEWORK_6_0 Jul 21, 2026
1 check failed
ralflang added a commit to horde/imp that referenced this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants