Changeset 26592 for extensions/community


Ignore:
Timestamp:
Jan 9, 2014, 10:26:21 PM (10 years ago)
Author:
plg
Message:

bug fixed: version_compare can't compare 2.5.c and 2.5.d. mistic has written a
new function safe_version_compare which correctly handles letters in version
numbers.

Location:
extensions/community
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/include/functions_community.inc.php

    r23085 r26592  
    396396  return pwg_db_fetch_assoc(pwg_query($query));
    397397}
     398
     399// will be included in Piwigo 2.6
     400if (!function_exists('safe_version_compare'))
     401{
     402  function safe_version_compare($a, $b, $cmp=null)
     403  {
     404    $replace_chars = create_function('$m', 'return ord(strtolower($m[1]));');
     405    $a = preg_replace('#([0-9]+)([a-z]+)#i', '$1.$2', $a);
     406    $b = preg_replace('#([0-9]+)([a-z]+)#i', '$1.$2', $b);
     407    $a = preg_replace_callback('#\b([a-z]{1})\b#i', $replace_chars, $a);
     408    $b = preg_replace_callback('#\b([a-z]{1})\b#i', $replace_chars, $b);
     409    if (empty($cmp))
     410    {
     411      return version_compare($a, $b);
     412    }
     413    else
     414    {
     415      return version_compare($a, $b, $cmp);
     416    }
     417  }
     418}
    398419?>
  • extensions/community/main.inc.php

    r26559 r26592  
    4444    COMMUNITY_VERSION == 'auto' or
    4545    $pwg_loaded_plugins[COMMUNITY_ID]['version'] == 'auto' or
    46     version_compare($pwg_loaded_plugins[COMMUNITY_ID]['version'], COMMUNITY_VERSION, '<')
     46    safe_version_compare($pwg_loaded_plugins[COMMUNITY_ID]['version'], COMMUNITY_VERSION, '<')
    4747  )
    4848  {
Note: See TracChangeset for help on using the changeset viewer.