Skip to content

Commit

Permalink
Merge pull request #171 from geodesicsolutions-community/storefront-php8
Browse files Browse the repository at this point in the history
Fix SQL error showing at top of page on storefronts in PHP8
  • Loading branch information
jonyo authored Jun 10, 2022
2 parents 7abb71a + a356b06 commit 0d8d38e
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/addons/storefront/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class addon_storefront_pages extends addon_storefront_info
public function home()
{
$store_id = $this->storeID = $this->init();
$db = true;
include GEO_BASE_DIR . 'get_common_vars.php';
$db = DataAccess::getInstance();

$util = geoAddon::getUtil('storefront');

Expand Down Expand Up @@ -205,15 +204,15 @@ function processTraffic($store_id)
foreach ($days as $day => $tvisits) {
$uvisits = count($ips[$day]);
$sql = "INSERT INTO $tables->traffic SET
owner=?,
time=?,
owner=?,
time=?,
uvisits=?,
tvisits=?";
$r = $db->Execute($sql, array($store_id,$day,$uvisits,$tvisits));
}

$sql = "DELETE FROM $tables->traffic_cache
WHERE time < $currentDate AND
WHERE time < $currentDate AND
owner = " . $store_id;
$result = $db->Execute($sql);
if (!$result) {
Expand Down Expand Up @@ -384,8 +383,8 @@ private function _initView($store_id)
$view->storefront = $setting->toArray();
}

$sql = "SELECT * FROM $tables->user WHERE store_id=?";
$r = $db->Getrow($sql, $store_id);
$sql = "SELECT * FROM $tables->users WHERE store_id=?";
$r = $db->Getrow($sql, [$store_id]);

//figure out what storefront template to use
$user = geoUser::getUser($store_id);
Expand Down Expand Up @@ -630,9 +629,9 @@ public function list_stores()
//NOTE: pay attention to the join order here, as it needs to include "price plan free" users who haven't visited their storefront at all yet
//that is to say: LEFT JOIN the subscription tables at the end so that the rest of the query still operates for users where that table is missing a row
$sql = "SELECT DISTINCT r.region
FROM " . geoTables::userdata_table . " as user
FROM " . geoTables::userdata_table . " as user
INNER JOIN " . geoTables::user_regions . " as r ON user.id = r.user AND r.level = " . $stateLevel .
($price_plans_with_free_storefronts ? " LEFT JOIN " . geoTables::user_groups_price_plans_table . " as ugpp ON user.id = ugpp.id " : '') . "
($price_plans_with_free_storefronts ? " LEFT JOIN " . geoTables::user_groups_price_plans_table . " as ugpp ON user.id = ugpp.id " : '') . "
LEFT JOIN " . $table->subscriptions . " as sub ON user.id = sub.user_id
WHERE " .
($price_plans_with_free_storefronts ? "(sub.expiration > " . geoUtil::time() . " OR ugpp.`price_plan_id` in " . $in_statement . " OR ugpp.`auction_price_plan_id` in " . $in_statement . ")" : "sub.expiration > " . geoUtil::time()) .
Expand Down Expand Up @@ -732,7 +731,6 @@ public function list_stores()

$css = "";
$tpl_vars['pagination'] = geoPagination::getHTML($totalPages, $page_num, $link, $css);
$body .= $tpl_vars['pagination'];
}
geoView::getInstance()->setBodyTpl('list_all_stores.tpl', 'storefront')
->setBodyVar($tpl_vars);
Expand Down

0 comments on commit 0d8d38e

Please sign in to comment.