Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Additional Images: Pregnant match, unknown modifier on Line 47

    [zc154, running Responsive Sheffield Blue template]

    Hi,

    I'm getting a huge number of log files complaining about a pregnant match:
    [06-Apr-2017 10:35:37 America/New_York] PHP Warning: preg_match(): Unknown modifier 'T' in /public_html/includes/modules/responsive_sheffield_blue/additional_images.php on line 47

    Here is the passage where the preg match occurs (I have bolded out line 47):
    // Check for additional matching images
    $file_extension = $products_image_extension;
    $products_image_match_array = array();
    if ($dir = @dir($products_image_directory)) {
    while ($file = $dir->read()) {
    if (!is_dir($products_image_directory . $file)) {
    if (substr($file, strrpos($file, '.')) == $file_extension) {
    if(preg_match('/\Q' . $products_image_base . '\E/i', $file) == 1) {
    if ($file != $products_image) {
    if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {
    // echo 'I AM A MATCH ' . $file . '<br>';
    $images_array[] = $file;
    } else {
    // echo 'I AM NOT A MATCH ' . $file . '<br>';
    }
    }
    }
    }
    }
    }
    if (sizeof($images_array)) {
    sort($images_array);
    }
    $dir->close();
    }
    }

    I think this is either a Zen Lightbox or Image Handler issue. Or maybe a Tabbed Product Pro issue? I dunno.

    Any thoughts on how to fix this?

    Thanks,
    Mike

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Any indication of what images are possibly involved? What filenames are being used? IH4 doesn't appear to modify anything at or before that point for basic image display/data collection.

    The current code at that line doesn't appear to have anything in it that would result in that message other than what is introduced in: $products_image_base. That appears to be generated from the main image's name in a default install and it appears that there is something in the filename (even if it is some hidden character) that is being interpreted and a problem.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Yes. Since the '/' is your delimiter in the preg_match call, if you have a '/' in the filename passed, then it's gonna complain.

    "Unknown modifier T" means your $products_image_base contains "/T" in it.
    .

    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.

  4. #4
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Thank you for the input, sorry for the delayed response. I got sidetracked but I'm back on it.

    Whatever this is, it's triggering a massively prolific error logs. Numerous times a time, often the individual log files are huge (601kb).

    Are you guys saying that this problem may exist inside the database itself? Like, the name of an image that has been inserted into a table?

  5. #5
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Quote Originally Posted by Feznizzle View Post
    Thank you for the input, sorry for the delayed response. I got sidetracked but I'm back on it.

    Whatever this is, it's triggering a massively prolific error logs. Numerous times a time, often the individual log files are huge (601kb).

    Are you guys saying that this problem may exist inside the database itself? Like, the name of an image that has been inserted into a table?
    Yup, that's what we're saying, though DrB knew more about the actual content that is causing the issue, "/T" which would be related to the filename. That said, a "better" fix than tryng to find/change the filename is to change the regex delimiter to something not permitted (or not likely to exist) in a filename/folder structure but still would work for regex.

    That would involve editing the if preg_match line.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Since '/' is being used as the delimiter,
    Code:
    if(preg_match('/\Q' . $products_image_base . '\E/i', $file) == 1) {
    would be better written as:
    Code:
    if(preg_match('/\Q' . preg_quote($products_image_base, '/') . '\E/i', $file) == 1) {
    .

    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.

  7. #7
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Thanks, DrByte. I'll give that a go...

  8. #8
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    I am unable to trigger an error, but I'm not sure that means the issue has cleared up. I was unable to trigger it myself, even before the fix I just applied.

    Man, I wish the error log would provide the url where the problem occured, not just what file and what line of the file triggered the error.

    I have cleaned out the log folder, will watch it for future occurrences.

    On a weird note, I'm become paranoid that some nefarious is afoot. I swear site traffic is getting hijacked or something! And this problem... it seemed to solve itself this morning!

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,489
    Plugin Contributions
    88

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Quote Originally Posted by Feznizzle View Post
    I am unable to trigger an error, but I'm not sure that means the issue has cleared up. I was unable to trigger it myself, even before the fix I just applied.

    Man, I wish the error log would provide the url where the problem occured, not just what file and what line of the file triggered the error.

    I have cleaned out the log folder, will watch it for future occurrences.

    On a weird note, I'm become paranoid that some nefarious is afoot. I swear site traffic is getting hijacked or something! And this problem... it seemed to solve itself this morning!
    Since you're using Zen Cart 1.5.4, you could install the myDEBUG Backtrace plugin, which has been incorporated into the ZC 1.5.5+ code base.

  10. #10
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Additional Images: Pregnant match, unknown modifier on Line 47

    Sweeeeet! Thank you so much! I will install that right away!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. preg_match(): Unknown modifier '0' ???
    By AnglersCorner in forum Upgrading to 1.5.x
    Replies: 5
    Last Post: 1 Jun 2015, 12:36 PM
  2. v139h Error: Unknown modifier '$' in main_product_image.php
    By divinelighting in forum General Questions
    Replies: 12
    Last Post: 27 Sep 2012, 10:26 AM
  3. Replies: 5
    Last Post: 15 Sep 2011, 03:16 PM
  4. Replies: 2
    Last Post: 3 May 2010, 08:39 PM
  5. preg_match() Unknown modifier 'a' warning in Admin Additiona Images addon
    By dlamar in forum All Other Contributions/Addons
    Replies: 6
    Last Post: 26 Mar 2010, 03:20 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