fix(imap_client): avoid array-to-string warning in getNamespaces#48
Conversation
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.
PR Summary
|
🔍 CI ResultsOverall: ❌ 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
Quality Metrics
❌ Failed Lanesphp8.1-dev
php8.1-stable
php8.2-dev
php8.2-stable
php8.3-dev
php8.3-stable
php8.4-dev
php8.4-stable
php8.5-dev
php8.5-stable
CI powered by horde-components • View full results |
|
See also horde/imp#95 - Defending at (legacy) library level is OK but we should eliminate the problem at the source, too. |
…tream Relates to horde/Imap_Client#48 Fixes imp#95
Summary
Horde_Imap_Client_Base::getNamespaces()against nested/non-scalar$additionalentries that triggered PHP “Array to string conversion” warnings (reported via PHP ERROR: Array to string conversion [pid 91211 on line 744 of "/var/www/horde6rc/vendor/horde/imap_client/lib/Horde/Imap/Client/Base.php"] imp#94).strlen→strval).Motivation
IMP forwards the backend
namespacesetting frombackends.phpasgetNamespaces()’s$additionalargument. Callingarray_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
Stringablebefore normalizing$additional.array_map('strval', iterator_to_array($ns))when building the already-detected set.$additionalentries are ignored.GetNamespacesTestcovering nested-array input, duplicate skip, and Mailbox/Stringableinput.Test plan
phpunit test/Unit/Base/GetNamespacesTest.php(3 tests)namespaceentry no longer logs the warningarray('#shared/', …)) still adds unadvertised namespaces as before