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

filelayout $$v_categories_name is not getting set #47

Open
mesnitu opened this issue Mar 29, 2018 · 10 comments
Open

filelayout $$v_categories_name is not getting set #47

mesnitu opened this issue Mar 29, 2018 · 10 comments

Comments

@mesnitu
Copy link

mesnitu commented Mar 29, 2018

For some reason, I'm facing a little situation here at import ( with PHP Version 7.1.14) :
The script is checking:
if (isset($filelayout[${$v_categories_name_var}]) || isset($filelayout[$v_categories_name_var_code])) {

However this is what I'm getting:

output $filelayout[${$v_categories_name_var}] -> 
output $filelayout[($$v_categories_name_var)] -> 
output $filelayout[$v_categories_name_var] -> 10

I can only go in the IF without the $$v_categories_name_var
Do we really need that variable variables here ?
Thanks

@mesnitu
Copy link
Author

mesnitu commented Mar 29, 2018

Please ignore the" isset($filelayout[$v_categories_name_var_code])" above. It's isset($filelayout[${$v_categories_name_var_code]})

@mc12345678
Copy link
Owner

Take a look at the current version of the import file beginning at line 805 committed Feb 8, 2016:

       $v_categories_name_var = 'v_categories_name_' . $lid; // ${$v_categories_name_var} >> $v_categories_name_1, $v_categories_name_2, etc.
        $v_categories_name_var_code = 'v_categories_name_' . $lid_code; // ${$v_categories_name_var} >> $v_categories_name_1, $v_categories_name_2, etc.
        if (isset(${$v_categories_name_var}) && isset($filelayout[${$v_categories_name_var}]) || isset(${$v_categories_name_var_code}) && isset($filelayout[${$v_categories_name_var_code}])) { // does column header exist?

@mesnitu
Copy link
Author

mesnitu commented Mar 29, 2018

Ok ! it's Working now. Thanks.
I'm using Easy Populate 4.0.37.6 - 02-08-2017. It's hard keep track

@mc12345678
Copy link
Owner

I have been trying to keep the master branch populated with things that work, even if the version number hasn't been consistently updated with each little tweak made. Pretty much if the files haven't been downloaded following a dated commit, then something has changed that may be of value.

So, all that said, does this issue need to remain open?

@mesnitu
Copy link
Author

mesnitu commented Apr 19, 2018

Well, I've been working on other stuff, and now I got back to import stuff, and guess what ? Still doesn't work. I remenber that it did, when you post it. But I'll close it. I've made a lot of changes to this file. Maybe it's something that I did.

Only works with
if (isset($v_categories_name_var) && isset($filelayout[$v_categories_name_var]) ||

But, since it's working for me this way, and I'm using some modifications on the file, I'll close this.

@mesnitu mesnitu closed this as completed Apr 19, 2018
@mc12345678
Copy link
Owner

mc12345678 commented Apr 26, 2018

Actually, upon further review, we both have something to consider/incorporate. The current condition of the file is as previously posted:

Take a look at the current version of the import file beginning at line 805 committed Feb 8, 2016:

    $v_categories_name_var = 'v_categories_name_' . $lid; // ${$v_categories_name_var} >> $v_categories_name_1, $v_categories_name_2, etc.
      $v_categories_name_var_code = 'v_categories_name_' . $lid_code; // ${$v_categories_name_var} >> $v_categories_name_1, $v_categories_name_2, etc.
      if (isset(${$v_categories_name_var}) && isset($filelayout[${$v_categories_name_var}]) || isset(${$v_categories_name_var_code}) && isset($filelayout[${$v_categories_name_var_code}])) { // does column header exist?

However, there is a problem in the right side of each anded group. The problem is that ${$v_categories_name_var} ultimately returns the value that is stored in the variable $v_categories_name_x rather than the string v_categories_name_x where x is a number. The result of this incorrect logic on the right side is that the if always evaluates as false.

Then there is the proposed revision (partial shown):

if (isset($v_categories_name_var) && isset($filelayout[$v_categories_name_var]) ||

The problem with this in conjunction with the code content that precedes it is that here the left side of the coupled evaluation is always true, because two lines before $v_categories_name_var is assigned to a value other than null and therefore will always be set. The right side evaluates correctly to depend on whether the imported file includes the column associated with the variable $v_categories_name_var which is something like v_categories_name_x where x is a number.

This will be corrected shortly in a new commit.

@mc12345678
Copy link
Owner

This is still under review.

@mc12345678 mc12345678 reopened this Apr 26, 2018
@mesnitu
Copy link
Author

mesnitu commented May 4, 2018

Hi
I've downloaded your latest to a fresh zc install. Now I'm getting inside the categories but getting a endless log file related to AdminRequestSanitizer

[04-May-2018 18:06:03 Europe/Berlin] PHP Warning:  Invalid argument supplied for foreach() in C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php on line 564
[04-May-2018 18:06:03 Europe/Berlin] PHP Stack trace:
[04-May-2018 18:06:03 Europe/Berlin] PHP   1. {main}() C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\easypopulate_4.php:0
[04-May-2018 18:06:03 Europe/Berlin] PHP   2. include_once() C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\easypopulate_4.php:546
[04-May-2018 18:06:03 Europe/Berlin] PHP   3. AdminRequestSanitizer->runSanitizers() C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\easypopulate_4_import.php:959
[04-May-2018 18:06:03 Europe/Berlin] PHP   4. AdminRequestSanitizer->runSpecificSanitizer() C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php:179
[04-May-2018 18:06:03 Europe/Berlin] PHP   5. AdminRequestSanitizer->processBuiltIn() C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php:200
[04-May-2018 18:06:03 Europe/Berlin] PHP   6. AdminRequestSanitizer->filterProductNameDeepRegex() C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php:289
[04-May-2018 18:06:03 Europe/Berlin] Request URI: /zenadmin/easypopulate_4.php, IP address: 192.168.1.73
#1  AdminRequestSanitizer->filterProductNameDeepRegex() called at [C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php:289]
#2  AdminRequestSanitizer->processBuiltIn() called at [C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php:200]
#3  AdminRequestSanitizer->runSpecificSanitizer() called at [C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\includes\classes\AdminRequestSanitizer.php:179]
#4  AdminRequestSanitizer->runSanitizers() called at [C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\easypopulate_4_import.php:959]
#5  include_once(C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\easypopulate_4_import.php) called at [C:\xampp\htdocs\vhosts\zenbookx.local\zenadmin\easypopulate_4.php:546]

@mesnitu
Copy link
Author

mesnitu commented May 4, 2018

And if I try to skip that sanitazer I run into

MySQLi error 1364: Field 'categories_description' doesn't have a default value
When executing:
INSERT INTO categories_description SET
                    categories_id   = 871,
                    language_id     = 1,
                    categories_name = 'Narrativas'

And yes, categories description is set as TEXT with no default value.
Note: I'm using mysql57 ( dont' ask why)

@mesnitu
Copy link
Author

mesnitu commented May 4, 2018

So categories_description must be present, or change categories table to have a default value.
However, still facing that sanitize issue....

$sql = "INSERT INTO " . TABLE_CATEGORIES_DESCRIPTION . " SET
                    categories_id   = :categories_id:,
                    language_id     = :language_id:,
                    categories_name = :categories_name:,
                    categories_description = ''";

mc12345678 added a commit that referenced this issue May 16, 2018
When generating a new category using EP4 while adding a new product, the category name is inserted; however, there has not been a description entered yet and therefore there was no data available to import.  A default ZC install does not assign a default value for the categories_description field within the categories_description table.  

This adds a default value; however, the database should be first queried to identify the existence of a default value.  If a default value is there, then either use the default value or don't include the categories_description when inserting that record.
This relates to #47.
mc12345678 added a commit that referenced this issue Jun 19, 2018
When generating a new category using EP4 while adding a new product, the category name is inserted; however, there has not been a description entered yet and therefore there was no data available to import, the previous correction assumed that the category name was not provided, this addresses the addition of a product that also has a category name identified.  A default ZC install does not assign a default value for the categories_description field within the categories_description table.  

This adds a default value; however, yet to be done is to have the database first queried to identify the existence of a default value.  If a default value is there, then either use the default value or don't include the categories_description when inserting that record.
This relates to #47.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants