Skip to content

Commit

Permalink
Get correct feed_id for notification attachment (#168)
Browse files Browse the repository at this point in the history
Release 2.0.2
  • Loading branch information
doekenorg authored Jun 5, 2023
1 parent eb54e9e commit 4819449
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gfexcel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: GravityExport Lite
* Version: 2.0.1
* Version: 2.0.2
* Plugin URI: https://gfexcel.com
* Description: Export all Gravity Forms entries to Excel (.xlsx) or CSV via a secret shareable URL.
* Author: GravityKit
Expand Down Expand Up @@ -29,7 +29,7 @@
}

if ( ! defined( 'GFEXCEL_PLUGIN_VERSION' ) ) {
define( 'GFEXCEL_PLUGIN_VERSION', '2.0.1' );
define( 'GFEXCEL_PLUGIN_VERSION', '2.0.2' );
}

if ( ! defined( 'GFEXCEL_MIN_PHP_VERSION' ) ) {
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: Gravity Forms, GravityForms, Excel, Export, Download, Entries, CSV
Requires at least: 4.0
Requires PHP: 7.2
Tested up to: 6.2
Stable tag: 2.0.1
Stable tag: 2.0.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -256,7 +256,11 @@ You can hide a row by adding a hook. Checkout this example:

== Changelog ==

= 2.0.1 on Jun 2, 2023 =
= 2.0.2 on June 5,2023 =

* Bugfix: Attachments could have the wrong fields.

= 2.0.1 on June 2, 2023 =

* Bugfix: The notification for the migration could throw an exception in some instances.

Expand Down
6 changes: 5 additions & 1 deletion src/Action/NotificationAttachmentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GFExcel\Action;

use GFExcel\Addon\GravityExportAddon;
use GFExcel\GFExcel;
use GFExcel\GFExcelOutput;
use GFExcel\Repository\FormsRepository;
Expand Down Expand Up @@ -46,8 +47,11 @@ private function handle_notification( array $notification, array $form, array $e
return $notification;
}

$feed = GravityExportAddon::get_instance()->get_feed_by_form_id( $form['id'] );
$feed_id = $feed['id'] ?? null;

// create a file based on the settings in the form, with only this entry.
$output = new GFExcelOutput( $form['id'], GFExcel::getRenderer( $form['id'] ) );
$output = new GFExcelOutput( $form['id'], GFExcel::getRenderer( $form['id'] ), null, $feed_id );
$output->setEntries( [ $entry ] );

// save the file to a temporary file
Expand Down
5 changes: 3 additions & 2 deletions src/GFExcelOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GFExcelOutput
* The feed object.
* @var mixed[]
*/
private $feed;
private $feed = [];

/**
* The form entries.
Expand Down Expand Up @@ -87,6 +87,7 @@ class GFExcelOutput
* @param int $form_id The form id.
* @param RendererInterface $renderer The renderer.
* @param CombinerInterface|null $combiner The combiner. {@since 1.8.0}
* @param int|null $feed_id The feed id.
*/
public function __construct($form_id, RendererInterface $renderer, ?CombinerInterface $combiner = null, $feed_id = null)
{
Expand Down Expand Up @@ -199,7 +200,7 @@ private function getForm()
*/
private function getFeed()
{
if ( ! $this->feed ) {
if ( ! $this->feed && $this->feed_id > 0 ) {
// TODO: Use \GFAPI::get_feed when GF minimum version requirement is bumped to ≥2.4.24
$feeds = \GFAPI::get_feeds( $this->feed_id, null, null, null );

Expand Down

0 comments on commit 4819449

Please sign in to comment.