Plugin Directory

Changeset 3674640


Ignore:
Timestamp:
08/31/2026 04:43:27 PM (3 months ago)
Author:
labelgrid
Message:

1.4.15

Location:
label-grid-tools/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • label-grid-tools/trunk/README.txt

    r3569187 r3674640  
    8282== Changelog ==
    8383
     84= 1.4.15 =
     85* Fix: Catalog sync froze at the "Processing genres" step and no genres were ever imported. Genres are now imported correctly, a sync that returns no data reports the error instead of hanging, and a failure in one section no longer stops the rest of the scheduled sync from running.
     86* Fix: Pre-save could fail silently on slow connections ‚ the session was not always ready before the pre-save was submitted, and errors were never shown. Sessions now wait properly and any failure is reported instead of failing quietly.
     87
    8488= 1.4.14 =
    8589* Fix: A WordPress "critical error" could appear on the LabelGrid Tools settings page when the saved API token contained stray spaces or line breaks (for example when the key is copied from the dashboard, where it wraps across several lines). The token is now cleaned before use and connection errors are handled gracefully instead of crashing the page.
  • label-grid-tools/trunk/admin/class-sync-content-data.php

    r3569163 r3674640  
    9191                else {
    9292                    LabelGrid_Tools::log_event('Update - No data retrieved', 'error', 'sync-catalog');
    93                     exit();
     93                    // A bare exit() answered an AJAX request expecting JSON with an
     94                    // empty body, so the progress bar hung on "DO NOT CLOSE THIS
     95                    // WINDOW" forever. Hand the failure back to the caller instead.
     96                    return array(
     97                        'more' => false,
     98                        'error' => sprintf(
     99                            /* translators: %s: catalog section being imported, e.g. genres */
     100                            esc_html__('No data was returned by LabelGrid for "%s". The import has been stopped.', 'label-grid-tools'),
     101                            esc_html($this->actions[0])
     102                        )
     103                    );
    94104                }
    95105
    … …  
    137147                else {
    138148                    LabelGrid_Tools::log_event('Silent Update - No data retrieved || Action: ' . $action . ' feed: ' . print_r($feed->data, true), 'error', 'sync-catalog');
    139                     exit();
     149                    // Skip only this action: exit() aborted the whole run, so every
     150                    // later action (releases included) was never synced.
     151                    continue;
    140152                }
    141153
    … …  
    878890        $the_post_id = 0;
    879891
    880         if ($genre->active == 'off')
     892        // `active` arrives from the API as a real JSON boolean, and comparing a
     893        // boolean against the non-empty string 'off' casts the string to true, so
     894        // the old test skipped every ACTIVE genre and kept the inactive ones.
     895        // Accept both the boolean and the legacy 'on'/'off' string form; anything
     896        // unrecognised, empty or missing is treated as active, so an unexpected
     897        // payload can never silently stop the import again.
     898        $genre_active = (isset($genre->active) && $genre->active !== '')
     899            ? filter_var($genre->active, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)
     900            : null;
     901
     902        if ($genre_active === false)
    881903            $skip = true;
    882904
  • label-grid-tools/trunk/admin/traits/sync-page.php

    r3179042 r3674640  
    2727        $percentage = $import->lgt_get_percentage_complete();
    2828
     29        if (! empty($ret['error'])) {
     30            // The admin JS reads `error` and `message` at the TOP level and always
     31            // dereferences data.step, so all three keys have to be present or the
     32            // progress bar hangs instead of showing the failure.
     33            wp_send_json(array(
     34                'success' => false,
     35                'error' => true,
     36                'message' => $ret['error'],
     37                'data' => array(
     38                    'step' => 'done'
     39                )
     40            ));
     41        }
     42
    2943        if ($ret['more']) {
    3044            $step += 1;
  • label-grid-tools/trunk/labelgrid-tools.php

    r3569187 r3674640  
    1515 * Plugin Name:       LabelGrid Tools
    1616 * Description:       LabelGrid Tools is an advanced plugin for Record Labels, Artists, and Distributors that allow to showcase music releases with ease providing advanced promotional and pre-release tools.
    17  * Version:           1.4.14
     17 * Version:           1.4.15
    1818 * Author:            LabelGrid
    1919 * Author URI:        https://labelgrid.com
    … …  
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define('LGT_PLUGIN_VERSION', '1.4.14');
     36define('LGT_PLUGIN_VERSION', '1.4.15');
    3737
    3838/**
  • label-grid-tools/trunk/public/js/labelgrid-tools-public-gate.js

    r2503487 r3674640  
    9797                                        function(reason) {
    9898                                                console.error('Something went wrong', reason);
     99                                                lg_gate_show_error('#modalwindow-freedownload', __('We could not start your session. Please check your connection and try again.', 'labelgrid-tools'));
    99100                                        });
    100101
    … …  
    128129                                        function(reason) {
    129130                                                console.error('Something went wrong', reason);
     131                                                lg_gate_show_error('#modalwindow-presave', __('We could not start your session. Please check your connection and try again.', 'labelgrid-tools'));
    130132                                        });
    131133
    … …  
    324326        }
    325327
     328        // Per-request timeout for the gate session calls (ms).
     329        var LGT_GATE_REQUEST_TIMEOUT = 15000;
     330
     331        // Show a failure inside the open modal instead of only logging to console.
     332        function lg_gate_show_error(windowid, message) {
     333                $(windowid + ' #popdescription').html(message);
     334                $(windowid + ' #content').html('');
     335        }
     336
    326337        function open_session(is_presave = false) {
    327338                return new Promise(
    328339                        function(resolve, reject) {
     340                                // The wall-clock setTimeout that used to live here rejected after 5s
     341                                // while add-session could still be in flight, and the flow then ran
     342                                // get-playlists/add-presave against a session that did not exist yet.
     343                                // Each request now carries its own timeout, so a slow call is ABORTED
     344                                // and reported through error() - the promise can only settle once,
     345                                // and never while a request is still running.
    329346                                $.ajax({
    330347                                        url: lgt_install_url + '/wp-json/lgt-gate-api/v1/check-session',
    331348                                        type: 'GET',
     349                                        timeout: LGT_GATE_REQUEST_TIMEOUT,
    332350                                        success: function(response) {
    333351
     352                                                if (!response || !response.session) {
     353                                                        reject(new Error('check-session returned no session'));
     354                                                        return;
     355                                                }
    334356
    335357                                                lg_set_session(response.session);
    … …  
    346368                                                        data: data_session,
    347369                                                        type: 'POST',
     370                                                        timeout: LGT_GATE_REQUEST_TIMEOUT,
    348371                                                        success: function(data) {
     372                                                                if (data && data.message == 'ko') {
     373                                                                        reject(new Error('add-session refused'));
     374                                                                        return;
     375                                                                }
    349376                                                                resolve();
     377                                                        },
     378                                                        error: function(xhr, status) {
     379                                                                reject(new Error('add-session failed: ' + status));
    350380                                                        }
    351381                                                });
    352382
    353383
     384                                        },
     385                                        error: function(xhr, status) {
     386                                                reject(new Error('check-session failed: ' + status));
    354387                                        }
    355388                                });
    356 
    357                                 setTimeout(() => reject(new Error()), 5000);
    358389                        });
    359390        }
    … …  
    576607                        type: 'POST',
    577608                        success: function(response) {
    578                                 if (response.message == 'ok' && playlist_id != null) alert(__('Track/s will be added to the selected playlist on ', 'labelgrid-tools') + lgt_release_date);
    579                                 else if (playlist_id != null) alert(__('Error scheduling the pre-save. Please contact an Administrator.', 'labelgrid-tools'));
     609                                // A failure has to be reported whether or not a playlist was chosen:
     610                                // both branches used to be gated on playlist_id != null, so the
     611                                // track/album pre-save failed completely silently.
     612                                if (response && response.message == 'ok') {
     613                                        if (playlist_id != null) alert(__('Track/s will be added to the selected playlist on ', 'labelgrid-tools') + lgt_release_date);
     614                                }
     615                                else alert(__('Error scheduling the pre-save. Please contact an Administrator.', 'labelgrid-tools'));
     616                        },
     617                        error: function(xhr, status) {
     618                                console.error('add-presave failed', status);
     619                                alert(__('Error scheduling the pre-save. Please contact an Administrator.', 'labelgrid-tools'));
    580620                        }
    581621                });
    … …  
    637677                        success: function(data) {
    638678                                //console.log(data);
     679                                // The endpoint answers HTTP 200 with a bare `false` (or `true`) when
     680                                // the gate call failed or returned nothing - e.g. the 422 "Session
     681                                // Null" case - so error() alone would never see it.
     682                                if (!data || typeof data !== 'object' || !data.playlists) {
     683                                        console.error('get-playlists returned no playlists', data);
     684                                        lg_gate_show_error('#modalwindow-presave', __('We could not load your playlists. Please close this window and try again.', 'labelgrid-tools'));
     685                                        return;
     686                                }
    639687                                callbacks['get_playlist_save'](data);
     688                        },
     689                        error: function(xhr, status) {
     690                                console.error('get-playlists failed', status);
     691                                lg_gate_show_error('#modalwindow-presave', __('We could not load your playlists. Please close this window and try again.', 'labelgrid-tools'));
    640692                        }
    641693                });
Note: See TracChangeset for help on using the changeset viewer.