Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1. #11
    Join Date
    Oct 2012
    Posts
    25
    Plugin Contributions
    0

    Default Re: myDEBUG-adm log files - question

    Started with v1.5.1

  2. #12
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    Default Re: myDEBUG-adm log files - question

    I've traced this down to the following conditions:
    1. The currently signed-in admin is not a superuser.
    2. The admin profile associated with that admin has one or more of the 'Product Types' enabled.

    For that set of conditions, the check_page function in admin_access.php is choking on the (non-existent) constant associated with the enabled Product Type. In that case, the main_page value returned for the enabled product type by the SQL query at line 29 of /ADMIN/includes/functions/admin_access.php is empty because there's no such key (e.g. _productTypes_product_music) to associate.

    With the changes in red, the debug logs no longer are created ... but I'm not sure if (a) it's an appropriate change and (b) if it's a complete change.
    Code:
      $sql = "SELECT ap.main_page, ap.page_params
              FROM " . TABLE_ADMIN . " a
              LEFT JOIN " . TABLE_ADMIN_PAGES_TO_PROFILES . " ap2p ON ap2p.profile_id = a.admin_profile
              LEFT JOIN " . TABLE_ADMIN_PAGES . " ap ON ap.page_key = ap2p.page_key
              WHERE admin_id = :adminId:";
      $sql = $db->bindVars($sql, ':adminId:', $_SESSION['admin_id'], 'integer');
      $result = $db->Execute($sql);
      $retVal = FALSE;
      while (!$result->EOF) {
        $pageName = zen_not_null($result->fields['main_page']) ? constant($result->fields['main_page']) : '';
        if (($pageName == $page || basename($pageName, '.php') == $page) && $result->fields['page_params'] == $page_params) {
          $retVal = TRUE;
        }
        $result->MoveNext();
      }
    I also noticed during my "playing" with this that it's not possible to check 'Product Types', 'Product - Free Shipping' in an admin profile and have it remain checked after clicking the Update button.

  3. #13
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    Default Re: myDEBUG-adm log files - question

    Quote Originally Posted by lat9 View Post
    I also noticed during my "playing" with this that it's not possible to check 'Product Types', 'Product - Free Shipping' in an admin profile and have it remain checked after clicking the Update button.
    The issue here is that the page_key value created in the admin_pages_to_profiles table (_productTypes_product_free_shipping) is 35 characters long and doesn't quite fit into the field that's defined as varchar(32).

  4. #14
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    Default Re: myDEBUG-adm log files - question

    Quote Originally Posted by lat9 View Post
    With the changes in red, the debug logs no longer are created ... but I'm not sure if (a) it's an appropriate change and (b) if it's a complete change.
    Code:
      $sql = "SELECT ap.main_page, ap.page_params
              FROM " . TABLE_ADMIN . " a
              LEFT JOIN " . TABLE_ADMIN_PAGES_TO_PROFILES . " ap2p ON ap2p.profile_id = a.admin_profile
              LEFT JOIN " . TABLE_ADMIN_PAGES . " ap ON ap.page_key = ap2p.page_key
              WHERE admin_id = :adminId:";
      $sql = $db->bindVars($sql, ':adminId:', $_SESSION['admin_id'], 'integer');
      $result = $db->Execute($sql);
      $retVal = FALSE;
      while (!$result->EOF) {
        $pageName = zen_not_null($result->fields['main_page']) ? constant($result->fields['main_page']) : '';
        if (($pageName == $page || basename($pageName, '.php') == $page) && $result->fields['page_params'] == $page_params) {
          $retVal = TRUE;
        }
        $result->MoveNext();
      }
    A better solution is to improve the query to 'weed out' the erroneous selection in the first place:
    Code:
      $sql = "SELECT ap.main_page, ap.page_params
              FROM " . TABLE_ADMIN . " a
              LEFT JOIN " . TABLE_ADMIN_PAGES_TO_PROFILES . " ap2p ON ap2p.profile_id = a.admin_profile
              LEFT JOIN " . TABLE_ADMIN_PAGES . " ap ON ap.page_key = ap2p.page_key
              WHERE admin_id = :adminId:
               AND ap2p.page_key NOT LIKE '_productTypes_%'";
      $sql = $db->bindVars($sql, ':adminId:', $_SESSION['admin_id'], 'integer');
      $result = $db->Execute($sql);
      $retVal = FALSE;
      while (!$result->EOF) {
        $pageName = constant($result->fields['main_page']);
        if (($pageName == $page || basename($pageName, '.php') == $page) && $result->fields['page_params'] == $page_params) {
          $retVal = TRUE;
        }
        $result->MoveNext();
      }

  5. #15
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: myDEBUG-adm log files - question

    Quote Originally Posted by EdsGoodStuff View Post
    [30-Nov-2012 21:41:11] PHP Warning: constant() [function.constant]: Couldn't find constant in /home/content/html/admin/includes/functions/admin_access.php on line 38

    I checked in /admin/includes/functions/admin_access.php and this is what it says on line 38:
    if (constant($result->fields['main_page']) == $page && $result->fields['page_params'] == $page_params) {
    Quote Originally Posted by EdsGoodStuff View Post
    Seem to have found a solution.

    I went to Admin Access Management> Admin Profiles and clicked on Edit for the Administrator User Profile. The BOX_HEADING_PRODUCT_TYPES category at the bottom of the page has four check-boxes of which three were checked by default- Product-Music, Document-General, and Document-Product. When I uncheck these boxes and update the profile I can log in as Administrator and not get any myDebug errors.
    Quote Originally Posted by lat9 View Post
    I've traced this down to the following conditions:
    1. The currently signed-in admin is not a superuser.
    2. The admin profile associated with that admin has one or more of the 'Product Types' enabled.

    For that set of conditions, the check_page function in admin_access.php is choking on the (non-existent) constant associated with the enabled Product Type. In that case, the main_page value returned for the enabled product type by the SQL query at line 29 of /ADMIN/includes/functions/admin_access.php is empty because there's no such key (e.g. _productTypes_product_music) to associate.

    With the changes in red, the debug logs no longer are created ... but I'm not sure if (a) it's an appropriate change and (b) if it's a complete change.
    Code:
      $sql = "SELECT ap.main_page, ap.page_params
              FROM " . TABLE_ADMIN . " a
              LEFT JOIN " . TABLE_ADMIN_PAGES_TO_PROFILES . " ap2p ON ap2p.profile_id = a.admin_profile
              LEFT JOIN " . TABLE_ADMIN_PAGES . " ap ON ap.page_key = ap2p.page_key
              WHERE admin_id = :adminId:";
      $sql = $db->bindVars($sql, ':adminId:', $_SESSION['admin_id'], 'integer');
      $result = $db->Execute($sql);
      $retVal = FALSE;
      while (!$result->EOF) {
    /// FIX: add the zen_not_null() check here
        $pageName = zen_not_null($result->fields['main_page']) ? constant($result->fields['main_page']) : '';
        if (($pageName == $page || basename($pageName, '.php') == $page) && $result->fields['page_params'] == $page_params) {
          $retVal = TRUE;
        }
        $result->MoveNext();
      }
    I also noticed during my "playing" with this that it's not possible to check 'Product Types', 'Product - Free Shipping' in an admin profile and have it remain checked after clicking the Update button.
    Quote Originally Posted by lat9 View Post
    The issue here is that the page_key value created in the admin_pages_to_profiles table (_productTypes_product_free_shipping) is 35 characters long and doesn't quite fit into the field that's defined as varchar(32).
    Quote Originally Posted by lat9 View Post
    A better solution is to improve the query to 'weed out' the erroneous selection in the first place:
    Code:
      $sql = "SELECT ap.main_page, ap.page_params
              FROM " . TABLE_ADMIN . " a
              LEFT JOIN " . TABLE_ADMIN_PAGES_TO_PROFILES . " ap2p ON ap2p.profile_id = a.admin_profile
              LEFT JOIN " . TABLE_ADMIN_PAGES . " ap ON ap.page_key = ap2p.page_key
              WHERE admin_id = :adminId:
               AND ap2p.page_key NOT LIKE '_productTypes_%'";
    /// FIX: added the AND line above
      $sql = $db->bindVars($sql, ':adminId:', $_SESSION['admin_id'], 'integer');
      $result = $db->Execute($sql);
      $retVal = FALSE;
      while (!$result->EOF) {
        $pageName = constant($result->fields['main_page']);
        if (($pageName == $page || basename($pageName, '.php') == $page) && $result->fields['page_params'] == $page_params) {
          $retVal = TRUE;
        }
        $result->MoveNext();
      }
    Moved to Bug Reports area for further investigation.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #16
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Re: myDEBUG-adm log files - question

    I just wanted to report that I experienced this bug as well. Mine is a heavily modified zen cart that has been updated from 1.3.8 to it's current 1.5.1. Some plugins that might have triggered this? Perhaps SSU or the fact that I had previously installed admin profiles, but then removed it once I upgraded to 1.5.1.

    Once I went in and set up profiles for everyone the error seemed to disappear and hasn't come back. So I'm just hoping it was temporary and ignoring it for now.

  7. #17
    Join Date
    Aug 2010
    Posts
    7
    Plugin Contributions
    0

    Default Re: myDEBUG-adm log files - question

    Same problem here in fresh install of 1.5.1 No mods or edits its stock u Get the following message: PHP Warning: constant(): Couldn't find constant in /..includes/functions/admin_access.php on line 38, referer: http://.../categories.php?cPath=11&c...=edit_category

    An 8mb error log file has been growing and growing because of this error. Is there a fix? I tried the above and i get an "Error please refresh this page" when trying to edit categories.

    The problem also does not occur on superuser profile. Only occurs on custom profiles.

  8. #18
    Join Date
    Sep 2005
    Posts
    460
    Plugin Contributions
    0

    Default Re: myDEBUG-adm log files - question

    I've got this issue with other than super user profiles AFTER installing Image Handler 4, but people in the IH thread concluded that it would not be an IH problem. So, the problem really persists and an administrator can't update the product info anymore due to this permission issue:
    http://www.zen-cart.com/showthread.p...36#post1189336

    The error log tells about the same CONSTANT issues than in this thread.
    I may be blond but at least I found Zen.

  9. #19
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: myDEBUG-adm log files - question

    Quote Originally Posted by lat9 View Post
    A better solution is to improve the query to 'weed out' the erroneous selection in the first place:
    Code:
      $sql = "SELECT ap.main_page, ap.page_params
              FROM " . TABLE_ADMIN . " a
              LEFT JOIN " . TABLE_ADMIN_PAGES_TO_PROFILES . " ap2p ON ap2p.profile_id = a.admin_profile
              LEFT JOIN " . TABLE_ADMIN_PAGES . " ap ON ap.page_key = ap2p.page_key
              WHERE admin_id = :adminId:
               AND ap2p.page_key NOT LIKE '_productTypes_%'";
      $sql = $db->bindVars($sql, ':adminId:', $_SESSION['admin_id'], 'integer');
      $result = $db->Execute($sql);
      $retVal = FALSE;
      while (!$result->EOF) {
        $pageName = constant($result->fields['main_page']);
        if (($pageName == $page || basename($pageName, '.php') == $page) && $result->fields['page_params'] == $page_params) {
          $retVal = TRUE;
        }
        $result->MoveNext();
      }
    I've been using this fix on a couple of my 1.5.1 installations since January 2013 and it appears to work well. Thanks lat9!
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 1
    Last Post: 2 Feb 2014, 04:45 PM
  2. Couldn't find constant MODULE_SHIPPING_ZONES_HANDLING_METHOD_1 in zones.php
    By NickyCarroll in forum Upgrading from 1.3.x to 1.3.9
    Replies: 2
    Last Post: 23 Feb 2011, 02:20 AM
  3. err: Warning: constant(): Couldn't find constant MODULE_SHIPPING_MZMT_GEOZONE_7_TEXT_
    By ginginca in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 6 Mar 2007, 07:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR