Skip to content

Commit

Permalink
Assign GUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Nov 5, 2024
1 parent 48ee5a0 commit 58150bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/playground/data-liberation/docs-importer-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ function import_markdown_files() {
break;
}
}

$parent_path = dirname($event->dir->getRealPath());
$parent_id = $directory_indexes[$parent_path] ?? null;
$relative_path = substr($event->dir->getRealPath(), strlen($root_dir));

if(null !== $directory_index_idx) {
array_splice($files, $directory_index_idx, 1)[0];
Expand All @@ -61,6 +63,7 @@ function import_markdown_files() {
file_get_contents($file->getRealPath()),
$next_post_id,
$parent_id,
$relative_path,
slug_to_title($file->getFilename()),
);
} else {
Expand All @@ -71,6 +74,7 @@ function import_markdown_files() {
'',
$next_post_id,
$parent_id,
$relative_path,
slug_to_title($event->dir->getFilename()),
);
}
Expand All @@ -85,6 +89,7 @@ function import_markdown_files() {
file_get_contents($file->getRealPath()),
$next_post_id,
$directory_index_id,
$relative_path,
$title_fallback
);
++$next_post_id;
Expand All @@ -98,8 +103,8 @@ function import_markdown_file(
$markdown,
$post_id,
$parent_id,
$guid,
$title_fallback = '',
$title_override = '',
) {
$converter = new WP_Markdown_To_Blocks($markdown);
$converter->parse();
Expand All @@ -111,7 +116,7 @@ function import_markdown_file(
$block_markup = $removed_title['remaining_html'];
}

$post_title = $title_override;
$post_title = '';
if(!$post_title && !empty($removed_title['content'])) {
$post_title = $removed_title['content'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ protected function prefill_existing_posts() {
* @return int|bool Existing post ID if it exists, false otherwise.
*/
protected function post_exists( $data ) {
return false;
// Constant-time lookup if we prefilled
$exists_key = $data['guid'] ?? null;

Expand Down

0 comments on commit 58150bb

Please sign in to comment.