За последние 24 часа нас посетили 20988 программистов и 1502 робота. Сейчас ищут 688 программистов ...

Ошибка "preg_match():" на J3/php7

Тема в разделе "PHP для новичков", создана пользователем Bascrib, 19 окт 2016.

Метки:
  1. Bascrib

    Bascrib Новичок

    С нами с:
    19 окт 2016
    Сообщения:
    4
    Симпатии:
    0
    Здравствуйте, у меня сайт на joomla 3 / php 7
    выскочила вот такая ошибка в футере
    Warning: preg_match(): Unknown modifier 'z' in plugins/system/cache/cache.php on line 162

    строка 164:

    if (preg_match('/' . $exclusion . 'is', $path, $match))

    помогите исправить такую ошибку...

    файл cache.php целиком:

    PHP:
    1. <?php
    2. /**
    3. * @package     Joomla.Plugin
    4. * @subpackage  System.cache
    5. *
    6. * @copyright   Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
    7. * @license     GNU General Public License version 2 or later; see LICENSE.txt
    8. */
    9.  
    10. defined('_JEXEC') or die;
    11.  
    12. /**
    13. * Joomla! Page Cache Plugin.
    14. *
    15. * @since  1.5
    16. */
    17. class PlgSystemCache extends JPlugin
    18. {
    19.     var $_cache = null;
    20.  
    21.     var $_cache_key = null;
    22.  
    23.     /**
    24.      * Constructor.
    25.      *
    26.      * @param   object  &$subject  The object to observe.
    27.      * @param   array   $config    An optional associative array of configuration settings.
    28.      *
    29.      * @since   1.5
    30.      */
    31.     public function __construct(& $subject, $config)
    32.     {
    33.         parent::__construct($subject, $config);
    34.  
    35.         // Set the language in the class.
    36.         $options = array(
    37.             'defaultgroup' => 'page',
    38.             'browsercache' => $this->params->get('browsercache', false),
    39.             'caching'      => false,
    40.         );
    41.  
    42.         $this->_cache     = JCache::getInstance('page', $options);
    43.         $this->_cache_key = JUri::getInstance()->toString();
    44.     }
    45.  
    46.     /**
    47.      * Converting the site URL to fit to the HTTP request.
    48.      *
    49.      * @return  void
    50.      *
    51.      * @since   1.5
    52.      */
    53.     public function onAfterInitialise()
    54.     {
    55.         global $_PROFILER;
    56.  
    57.         $app  = JFactory::getApplication();
    58.         $user = JFactory::getUser();
    59.  
    60.         if ($app->isAdmin())
    61.         {
    62.             return;
    63.         }
    64.  
    65.         if (count($app->getMessageQueue()))
    66.         {
    67.             return;
    68.         }
    69.  
    70.         if ($user->get('guest') && $app->input->getMethod() == 'GET')
    71.         {
    72.             $this->_cache->setCaching(true);
    73.         }
    74.  
    75.         $data = $this->_cache->get($this->_cache_key);
    76.  
    77.         if ($data !== false)
    78.         {
    79.             // Set cached body.
    80.             $app->setBody($data);
    81.  
    82.             echo $app->toString();
    83.  
    84.             if (JDEBUG)
    85.             {
    86.                 $_PROFILER->mark('afterCache');
    87.             }
    88.  
    89.             $app->close();
    90.         }
    91.     }
    92.  
    93.     /**
    94.      * After render.
    95.      *
    96.      * @return   void
    97.      *
    98.      * @since   1.5
    99.      */
    100.     public function onAfterRespond()
    101.     {
    102.         $app = JFactory::getApplication();
    103.  
    104.         if ($app->isAdmin())
    105.         {
    106.             return;
    107.         }
    108.  
    109.         if (count($app->getMessageQueue()))
    110.         {
    111.             return;
    112.         }
    113.  
    114.         $user = JFactory::getUser();
    115.  
    116.         if ($user->get('guest') && !$this->isExcluded())
    117.         {
    118.             // We need to check again here, because auto-login plugins have not been fired before the first aid check.
    119.             $this->_cache->store(null, $this->_cache_key);
    120.         }
    121.     }
    122.  
    123.     /**
    124.      * Check if the page is excluded from the cache or not.
    125.      *
    126.      * @return   boolean  True if the page is excluded else false
    127.      *
    128.      * @since    3.5
    129.      */
    130.     protected function isExcluded()
    131.     {
    132.         // Check if menu items have been excluded
    133.         if ($exclusions = $this->params->get('exclude_menu_items', array()))
    134.         {
    135.             // Get the current menu item
    136.             $active = JFactory::getApplication()->getMenu()->getActive();
    137.  
    138.             if ($active && $active->id && in_array($active->id, (array) $exclusions))
    139.             {
    140.                 return true;
    141.             }
    142.         }
    143.  
    144.         // Check if regular expressions are being used
    145.         if ($exclusions = $this->params->get('exclude', ''))
    146.         {
    147.             // Normalize line endings
    148.             $exclusions = str_replace(array("\r\n", "\r"), "\n", $exclusions);
    149.  
    150.             // Split them
    151.             $exclusions = explode("\n", $exclusions);
    152.  
    153.             // Get current path to match against
    154.             $path = JUri::getInstance()->toString(array('path', 'query', 'fragment'));
    155.  
    156.             // Loop through each pattern
    157.             if ($exclusions)
    158.             {
    159.                 foreach ($exclusions as $exclusion)
    160.                 {
    161.                     // Make sure the exclusion has some content
    162.                     if (strlen($exclusion))
    163.                     {
    164.                         if (preg_match('/' . $exclusion . 'is', $path, $match))
    165.                         {
    166.                             return true;
    167.                         }
    168.                     }
    169.                 }
    170.             }
    171.         }
    172.  
    173.         return false;
    174.     }
    175. }
     
  2. denis01

    denis01 Суперстар
    Команда форума Модератор

    С нами с:
    9 дек 2014
    Сообщения:
    12.230
    Симпатии:
    1.715
    Адрес:
    Молдова, г.Кишинёв
    @Bascrib с какими аргументами preg_match вызывают?
     
    Bascrib нравится это.
  3. Васяня

    Васяня Активный пользователь

    С нами с:
    2 окт 2016
    Сообщения:
    238
    Симпатии:
    32
    Адрес:
    Россия, Приморский край, г. Находка.
    Что такое $exclusion? Походу там есть слэши, если это текст надо экранировать символы регулярных выражений, для этого есть функция preg_quote. И ты ещё забыл закрывающий слэш в конце регулярки перед 'is'.
     
    Bascrib нравится это.
  4. Bascrib

    Bascrib Новичок

    С нами с:
    19 окт 2016
    Сообщения:
    4
    Симпатии:
    0
    напишите пожалуйста, куда именно поставить закрывающий слеш...
    если можно прямо строку правильно, у меня не хватает знаний..
     
  5. Васяня

    Васяня Активный пользователь

    С нами с:
    2 окт 2016
    Сообщения:
    238
    Симпатии:
    32
    Адрес:
    Россия, Приморский край, г. Находка.
    Код (PHP):
    1. preg_match('/'.preg_quote($exclusion).'/is',$path,$match)
    Пробуй
    --- Добавлено ---
    Это нужно поставить в 164 строку
     
    Bascrib нравится это.
  6. Bascrib

    Bascrib Новичок

    С нами с:
    19 окт 2016
    Сообщения:
    4
    Симпатии:
    0