diff --git a/classes/models/FrmUsage.php b/classes/models/FrmUsage.php index 138ba63136..df095ffcbb 100644 --- a/classes/models/FrmUsage.php +++ b/classes/models/FrmUsage.php @@ -603,22 +603,41 @@ private function fields() { * @return array */ private function actions() { - $args = array( - 'post_type' => FrmFormActionsController::$action_post_type, - 'numberposts' => 100, - ); + $actions = array(); + $offset = 0; + $limit = 100; + $limit_plus_one = $limit + 1; + + do { + $args = array( + 'post_type' => FrmFormActionsController::$action_post_type, + 'numberposts' => $limit_plus_one, + 'offset' => $offset, + ); + $saved_actions = get_posts( $args ); + $has_more = count( $saved_actions ) === $limit_plus_one; - $actions = array(); - $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' ); + if ( $has_more ) { + // Pop off the last item as it is only queried to determine if there are more results. + array_pop( $saved_actions ); + } - foreach ( $saved_actions as $action ) { - $actions[] = array( - 'form_id' => $action->menu_order, - 'type' => $action->post_excerpt, - 'status' => $action->post_status, - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), - ); - } + foreach ( $saved_actions as $action ) { + $actions[] = array( + 'form_id' => $action->menu_order, + 'type' => $action->post_excerpt, + 'status' => $action->post_status, + 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), + ); + unset( $action ); + } + + $offset += $limit; + + unset( $saved_actions ); + + gc_collect_cycles(); + } while ( $has_more ); return $actions; }