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

PHP 8.1 compatiblity & Magento 2 tables update (utilities) #108

Open
wants to merge 5 commits into
base: magento2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions magmi/engines/magmi_productimportengine.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,11 @@ public function getMode()
*/
public function addExtraAttribute($attr)
{
$attinfo = $this->attrinfo[$attr];
$this->_extra_attrs[$attinfo["backend_type"]]["data"][] = $attinfo;
if(isset($this->attrinfo[$attr]))
{
$attinfo = $this->attrinfo[$attr];
$this->_extra_attrs[$attinfo["backend_type"]]["data"][] = $attinfo;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion magmi/inc/magmi_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getLastSaved($fmt = "r")

public function load($name = null)
{
if (!isset($this->_props)) {
if (!isset($this->_props) || empty($this->_props)) {
if ($name == null) {
$name = $this->inifile;
}
Expand Down
3 changes: 2 additions & 1 deletion magmi/inc/remotefilegetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public function getRemoteFile($url, $dest, $authmode = null, $cookies = null)
$context = $this->createContext($url);
$ch = $context['curlhandle'];
$dl_opts = $context['opts']['dl'];

$dest = str_replace("pub/pub", "pub", $dest);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change for?

$outname = $dest;

if ($cookies) {
Expand All @@ -279,7 +281,6 @@ public function getRemoteFile($url, $dest, $authmode = null, $cookies = null)
$this->setURLOptions($url, $dl_opts);
$this->setAuthOptions($context, $dl_opts);


// Download the file , force expect to nothing to avoid buffer save problem
curl_setopt_array($ch, $dl_opts);
$inf = curl_getinfo($ch);
Expand Down
4 changes: 2 additions & 2 deletions magmi/plugins/base/general/reindex/options_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
href="#REINDEX:config" onclick="fcheck(0)">None</a>
<ul>
<?php
$idxarr = explode(",", $this->_plugin->getIndexList());
$indexes = explode(",", $this->getParam("REINDEX:indexes"));
$idxarr = explode(",", $this->_plugin->getIndexList() ?? '');
$indexes = explode(",", $this->getParam("REINDEX:indexes") ?? '');
foreach ($idxarr as $indexname) {
?>
<li><input type="checkbox" name="<?php echo $indexname?>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function initialize($params)
$this->magdir = Magmi_Config::getInstance()->getMagentoDir();
$this->_mdh = MagentoDirHandlerFactory::getInstance()->getHandler($this->magdir);
$this->_mdh->setRemoteGetterId("image");

// remote root
if ($this->getParam("IMG:remoteroot", "")) {
if ($this->getParam("IMG:remoteauth", false) == true) {
Expand Down Expand Up @@ -482,13 +483,19 @@ public function copyImageFile($imgfile, &$item, $extra)
// magento image value (relative to media catalog)
$impath = "/$i1/$i2/$bimgfile";
// target directory;
$l2d = "pub/media/catalog/product/$i1/$i2";

if(!strstr(getcwd(), "pub"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add brackets around "if" body and
"else" body

$l2d = "pub/media/catalog/product/$i1/$i2";
else
$l2d = "media/catalog/product/$i1/$i2";
// test for existence
$targetpath = "$l2d/$bimgfile";

/* test for same image (without problem) */
if ($impath == $this->_lastimage) {
return $impath;
}

/* test if imagefile comes from export */
if (!$this->_mdh->file_exists($targetpath) || $this->getParam("IMG:writemode") == "override") {
// if we already had problems with this target,assume we'll get others.
Expand Down
2 changes: 1 addition & 1 deletion magmi/plugins/inc/magmi_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function setParam($pname, $value)

public function fixListParam($pvalue)
{
$iarr = explode(",", $pvalue);
$iarr = explode(",", $pvalue ?? '');
$oarr = array();
foreach ($iarr as $v) {
if ($v != "") {
Expand Down
4 changes: 2 additions & 2 deletions magmi/plugins/utilities/clearcustomers/clearcustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public function runUtility()
$tables = array("customer_address_entity","customer_address_entity_datetime","customer_address_entity_decimal",
"customer_address_entity_int","customer_address_entity_text","customer_address_entity_varchar",
"customer_entity","customer_entity_datetime","customer_entity_decimal","customer_entity_int",
"customer_entity_text","customer_entity_varchar","tag","tag_properties","tag_relation","wishlist",
"wishlist_item","wishlist_item_option","log_customer");
"customer_entity_text","customer_entity_varchar","wishlist",
"wishlist_item","wishlist_item_option","customer_log");

foreach ($tables as $table) {
$this->exec_stmt("TRUNCATE TABLE `" . $this->tablename($table) . "`");
Expand Down
49 changes: 35 additions & 14 deletions magmi/plugins/utilities/clearproducts/clearproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,39 @@ public function runUtility()
{
$sql = "SET FOREIGN_KEY_CHECKS = 0";
$this->exec_stmt($sql);
$tables = array("catalog_product_bundle_option","catalog_product_bundle_option_value",
"catalog_product_bundle_selection","catalog_product_entity_datetime","catalog_product_entity_decimal",
"catalog_product_entity_gallery","catalog_product_entity_int","catalog_product_entity_media_gallery",
"catalog_product_entity_media_gallery_value","catalog_product_entity_text",
"catalog_product_entity_tier_price","catalog_product_entity_varchar","catalog_product_entity",
"catalog_product_option","catalog_product_option_price","catalog_product_option_title",
"catalog_product_option_type_price","catalog_product_option_type_title","catalog_product_option_type_value",
"catalog_product_super_attribute_label","catalog_product_super_attribute_pricing",
"catalog_product_super_attribute","catalog_product_super_link","catalog_product_link",
"catalog_product_link_attribute_varchar","catalog_product_link_attribute_int",
"catalog_product_entity_group_price",

"catalog_product_relation","catalog_product_enabled_index","catalog_product_website",
$tables = array("catalog_product_bundle_option",
"catalog_product_bundle_option_value",
"catalog_product_bundle_selection",
"catalog_product_entity_datetime",
"catalog_product_entity_decimal",
"catalog_product_entity_int",
"catalog_product_entity_gallery",
"catalog_product_entity_media_gallery",
"catalog_product_entity_media_gallery_value",
"catalog_product_entity_media_gallery_value_to_entity",
"catalog_product_entity_media_gallery_value_video",
"catalog_product_entity_text",
"catalog_product_entity_tier_price",
"catalog_product_entity_varchar",
"catalog_product_entity",
"catalog_product_option",
"catalog_product_option_price",
"catalog_product_option_title",
"catalog_product_option_type_price",
"catalog_product_option_type_title",
"catalog_product_option_type_value",
"catalog_product_super_attribute_label",
//"catalog_product_super_attribute_pricing",
"catalog_product_super_attribute",
"catalog_product_super_link",
"catalog_product_link",
"catalog_product_link_attribute_varchar",
"catalog_product_link_attribute_int",
//"catalog_product_entity_group_price",

"catalog_product_relation",
//"catalog_product_enabled_index",
"catalog_product_website",
"catalog_category_product_index","catalog_category_product","cataloginventory_stock_item",
"cataloginventory_stock_status");

Expand All @@ -38,7 +58,8 @@ public function runUtility()
}

//clean url rewrites for products
$sql = "DELETE FROM ".$this->tablename("core_url_rewrite")." WHERE product_id IS NOT NULL AND is_system=1";
//$sql = "DELETE FROM ".$this->tablename("core_url_rewrite")." WHERE product_id IS NOT NULL AND is_system=1";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the comment

$sql = "DELETE FROM ".$this->tablename("url_rewrite")." WHERE entity_id IS NOT NULL AND is_autogenerated=1";
$this->delete($sql);

$sql = "SET FOREIGN_KEY_CHECKS = 1";
Expand Down
4 changes: 2 additions & 2 deletions magmi/web/magmi_web_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
function tdarray_to_js($container, $mainarr, $prefix)
{
$varr = array();
$vlist = explode(",", $container->getParam($mainarr));
$vlist = explode(",", $container->getParam($mainarr) ?? '');
foreach ($vlist as $k) {
$v = $container->getParam("$prefix:" . rawurlencode($k));
$v = addslashes($v);
$v = addslashes($v ?? '');
$varr[] = "\"$k\":\"$v\"";
}
return "{" . implode(",", $varr) . "}";
Expand Down
4 changes: 2 additions & 2 deletions magmi/web/progress_parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ public function parseData($type, $info)
}
$this->setData("$type:count", $dcount);
if ($delapsed > 0) {
$this->setData("$type:speed", ceil(($dcount * 60) / $delapsed));
$this->setData("$type:speed", ceil(($dcount * 60) / (double)$delapsed));
} else {
$this->setData("$type:speed", 0);
}

$this->setData("$type:elapsed", round($delapsed, 4));
$this->setData("$type:elapsed", round((double)$delapsed, 4));
$this->setData("$type:incelapsed", round($dlastinc, 4));
break;
case "columns":
Expand Down