We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43124
    • 21 Posts
    Просмотрел лог ошибок сервера и обнаружил там следующее:
    *****.ru [Wed Aug 28 09:53:42 2013] [error] [client 217.66.158.62] PHP Warning:  in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/**/**********/*****/public_html/core/cache/includes/elements/modsnippet/11.include.cache.php on line 39, referer: http://***.*****.ru/


    Открыл файл 11.include.cache.php, нашел там ту саму строку 39

    <?php
    function elements_modsnippet_11($scriptProperties= array()) {
    global $modx;
    if (is_array($scriptProperties)) {
    extract($scriptProperties, EXTR_SKIP);
    }
    /**
     * FormIt
     *
     * Copyright 2009-2012 by Shaun McCormick <[email protected]>
     *
     * FormIt is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by the Free
     * Software Foundation; either version 2 of the License, or (at your option) any
     * later version.
     *
     * FormIt is distributed in the hope that it will be useful, but WITHOUT ANY
     * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License along with
     * FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
     * Suite 330, Boston, MA 02111-1307 USA
     *
     * @package formit
     */
    /**
     * Custom output filter that returns checked="checked" if the value is set
     *
     * @var string $input
     * @var string $options
     * @package formit
     */
    $output = ' ';
    if ($input == $options) {
        $output = ' selected="selected"';
    }
    $input = $modx->fromJSON($input);
    if (in_array($options,$input)) {
      $output = ' selected="selected"';
    }
    return $output;
    }


    Дело как понял касается formit, и не нравится $input
    Как исправить ошибку?
    Не могу понять что значит эта строка в логе
    [<a href='function.in-array'>function.in-array</a>]
      • 44874
      • 11 Posts
      Тебе просто надо проверять $input на то, действительно ли он является массивом. Например так:
      $input = $modx->fromJSON($input);
      if (is_array($input) && in_array($options,$input)) {
        $output = ' selected="selected"';
      }
      

      А строка в логе - это просто ссылка на документацию по этой функции - стандартное поведение php парсера. Просто, если бы эта строка вывелась в браузере - это была бы ссылка, но ошибки пишутся в лог - поэтому там просто html
        • 43124
        • 21 Posts
        Quote from: klermonte at Aug 28, 2013, 07:56 AM
        Тебе просто надо проверять $input на то, действительно ли он является массивом. Например так:
        $input = $modx->fromJSON($input);
        if (is_array($input) && in_array($options,$input)) {
          $output = ' selected="selected"';
        }
        

        спасибо, исправил, буду смотреть логи...