Skip to content

Commit

Permalink
#43: Correct admin sequencing for changes that require USU cache resets.
Browse files Browse the repository at this point in the history
  • Loading branch information
lat9 committed Apr 20, 2021
1 parent 84c7070 commit c96c27f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
20 changes: 14 additions & 6 deletions YOUR_ADMIN/includes/classes/observers/UsuAdminObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Part of Ultimate URLs for Zen Cart.
*
* @copyright Copyright 2019 Cindy Merkin (vinosdefrutastropicales.com)
* @copyright Copyright 2019-2021 Cindy Merkin (vinosdefrutastropicales.com)
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL V3.0
*/
if (!defined('IS_ADMIN_FLAG') || IS_ADMIN_FLAG !== true) {
Expand All @@ -22,16 +22,24 @@ public function __construct()
'NOTIFY_SEFU_INTERCEPT_ADMCATHREF',
)
);

if (!class_exists('usu')) {
require DIR_FS_CATALOG . DIR_WS_CLASSES . 'usu.php';
}
$this->usu = new usu();
}
}

public function update(&$class, $eventID, $p1, &$p2, &$p3, &$p4, &$p5, &$p6, &$p7, &$p8)
{
// -----
// Moved here (was in constructor) so that any action detected by USU's admin initialization
// file that 'should' result in a cache-clearing will actually 'stick'. When in the constructor,
// the action that would result in a cache-related change wouldn't have been completed when
// the class-constructor attempts to re-build any missing caches.
//
if (!class_exists('usu')) {
require DIR_FS_CATALOG . DIR_WS_CLASSES . 'usu.php';
}
if (!isset($this->usu)) {
$this->usu = new usu();
}

switch ($eventID) {
// -----
// Issued at the top of the zen_catalog_href_link function to allow us to override the href-link
Expand Down
24 changes: 21 additions & 3 deletions YOUR_ADMIN/includes/init_includes/init_usu_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// last_modified date for the USU_VERSION configuration setting is updated to reflect
// the current update-date.
//
define('USU_CURRENT_VERSION', '3.0.9-beta1');
define('USU_CURRENT_UPDATE_DATE', '2021-04-18');
define('USU_CURRENT_VERSION', '3.0.9-beta2');
define('USU_CURRENT_UPDATE_DATE', '2021-04-20');

// -----
// Wait until an admin is logged in before seeing if any initialization steps need to be performed.
Expand Down Expand Up @@ -112,6 +112,15 @@
FILENAME_PRODUCT,
FILENAME_CATEGORIES,
FILENAME_CATEGORY_PRODUCT_LISTING,

// -----
// Adding product-specific handlers whose filenames aren't 'registered' in
// /includes/filenames.php.
//
'product_music',
'product_free_shipping',
'document_product',
'document_general',
);
if (in_array($usu_current_page, $usu_action_pages) && !empty($_GET['action'])) {
switch ($usu_current_page) {
Expand All @@ -128,7 +137,15 @@
break;

case FILENAME_PRODUCT:
if ($_GET['action'] == 'update_product') {
// -----
// Adding product-specific handlers whose filenames aren't 'registered' in
// /includes/filenames.php.
//
case 'product_music':
case 'product_free_shipping':
case 'document_product':
case 'document_general':
if (in_array($_GET['action'], array('update_product', 'delete_product_confirm'))) {
usu_reset_cache_data('products');
}
break;
Expand All @@ -142,6 +159,7 @@

case 'update_category':
case 'update_category_status':
case 'delete_category_confirm':
usu_reset_cache_data('categories');
break;

Expand Down

0 comments on commit c96c27f

Please sign in to comment.