Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for PHP 8.2 and M2 2.4.6 #122

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Controller/Adminhtml/Config/Sftp/TestConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
*/
class TestConnection extends Action
{

public $sftp;
public $storeManager;
public $configProvider;
public $resultJsonFactory;
public $tagFilter;

/**
* TestConnection constructor.
*
Expand Down Expand Up @@ -88,10 +93,10 @@ public function execute()


/**
* @var \Magento\Framework\Controller\Result\Json $resultJson
* @var \Magento\Framework\Controller\Result\Json $resultJson
*/
$resultJson = $this->resultJsonFactory->create();
return $resultJson->setData($result);
}

}
}
2 changes: 1 addition & 1 deletion Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public function addRecord(int $level, string $message, array $context = [], Date
print_r($message."\n");
}

return parent::addRecord($level, $message, $context);
return parent::addRecord($level, $message, $context, $datetime);
}
}
26 changes: 25 additions & 1 deletion Model/BVSEOSDK/BV.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@
*/
class BV
{
public $config;
/**
* @var \Bazaarvoice\Connector\Model\BVSEOSDK\Reviews
*/
public $reviews;
/**
* @var \Bazaarvoice\Connector\Model\BVSEOSDK\Questions
*/
public $questions;
/**
* @var \Bazaarvoice\Connector\Model\BVSEOSDK\Stories
*/
public $stories;
/**
* @var \Bazaarvoice\Connector\Model\BVSEOSDK\Spotlights
*/
public $spotlights;
/**
* @var \Bazaarvoice\Connector\Model\BVSEOSDK\SellerRatings
*/
public $sellerratings;
/**
* @var \Bazaarvoice\Connector\Model\BVSEOSDK\SellerRatings|\Bazaarvoice\Connector\Model\BVSEOSDK\Reviews|\Bazaarvoice\Connector\Model\BVSEOSDK\Questions|\Bazaarvoice\Connector\Model\BVSEOSDK\Stories|\Bazaarvoice\Connector\Model\BVSEOSDK\Spotlights
*/
public $SEO;

/**
* BV Class Constructor
Expand Down Expand Up @@ -196,4 +221,3 @@ protected function validateParameters($params)
}
}
}

6 changes: 4 additions & 2 deletions Model/BVSEOSDK/BVFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ public function buildSDKDebugFooter()
$footer .= "\n".' <li data-bvseo="bv.root.folder">'.$this->base->config['bv_root_folder'].'</li>';
$footer .= "\n".' <li data-bvseo="seo.sdk.charset">'.$this->base->config['charset'].'</li>';
$footer .= "\n".' <li data-bvseo="seo.sdk.ssl.enabled">'.$ssl_enabled.'</li>';
$footer .= "\n".' <li data-bvseo="crawlerAgentPattern">'.$this->base->config['crawler_agent_pattern'].'</li>';
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$crawlerAgentPattern = $this->base->config['crawler_agent_pattern'] ?? '';
$footer .= "\n".' <li data-bvseo="crawlerAgentPattern">'.$crawlerAgentPattern.'</li>';
$footer .= "\n".' <li data-bvseo="subjectID">'.urlencode($subject_id).'</li>';


$footer .= "\n".' <li data-bvseo="en">'.$sdk_enabled.'</li>';
$footer .= "\n".' <li data-bvseo="pn">bvseo-'.$this->base->config['page'].'</li>';
$footer .= "\n".' <li data-bvseo="userAgent">'.$_SERVER['HTTP_USER_AGENT'].'</li>';
$footer .= "\n".' <li data-bvseo="userAgent">'.$userAgent.'</li>';
$footer .= "\n".' <li data-bvseo="pageURI">'.$this->base->config['page_url'].'</li>';
$footer .= "\n".' <li data-bvseo="baseURI">'.$this->base->config['base_url'].'</li>';
$footer .= "\n".' <li data-bvseo="contentType">'.$content_type.'</li>';
Expand Down
22 changes: 21 additions & 1 deletion Model/BVSEOSDK/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
*/
class Base
{

public $config;
/**
* @var array<string, mixed>|array<string, string>
*/
public $bv_config;
public $seo_url;
/**
* @var float|string
*/
public $start_time;
/**
* @var float
*/
public $response_time;
private $msg = '';

public function __construct($params = array())
Expand Down Expand Up @@ -45,7 +60,8 @@ public function __construct($params = array())
: $this->config['execution_timeout'];

// set up combined user agent to be passed to cloud storage (if needed)
$this->config['user_agent'] = "bv_php_sdk/3.2.1;".$_SERVER['HTTP_USER_AGENT'];
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$this->config['user_agent'] = "bv_php_sdk/3.2.1;".$userAgent;
}

protected function validateParams($params)
Expand Down Expand Up @@ -287,6 +303,10 @@ private function _isBot()
return true;
}

if (!isset($this->config['crawler_agent_pattern']) || !isset($_SERVER['HTTP_USER_AGENT'])) {
return true;
}

// search the user agent string for an indication if this is a search bot or not
return mb_eregi('('.$this->config['crawler_agent_pattern'].')', $_SERVER['HTTP_USER_AGENT']);
}
Expand Down
4 changes: 4 additions & 0 deletions Model/BVSEOSDK/Questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
class Questions extends Base
{
/**
* @var array<string, string>|array<string, mixed>
*/
public $config;

function __construct($params = array())
{
Expand Down
4 changes: 4 additions & 0 deletions Model/BVSEOSDK/Reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
class Reviews extends Base
{
/**
* @var array<string, string>|array<string, mixed>
*/
public $config;

function __construct($params = array())
{
Expand Down
4 changes: 4 additions & 0 deletions Model/BVSEOSDK/SellerRatings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

class SellerRatings extends Base
{
/**
* @var array<string, string>
*/
public $config;

function __construct($params = array())
{
Expand Down
4 changes: 4 additions & 0 deletions Model/BVSEOSDK/Spotlights.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

class Spotlights extends Base
{
/**
* @var array<string, string>
*/
public $config;

function __construct($params = array())
{
Expand Down
4 changes: 4 additions & 0 deletions Model/BVSEOSDK/Stories.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
class Stories extends Base
{
/**
* @var array<string, string>|array<string, mixed>
*/
public $config;

function __construct($params = array())
{
Expand Down
7 changes: 7 additions & 0 deletions Model/Indexer/Eav.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@

class Eav implements IndexerActionInterface, MviewActionInterface
{
/**
* @var \Magento\Catalog\Helper\Image
*/
public $imageHelper;
public $assetRepository;
public $design;
public $theme;
/**
* @var \Bazaarvoice\Connector\Logger\Logger
*/
Expand Down
17 changes: 8 additions & 9 deletions Model/XMLWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class XMLWriter extends \XMLWriter
* @param null $content
* @param bool $cdata
*
* @return bool|void
* @return bool
*/
public function writeElement($name, $content = null, $cdata = false): bool
{
Expand All @@ -31,26 +31,25 @@ public function writeElement($name, $content = null, $cdata = false): bool
$this->endElement();
return true;
} else {
parent::writeElement($name, $content);
return true;
return parent::writeElement($name, $content);
}
return false;
}

/**
* @param null $content
* @param bool $cdata
*
* @return bool|void
* @return bool
*/
public function writeRaw($content = null, $cdata = false): bool
{
$content = trim((string)$content);
if ($cdata) {
$this->writeCdata($content);
return true;
return $this->writeCdata($content);
} else {
parent::writeRaw($content);
return true;
return parent::writeRaw($content);
}
return false;
}
}
}
1 change: 1 addition & 0 deletions Setup/Patch/Data/UpgradeBvDataAtttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

class UpgradeBvDataAtttribute implements DataPatchInterface, PatchRevertableInterface
{
public $salesSetupFactory;
const MODULE_NAME = 'Bazaarvoice_Connector';
/**
* @var ModuleDataSetupInterface
Expand Down
4 changes: 2 additions & 2 deletions ViewModel/Pixel.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ public function getOrderDetails()
$this->orderDetails['tax'] = number_format((float)$order->getTaxAmount() ?? 0.0, 2, '.', '');
$this->orderDetails['shipping'] = number_format((float)$order->getShippingAmount() ?? 0.0, 2, '.', '');
if (!$this->taxConfig->discountTax()) {
$this->orderDetails['discount'] = number_format(abs((float)$order->getDiscountAmount()) ?? 0.0, 2, '.', '');
$this->orderDetails['discount'] = number_format((float)abs((float)$order->getDiscountAmount()) ?? 0.0, 2, '.', '');
} else {
//when discount is applied to products "including tax" - extract tax compensation amount from "discount".  
$this->orderDetails['discount'] = number_format(
abs((float)$order->getDiscountAmount()) - abs((float)$order->getDiscountTaxCompensationAmount()) ?? 0.0, 2, '.', '' );
(float)abs((float)$order->getDiscountAmount()) - (float)abs((float)$order->getDiscountTaxCompensationAmount()) ?? 0.0, 2, '.', '' );
}

if ($address) {
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}
},
"require": {
"php": "~7.0||~8.1.0||~8.2.0" ,"magento/framework": "~100.1|~101.0|~102.0|~103.0|~104.0"
"php": "~7.0||~8.1.0||~8.2.0||~8.3.0" ,
"magento/framework": "*"
}
}