Skip to content

Commit

Permalink
2.3 better detection (by database version)
Browse files Browse the repository at this point in the history
This is the more correct way, since updates can fail with a
codebase that is 2.3-enabled we'll be querying the wrong tables.
  • Loading branch information
soulseekah committed Oct 1, 2017
1 parent 754ff5e commit 245def6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion future/includes/class-gv-entry-gravityforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function by_id( $entry_id ) {
public static function by_slug( $entry_slug, $form_id = 0 ) {
global $wpdb;

if ( method_exists( '\GFFormsModel', 'get_entry_meta_table_name' ) ) {
if ( version_compare( \GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) {
$entry_meta = \GFFormsModel::get_entry_meta_table_name();
$sql = "SELECT entry_id FROM $entry_meta";
} else {
Expand Down
4 changes: 2 additions & 2 deletions includes/extensions/edit-entry/class-edit-entry-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private function process_save() {
private function unset_hidden_field_values() {
global $wpdb;

if ( method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) {
$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
} else {
Expand Down Expand Up @@ -839,7 +839,7 @@ private function after_update() {

$entry = GFFormsModel::set_entry_meta( $entry, $this->form );

if ( ! method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
// We need to clear the cache because Gravity Forms caches the field values, which
// we have just updated.
foreach ($this->form['fields'] as $key => $field) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/GravityView_Future_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3454,7 +3454,7 @@ public function test_frontend_field_html_post() {

global $wpdb;

if ( method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) {
$wpdb->insert( GFFormsModel::get_entry_meta_table_name(), array(
'entry_id' => $entry['id'], 'form_id' => $form['id'],
'meta_key' => '24', 'meta_value' => $image
Expand Down

0 comments on commit 245def6

Please sign in to comment.