@viktorross

Постоянное предупреждение после того как переделали скрипт, почему?

помогите пожалуйста решить проблему, постоянно появляется в логе тысячи одних и тех же предупреждений после переделки скрипта, посмотрите пожалуйста кто-нибудь что не так, вероятно из-за этого не работает еще что-то на сайте

сам смотрел что и как исправить не понятно

[Sun Aug 04 00:05:45 2019] [warn] [client 141.8.142.99] mod_fcgid: stderr: PHP Notice:  Undefined variable: join_users in /var/www/site/data/www/site.ru/classes/listings.php on line 1216
[Sun Aug 04 00:05:45 2019] [warn] [client 141.8.142.99] mod_fcgid: stderr: PHP Notice:  Undefined variable: join_ext in /var/www/site/data/www/site.ru/classes/site.php on line 1216
[Sun Aug 04 00:05:45 2019] [warn] [client 141.8.142.99] mod_fcgid: stderr: PHP Notice:  Undefined variable: join_options in /var/www/site/data/www/site.ru/classes/listings.php on line 1216
[Sun Aug 04 00:05:45 2019] [warn] [client 141.8.142.99] mod_fcgid: stderr: PHP Notice:  Undefined variable: join_pe in /var/www/site/data/www/site.ru/classes/listings.php on line 1217


вот эта часть

do_action("search_listing_query", array(&$where));
		
		// count(*) faster than count(val) **********
		$sql = "select count($count) 
		from ".TABLE_ADS."
		$join_pictures $join_users $join_ext $join_options $join_pe
		$q_join
		".$where.$locations_str;
		//echo $sql;
		$no_ads = $db->fetchRow($sql);

		return $no_ads;
	}


вот старая версия

public function getNoShortListings($where, $q_join = "", $noloc = 0)
    {
        global $db;
        global $settings;
        $join_pictures = "";
        $count = "*";
        if (strstr($where, TABLE_ADS_PICTURES)) {
            $join_pictures = "left join " . TABLE_ADS_PICTURES . " on " . TABLE_ADS . ".id=" . TABLE_ADS_PICTURES . ".ad_id ";
            $count = "DISTINCT " . TABLE_ADS . ".id";
        }
        $join_users = "";
        if (strstr($where, TABLE_USERS)) {
            $join_users = "left join " . TABLE_USERS . " on " . TABLE_ADS . ".user_id=" . TABLE_USERS . ".id ";
        }
        $join_ext = "";
        if (strstr($where, TABLE_ADS_EXTENSION)) {
            $join_ext = " left join " . TABLE_ADS_EXTENSION . " on " . TABLE_ADS . ".id = " . TABLE_ADS_EXTENSION . ".`id` ";
        }
        $join_options = "";
        if (strstr($where, TABLE_OPTIONS)) {
            $join_options = " left join " . TABLE_OPTIONS . " on " . TABLE_ADS . ".`id` = " . TABLE_OPTIONS . ".`object_id` and `option` like 'video' ";
        }
        $join_cat = "";
        if (strstr($where, TABLE_CATEGORIES)) {
            $join_users = "left join " . TABLE_CATEGORIES . "_lang on " . TABLE_ADS . ".category_id=" . TABLE_CATEGORIES . "_lang.id ";
        }
        $join_pe = "";
        if (strstr($where, TABLE_PENDING_EDITED)) {
            $join_pe = " left join " . TABLE_PENDING_EDITED . " on " . TABLE_ADS . ".id = " . TABLE_PENDING_EDITED . ".`ad_id` ";
        }
        $locations_str = "";
        global $admin_side;
        if (!$noloc && $settings["enable_locations"] && !isset($admin_side)) {
            $locations_str = locations::makeQueryStr();
            if (!$where) {
                $locations_str = " where " . substr($locations_str, 4);
            }
        }
        do_action("search_listing_query", array($where));
        $sql = "select count(" . $count . ") \n\t\tfrom " . TABLE_ADS . "\n\t\t" . $join_pictures . " " . $join_users . " " . $join_ext . " " . $join_options . " " . $join_pe . "\n\t\t" . $q_join . "\n\t\t" . $where . $locations_str;
        $no_ads = $db->fetchRow($sql);
        return $no_ads;
    }


но естественно при возврате старой версии появляется куча фатальных ошибок

как я вижу из первой версии с ошибкой определено только 2

do_action("search_listing_query", array(&$where));
do_action("search_listing_order", array(&$order_by, &$order_way));

if(!$where) $where=" where 1 ";

$join_pictures = '';
if(strstr($where, TABLE_ADS_PICTURES))
$join_pictures = "inner join ".TABLE_ADS_PICTURES." on ".TABLE_ADS.".id=".TABLE_ADS_PICTURES.".ad_id ";

$join_users = '';
if(strstr($where, TABLE_USERS))
$join_users = "inner join ".TABLE_USERS." on ".TABLE_ADS.".user_id=".TABLE_USERS.".id ";

куда смотреть?
  • Вопрос задан
  • 75 просмотров
Решения вопроса 1
glaphire
@glaphire Куратор тега PHP
PHP developer
Очень запутанный код. Напиши полную версию ф-и getNoShortListings до и после. Вряд ли где-то эти переменные сбрасываются неявно, может ты забыл их правильно проинициализировать до вызова do_action после рефакторинга?
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы