If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / Can anyone help me solve the plugin error problem?

Can anyone help me solve the plugin error problem?

Started by targetmarts on 17 Aug 2023, 9:56 AM · Views: 1,770

Results 1 to 11 of 11
17 Aug 2023, 9:56 AM
#1
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #1 by targetmarts

[Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here.
And, remove this comment before actually posting!]
site:https://heelsbags.com
Database Engine: MySQL 5.6.51-cll-lve
HTTP Server: Apache
PHP Version: 8.1.21 (Zend: 4.1.21)
zen cart v1.5.8a
plugins:
Zen Colorbox
Ultimate URLs 3.1.0
SitemapXML 3.9.9
Easy Populate 4
Database Backup Manager - MySQL
Image Handler5 Version: 5.3.4

#0 /home/.../public_html/heelsbags/includes/init_includes/init_sessions.php(125): zen_debug_error_handler()
#1 /home/.../public_html/heelsbags/includes/autoload_func.php(40): require_once('/home/g67mwiq1l...')
#2 /home/.../public_html/heelsbags/includes/application_top.php(237): require('/home/g67mwiq1l...')
#3 /home/.../public_html/heelsbags/index.php(25): require('/home/g67mwiq1l...')
--> PHP Warning: Undefined array key "SSL_SESSION_ID" in /home/.../public_html/heelsbags/includes/init_includes/init_sessions.php on line 125.
here is the code of init_sessions.php on line 125
$ssl_session_id = $_SERVER['SSL_SESSION_ID'];

17 Aug 2023, 4:44 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #2 by lat9

Thanks for the report; that's a bug! The pertinent section of code in /includes/init_includes/init_sessions.php is below, with line 125 highlighted:

/**
 * verify the ssl_session_id if the feature is enabled
 */
if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == 'true') && ($session_started == true) ) {
  [B]$ssl_session_id = $_SERVER['SSL_SESSION_ID'];[/B]
  if (empty($_SESSION['SSL_SESSION_ID'])) {
    $_SESSION['SSL_SESSION_ID'] = $ssl_session_id;
  }
  if ($_SESSION['SSL_SESSION_ID'] != $ssl_session_id) {
    zen_session_destroy();
    zen_redirect(zen_href_link(FILENAME_SSL_CHECK));
  }
}

While the Zen Cart devs determine how best to correct this issue, you can work-around the issue by setting Configuration :: Sessions :: Check SSL Session ID to its default of 'False'.

Zen Cart GitHub issue: https://github.com/zencart/zencart/issues/5940

18 Aug 2023, 12:16 AM
#3
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #3 by targetmarts

lat9:

Thanks for the report; that's a bug! The pertinent section of code in /includes/init_includes/init_sessions.php is below, with line 125 highlighted:

/**

  • verify the ssl_session_id if the feature is enabled
    */
    if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == 'true') && ($session_started == true) ) {
    [B]$ssl_session_id = $_SERVER['SSL_SESSION_ID'];[/B]
    if (empty($_SESSION['SSL_SESSION_ID'])) {
    $_SESSION['SSL_SESSION_ID'] = $ssl_session_id;
    }
    if ($_SESSION['SSL_SESSION_ID'] != $ssl_session_id) {
    zen_session_destroy();
    zen_redirect(zen_href_link(FILENAME_SSL_CHECK));
    }
    }
> 
> While the Zen Cart devs determine how best to correct this issue, you can *work-around* the issue by setting ***Configuration :: Sessions :: Check SSL Session ID*** to its default of 'False'.
> 
> Zen Cart GitHub issue: <https://github.com/zencart/zencart/issues/5940>

ok,thanks,so that means to set Configuration :: Sessions :: Check SSL Session ID  "false"  to fix this bug logs?
18 Aug 2023, 12:57 AM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #4 by lat9

targetmarts:

ok,thanks,so that means to set Configuration :: Sessions :: Check SSL Session ID "false" to fix this bug logs?
What it means is that you can cause those logs not to be generated by setting that configuration value to "False"; the logs will continue to be generated when the value is set to "True".

Again, that's a way to work-around that bug, not a correction/fix.

18 Aug 2023, 12:17 PM
#5
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #5 by targetmarts

lat9:

What it means is that you can cause those logs not to be generated by setting that configuration value to "False"; the logs will continue to be generated when the value is set to "True".

Again, that's a way to work-around that bug, not a correction/fix.

ok i did it and test again,but maybe it can't login up and checkout , it always goto https://heelsbags.com/index.php?main_page=cookie_usage
"We have detected that your browser does not support cookies, or cookies have been disabled."

18 Aug 2023, 4:28 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #6 by lat9

Would you post a screenshot of the site's Configuration :: Sessions settings? Since there was one non-default setting, perhaps there's another that's causing that cookie required page.

If you have a test account-login that you can share with me, send me a PM with that information.

19 Aug 2023, 1:03 AM
#7
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #7 by targetmarts

lat9:

Would you post a screenshot of the site's Configuration :: Sessions settings? Since there was one non-default setting, perhaps there's another that's causing that cookie required page.

If you have a test account-login that you can share with me, send me a PM with that information.

Sessions
Title Value Action
Session Directory /tmp
Cookie Domain True Info
Force Cookie Use True Info
Check SSL Session ID False Info
Check User Agent True Info
Check IP Address False Info
Prevent Spider Sessions True Info
Recreate Session True Info
IP to Host Conversion Status true Info
Use root path for cookie path False Info
Add period prefix to cookie domain True Info

test
[email protected]
heelsbags

with cloudflare information
Attachment 20357

19 Aug 2023, 10:19 AM
#8
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #8 by targetmarts

ok,i have set the cloudflare again,and maybe it work now,but i hope you help me to test ,beacuse i don't know if have any other question,but there have an problem for cart,the cart don't upgrade when click "add to cart"button,and it don't upgrade when goto cart(https://heelsbags.com/index.php?main_page=shopping_cart%29,you must enter F5 to Refresh(or click refresh botton).
as if i add "Hikvision DS-2DE7A825IW-AEB(T5) 7-inch 8 MP 25X Powered by DarkFighter IR Network Speed Dome ptz cameras" or "Dahua NVR616-64-4KS2 64 Channel 3U 16HDDs Ultra series Network Video Recorder nvr" to cart, No updated shopping cart displayed at the top of website page.and we must refresh the page,then upated .
what's happend?

19 Aug 2023, 10:29 AM
#9
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #9 by targetmarts

second
Maybe you can help me to upgrade or perfect cloudflare workers and pages.i found a code from internet for worker.js,but i don't know how about it(sure i have set the api ):

// API settings if KV isn't being used
const CLOUDFLARE_API = {
  email: "****", // From https://dash.cloudflare.com/profile
  key: "****",   // Global API Key from https://dash.cloudflare.com/profile
  zone: "*****"   // "Zone ID" from the API section of the dashboard overview page https://dash.cloudflare.com/
};
// source: https://github.com/cloudflare/worker-examples/blob/master/examples/edge-cache-html/edge-cache-html.js
// IMPORTANT: Either A Key/Value Namespace must be bound to this worker script
// using the variable name EDGE_CACHE. or the API parameters below should be
// configured. KV is recommended if possible since it can purge just the HTML
// instead of the full cache.

// Default cookie prefixes for bypass
const DEFAULT_BYPASS_COOKIES = [
  "zc-",
  "zencart",
  "comment_",
  "zen_"
];

/**
 * Main worker entry point.
 */
addEventListener("fetch", event => {
  const request = event.request;
  let upstreamCache = request.headers.get('x-HTML-Edge-Cache');

  // Only process requests if KV store is set up and there is no
  // HTML edge cache in front of this worker (only the outermost cache
  // should handle HTML caching in case there are varying levels of support).
  let configured = false;
  if (typeof EDGE_CACHE !== 'undefined') {
    configured = true;
  } else if (CLOUDFLARE_API.email.length && CLOUDFLARE_API.key.length && CLOUDFLARE_API.zone.length) {
    configured = true;
  }

  // Bypass processing of image requests (for everything except Firefox which doesn't use image/*)
  const accept = request.headers.get('Accept');
  let isImage = false;
  if (accept && (accept.indexOf('image/*') !== -1)) {
    isImage = true;
  }

  if (configured && !isImage && upstreamCache === null) {
    event.passThroughOnException();
    event.respondWith(processRequest(request, event));
  }
});

/**
 * Process every request coming through to add the edge-cache header,
 * watch for purge responses and possibly cache HTML GET requests.
 *
 * @param {Request} originalRequest - Original request
 * @param {Event} event - Original event (for additional async waiting)
 */
async function processRequest(originalRequest, event) {
  let cfCacheStatus = null;
  const accept = originalRequest.headers.get('Accept');
  const isHTML = (accept && accept.indexOf('text/html') >= 0);
  let {response, cacheVer, status, bypassCache} = await getCachedResponse(originalRequest);

  if (response === null) {
    // Clone the request, add the edge-cache header and send it through.
    let request = new Request(originalRequest);
    request.headers.set('x-HTML-Edge-Cache', 'supports=cache|purgeall|bypass-cookies');
    response = await fetch(request);

    if (response) {
      const options = getResponseOptions(response);
      if (options && options.purge) {
        await purgeCache(cacheVer, event);
        status += ', Purged';
      }
      bypassCache = bypassCache || shouldBypassEdgeCache(request, response);
      if ((!options || options.cache) && isHTML &&
          originalRequest.method === 'GET' && response.status === 200 &&
          !bypassCache) {
        status += await cacheResponse(cacheVer, originalRequest, response, event);
      }
    }
  } else {
    // If the origin didn't send the control header we will send the cached response but update
    // the cached copy asynchronously (stale-while-revalidate). This commonly happens with
    // a server-side disk cache that serves the HTML directly from disk.
    cfCacheStatus = 'HIT';
    if (originalRequest.method === 'GET' && response.status === 200 && isHTML) {
      bypassCache = bypassCache || shouldBypassEdgeCache(originalRequest, response);
      if (!bypassCache) {
        const options = getResponseOptions(response);
        if (!options) {
          status += ', Refreshed';
          event.waitUntil(updateCache(originalRequest, cacheVer, event));
        }
      }
    }
  }

  if (response && status !== null && originalRequest.method === 'GET' && response.status === 200 && isHTML) {
    response = new Response(response.body, response);
    response.headers.set('x-HTML-Edge-Cache-Status', status);
    if (cacheVer !== null) {
      response.headers.set('x-HTML-Edge-Cache-Version', cacheVer.toString());
    }
    if (cfCacheStatus) {
      response.headers.set('CF-Cache-Status', cfCacheStatus);
    }
  }

  return response;
}

/**
 * Determine if the cache should be bypassed for the given request/response pair.
 * Specifically, if the request includes a cookie that the response flags for bypass.
 * Can be used on cache lookups to determine if the request needs to go to the origin and
 * origin responses to determine if they should be written to cache.
 * @param {Request} request - Request
 * @param {Response} response - Response
 * @returns {bool} true if the cache should be bypassed
 */
function shouldBypassEdgeCache(request, response) {
  let bypassCache = false;

  if (request && response) {
    const options = getResponseOptions(response);
    const cookieHeader = request.headers.get('cookie');
    let bypassCookies = DEFAULT_BYPASS_COOKIES;
    if (options) {
      bypassCookies = options.bypassCookies;
    }
    if (cookieHeader && cookieHeader.length && bypassCookies.length) {
      const cookies = cookieHeader.split(';');
      for (let cookie of cookies) {
        // See if the cookie starts with any of the logged-in user prefixes
        for (let prefix of bypassCookies) {
          if (cookie.trim().startsWith(prefix)) {
            bypassCache = true;
            break;
          }
        }
        if (bypassCache) {
          break;
        }
      }
    }
  }

  return bypassCache;
}

const CACHE_HEADERS = ['Cache-Control', 'Expires', 'Pragma'];

/**
 * Check for cached HTML GET requests.
 *
 * @param {Request} request - Original request
 */
async function getCachedResponse(request) {
  let response = null;
  let cacheVer = null;
  let bypassCache = false;
  let status = 'Miss';

  // Only check for HTML GET requests (saves on reading from KV unnecessarily)
  // and not when there are cache-control headers on the request (refresh)
  const accept = request.headers.get('Accept');
  const cacheControl = request.headers.get('Cache-Control');
  let noCache = false;
  if (cacheControl && cacheControl.indexOf('no-cache') !== -1) {
    noCache = true;
    status = 'Bypass for Reload';
  }
  if (!noCache && request.method === 'GET' && accept && accept.indexOf('text/html') >= 0) {
    // Build the versioned URL for checking the cache
    cacheVer = await GetCurrentCacheVersion(cacheVer);
    const cacheKeyRequest = GenerateCacheRequest(request, cacheVer);

    // See if there is a request match in the cache
    try {
      let cache = caches.default;
      let cachedResponse = await cache.match(cacheKeyRequest);
      if (cachedResponse) {
        // Copy Response object so that we can edit headers.
        cachedResponse = new Response(cachedResponse.body, cachedResponse);

        // Check to see if the response needs to be bypassed because of a cookie
        bypassCache = shouldBypassEdgeCache(request, cachedResponse);

        // Copy the original cache headers back and clean up any control headers
        if (bypassCache) {
          status = 'Bypass Cookie';
        } else {
          status = 'Hit';
          cachedResponse.headers.delete('Cache-Control');
          cachedResponse.headers.delete('x-HTML-Edge-Cache-Status');
          for (header of CACHE_HEADERS) {
            let value = cachedResponse.headers.get('x-HTML-Edge-Cache-Header-' + header);
            if (value) {
              cachedResponse.headers.delete('x-HTML-Edge-Cache-Header-' + header);
              cachedResponse.headers.set(header, value);
            }
          }
          response = cachedResponse;
        }
      } else {
        status = 'Miss';
      }
    } catch (err) {
      // Send the exception back in the response header for debugging
      status = "Cache Read Exception: " + err.message;
    }
  }

  return {response, cacheVer, status, bypassCache};
}

/**
 * Asynchronously purge the HTML cache.
 * @param {Int} cacheVer - Current cache version (if retrieved)
 * @param {Event} event - Original event
 */
async function purgeCache(cacheVer, event) {
  if (typeof EDGE_CACHE !== 'undefined') {
    // Purge the KV cache by bumping the version number
    cacheVer = await GetCurrentCacheVersion(cacheVer);
    cacheVer++;
    event.waitUntil(EDGE_CACHE.put('html_cache_version', cacheVer.toString()));
  } else {
    // Purge everything using the API
    const url = "https://api.cloudflare.com/client/v4/zones/" + CLOUDFLARE_API.zone + "/purge_cache";
    event.waitUntil(fetch(url,{
      method: 'POST',
      headers: {'X-Auth-Email': CLOUDFLARE_API.email,
                'X-Auth-Key': CLOUDFLARE_API.key,
                'Content-Type': 'application/json'},
      body: JSON.stringify({purge_everything: true})
    }));
  }
}

/**
 * Update the cached copy of the given page
 * @param {Request} originalRequest - Original Request
 * @param {String} cacheVer - Cache Version
 * @param {EVent} event - Original event
 */
async function updateCache(originalRequest, cacheVer, event) {
  // Clone the request, add the edge-cache header and send it through.
  let request = new Request(originalRequest);
  request.headers.set('x-HTML-Edge-Cache', 'supports=cache|purgeall|bypass-cookies');
  response = await fetch(request);

  if (response) {
    status = ': Fetched';
    const options = getResponseOptions(response);
    if (options && options.purge) {
      await purgeCache(cacheVer, event);
    }
    let bypassCache = shouldBypassEdgeCache(request, response);
    if ((!options || options.cache) && !bypassCache) {
      await cacheResponse(cacheVer, originalRequest, response, event);
    }
  }
}

/**
 * Cache the returned content (but only if it was a successful GET request)
 *
 * @param {Int} cacheVer - Current cache version (if already retrieved)
 * @param {Request} request - Original Request
 * @param {Response} originalResponse - Response to (maybe) cache
 * @param {Event} event - Original event
 * @returns {bool} true if the response was cached
 */
async function cacheResponse(cacheVer, request, originalResponse, event) {
  let status = "";
  const accept = request.headers.get('Accept');
  if (request.method === 'GET' && originalResponse.status === 200 && accept && accept.indexOf('text/html') >= 0) {
    cacheVer = await GetCurrentCacheVersion(cacheVer);
    const cacheKeyRequest = GenerateCacheRequest(request, cacheVer);

    try {
      // Move the cache headers out of the way so the response can actually be cached.
      // First clone the response so there is a parallel body stream and then
      // create a new response object based on the clone that we can edit.
      let cache = caches.default;
      let clonedResponse = originalResponse.clone();
      let response = new Response(clonedResponse.body, clonedResponse);
      for (header of CACHE_HEADERS) {
        let value = response.headers.get(header);
        if (value) {
          response.headers.delete(header);
          response.headers.set('x-HTML-Edge-Cache-Header-' + header, value);
        }
      }
      response.headers.delete('Set-Cookie');
      response.headers.set('Cache-Control', 'public; max-age=315360000');
      event.waitUntil(cache.put(cacheKeyRequest, response));
      status = ", Cached";
    } catch (err) {
      // status = ", Cache Write Exception: " + err.message;
    }
  }
  return status;
}

/******************************************************************************
 * Utility Functions
 *****************************************************************************/

/**
 * Parse the commands from the x-HTML-Edge-Cache response header.
 * @param {Response} response - HTTP response from the origin.
 * @returns {*} Parsed commands
 */
function getResponseOptions(response) {
  let options = null;
  let header = response.headers.get('x-HTML-Edge-Cache');
  if (header) {
    options = {
      purge: false,
      cache: false,
      bypassCookies: []
    };
    let commands = header.split(',');
    for (let command of commands) {
      if (command.trim() === 'purgeall') {
        options.purge = true;
      } else if (command.trim() === 'cache') {
        options.cache = true;
      } else if (command.trim().startsWith('bypass-cookies')) {
        let separator = command.indexOf('=');
        if (separator >= 0) {
          let cookies = command.substr(separator + 1).split('|');
          for (let cookie of cookies) {
            cookie = cookie.trim();
            if (cookie.length) {
              options.bypassCookies.push(cookie);
            }
          }
        }
      }
    }
  }

  return options;
}

/**
 * Retrieve the current cache version from KV
 * @param {Int} cacheVer - Current cache version value if set.
 * @returns {Int} The current cache version.
 */
async function GetCurrentCacheVersion(cacheVer) {
  if (cacheVer === null) {
    if (typeof EDGE_CACHE !== 'undefined') {
      cacheVer = await EDGE_CACHE.get('html_cache_version');
      if (cacheVer === null) {
        // Uninitialized - first time through, initialize KV with a value
        // Blocking but should only happen immediately after worker activation.
        cacheVer = 0;
        await EDGE_CACHE.put('html_cache_version', cacheVer.toString());
      } else {
        cacheVer = parseInt(cacheVer);
      }
    } else {
      cacheVer = -1;
    }
  }
  return cacheVer;
}

/**
 * Generate the versioned Request object to use for cache operations.
 * @param {Request} request - Base request
 * @param {Int} cacheVer - Current Cache version (must be set)
 * @returns {Request} Versioned request object
 */
function GenerateCacheRequest(request, cacheVer) {
  let cacheUrl = request.url;
  if (cacheUrl.indexOf('?') >= 0) {
    cacheUrl += '&';
  } else {
    cacheUrl += '?';
  }
  cacheUrl += 'cf_edge_cache_ver=' + cacheVer;
  return new Request(cacheUrl);
}

any one help me to check and perfect please.thanks

19 Aug 2023, 12:56 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #10 by lat9

Some of your Configuration :: Sessions settings are different from the default values.

Session Directory /tmp ... this is set by default to the file-system path to the site's /cache directory, e.g. /home/yoursite/public_html/cache
Cookie Domain True
**Force Cookie Use True **... Should be False, unless needed
Check SSL Session ID False
**Check User Agent True **... Should be False, unless needed
Check IP Address False
Prevent Spider Sessions True
Recreate Session True
IP to Host Conversion Status true
Use root path for cookie path False
Add period prefix to cookie domain True

Try changing those configuration settings and see if that helps.

20 Aug 2023, 12:25 AM
#11
targetmarts avatar

targetmarts

Zen Follower

Join Date:
Jan 2018
Posts:
122
Plugin Contributions:
0

Post #11 by targetmarts

lat9:

Some of your Configuration :: Sessions settings are different from the default values.

Session Directory /tmp ... this is set by default to the file-system path to the site's /cache directory, e.g. /home/yoursite/public_html/cache
Cookie Domain True
**Force Cookie Use True **... Should be False, unless needed
Check SSL Session ID False
**Check User Agent True **... Should be False, unless needed
Check IP Address False
Prevent Spider Sessions True
Recreate Session True
IP to Host Conversion Status true
Use root path for cookie path False
Add period prefix to cookie domain True

Try changing those configuration settings and see if that helps.

Ok,Thanks,i have did it,but the cart don't upgrade when add some products to cart.