Skip to content

Commit

Permalink
Store known Permalinks to speed up export
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Dec 26, 2023
1 parent 5fabd7b commit 7c80667
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion includes/admin/class-import-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public static function export_tables() {
}

$data_rows = array();
$url_list = array();

$sql = 'SELECT * FROM ' . $table_name;
if ( ! $network_wide ) {
Expand All @@ -315,7 +316,15 @@ public static function export_tables() {
$row[] = $result['blog_id'];

if ( $export_urls ) {
$row[] = ( is_multisite() && $network_wide ) ? get_blog_permalink( $result['blog_id'], $result['postnumber'] ) : get_permalink( $result['postnumber'] );
// Check if $result['postnumber'] is found in $url_list array. $url_list is an associative array with post ID as key and URL as value.
if ( isset( $url_list[ $result['postnumber'] ] ) ) {
$row[] = $url_list[ $result['postnumber'] ];
} else {
// If $result['postnumber'] is not found in $url_list array, get URL from $result['postnumber'] and add it to $url_list array.
$row[] = ( is_multisite() && $network_wide ) ? get_blog_permalink( $result['blog_id'], $result['postnumber'] ) : get_permalink( $result['postnumber'] );

$url_list[ $result['postnumber'] ] = $row[4];
}
}

$data_rows[] = $row;
Expand Down

0 comments on commit 7c80667

Please sign in to comment.