Skip to content

Conversation

@ant-tar
Copy link

@ant-tar ant-tar commented Jan 4, 2026

Fixed: PHP 8 fatal error when merging xPDOIterator; replaced with safe foreach iteration.

Fixed: PHP 8 fatal error when merging xPDOIterator; replaced with safe foreach iteration.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a PHP 8 compatibility issue where array_merge() was being used with an xPDOIterator object, which causes a fatal error. The fix replaces the problematic array_merge() calls with safe foreach iteration to manually add iterator items to the array.

Changes:

  • Replaced array_merge() with foreach iteration for xPDOIterator in two locations
  • Added empty check for $resource before calling getChildIds()
  • Improved code formatting with proper spacing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!empty($resource) && ($child_ids = $modx->getChildIds($resource->id, 50, array('context' => $resource->context_key)))) {
$children = $modx->getIterator('modResource', array('id:IN' => $child_ids));
foreach ($children as $child) {
$resources[] = $child;
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace at the end of this line. Remove the space after the semicolon to maintain clean code formatting.

Suggested change
$resources[] = $child;
$resources[] = $child;

Copilot uses AI. Check for mistakes.
if (!empty($resource) && ($child_ids = $modx->getChildIds($resource->id, 50, array('context' => $resource->context_key)))) {
$children = $modx->getIterator('modResource', array('id:IN' => $child_ids));
foreach ($children as $child) {
$resources[] = $child;
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace at the end of this line. Remove the space after the semicolon to maintain clean code formatting.

Suggested change
$resources[] = $child;
$resources[] = $child;

Copilot uses AI. Check for mistakes.
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.

1 participant