Skip to content

Commit

Permalink
Fix iteration to progress through different table iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonpayton committed Dec 23, 2024
1 parent cc28a90 commit 0fbf4e6
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
return;
}

header('Content-Type: text/plain');
$export_iterator = new WP_Entity_Export_Iterator();
foreach ($export_iterator as $key => $entity) {
echo "Key: $key\n";
Expand Down Expand Up @@ -98,6 +99,7 @@ public function next() {
$this->current_id
)
);
// @TODO: How to handle errors?
$this->current_entity = null;
if ($current_row) {
Expand Down Expand Up @@ -134,6 +136,10 @@ public function current() {

#[\ReturnTypeWillChange]
public function next() {
if (!$this->entity_iterator_iterator->valid()) {
return;
}

$this->entity_iterator_iterator->current()->next();
if (!$this->entity_iterator_iterator->current()->valid()) {
$this->entity_iterator_iterator->next();
Expand Down Expand Up @@ -167,10 +173,7 @@ public function key() {

#[\ReturnTypeWillChange]
public function valid() {
return (
$this->entity_iterator_iterator->valid() &&
$this->entity_iterator_iterator->current()->valid()
);
return $this->entity_iterator_iterator->valid();
}

// TODO: Maybe simplify this if we stick with just iterating over rows for all tables.
Expand Down

0 comments on commit 0fbf4e6

Please sign in to comment.