Skip to content

Fix listing export columns for multiple directories - #3002

Closed
the-sohan wants to merge 1 commit into
sovware:developmentfrom
the-sohan:fix/listing-export-multidirectory-columns
Closed

Fix listing export columns for multiple directories#3002
the-sohan wants to merge 1 commit into
sovware:developmentfrom
the-sohan:fix/listing-export-multidirectory-columns

Conversation

@the-sohan

@the-sohan the-sohan commented Sep 9, 2026

Copy link
Copy Markdown

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

Listing exports containing listings from multiple directory types could omit fields or place values under the wrong columns. The exporter previously selected one row with the greatest field count as the column model; rows from other directory types can have different keys even when they contain the same number of fields.

This change builds an ordered union of the column keys present in every exported row, then aligns each row to that complete column set. Missing values remain empty, and array_key_exists() preserves columns whose value is explicitly null.

How to reproduce the issue or test the changes:

  1. Create two directory types with at least one distinct submission field in each, and publish a listing in both directories.
  2. Export all listings from Directorist → Settings → Tools → Listings → Export.
  3. Open the CSV and verify that fields from both directory types have their own columns, values appear under the correct headers, and missing values are empty.

Local verification:

  • php -l includes/classes/class-listings-export.php
  • vendor/bin/phpcs --standard=phpcs.xml includes/classes/class-listings-export.php
  • php -r regression scenario covering equal-length rows with different directory-specific keys
  • git diff --check origin/development...HEAD

Notes:

  • GitHub's PHPCS Check workflow cannot check out this fork-based PR because it runs on pull_request_target and actions/checkout rejects fork code unless allow-unsafe-pr-checkout is enabled. The same PHPCS command passes locally.

Any linked issues

Checklist

Files changed

  • includes/classes/class-listings-export.php — Build the export schema from all listing rows and align every row to the complete set of columns.

@the-sohan the-sohan closed this Sep 9, 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