Mailing List Archive

Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21
I'm just setting up a new server with IC 5.10, Centos 7.4 and mysql 5.7.21,
whilst testing the catalog on the new server I get an error which is being
caused by the data tag in an actionmap.

This is the line that causes the error:-

my $page = $Tag->data({ table => 'cat2', column => 'which_page', foreign =>
'name', key => $c2 });

The error is:-

Sorry, there was an error in processing this form action. Please report the
error or try again later. (Can't locate object method "open_table" via
package "Vend::Table::DBI" (perhaps you forgot to load "Vend::Table::DBI"?)
at /usr/local/interchange/lib/Vend/Data.pm line 995. )
?
I don't get this error on the old server, centos 5.8, mysql 5.6 and IC 5.10.

Any suggestions how to fix it?

TIA
Andy
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 03/08/2018 12:38 AM, IC wrote:
> I'm just setting up a new server with IC 5.10, Centos 7.4 and mysql 5.7.21, whilst testing the catalog on the new server
> I get an error which is being caused by the data tag in an actionmap.
>
> This is the line that causes the error:-
>
> my $page = $Tag->data({ table => 'cat2', column => 'which_page', foreign => 'name', key => $c2 });
>
> The error is:-
>
> Sorry, there was an error in processing this form action. Please report the error or try again later. (Can't locate
> object method "open_table" via package "Vend::Table::DBI" (perhaps you forgot to load "Vend::Table::DBI"?) at
> /usr/local/interchange/lib/Vend/Data.pm line 995. )
> ?
> I don't get this error on the old server, centos 5.8, mysql 5.6 and IC 5.10.
>
> Any suggestions how to fix it?

Please try this at the beginning of your action map:

$Tag->perl({ tables => 'cat2' });

Regards
Racke

--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
> my $page = $Tag->data({ table => 'cat2', column => 'which_page', foreign => 'name', key => $c2 });
>
> The error is:-
>
> Sorry, there was an error in processing this form action. Please report the error or try again later. (Can't locate object method "open_table" via package "Vend::Table::DBI" (perhaps you forgot to load "Vend::Table::DBI"?) at /usr/local/interchange/lib/Vend/Data.pm line 995. )
> ?
> I don't get this error on the old server, centos 5.8, mysql 5.6 and IC 5.10.
>
> Any suggestions how to fix it?

Hi Andy,

This sounds like an issue with Safe; had you previously done an AllowGlobal or similar on the old server that you did not replicate to the new setup? The other way to fix this is to write a wrapper global usertag or adjust the surrounding ITL to have the [data] tag called as a parse-level construct instead of in a [perl] or [calc] block.

David
--
David Christensen
End Point Corporation
david@endpoint.com
785-727-1171
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
> Hi Andy,
>
> This sounds like an issue with Safe; had you previously done an
> AllowGlobal or similar on the old server that you did not replicate to the
> new setup? The other way to fix this is to write a wrapper global usertag
> or adjust the surrounding ITL to have the [data] tag called as a parse-
> level construct instead of in a [perl] or [calc] block.
>
> David

Hi David,

It should be identical to the old server, same interchange.cfg and catalog.cfg and same IC version just newer OS etc

I don't quite understand how to move forward with a global usertag for this, could you elaborate please?

Thanks,
Andy.



_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
>
> Please try this at the beginning of your action map:
>
> $Tag->perl({ tables => 'cat2' });
>
> Regards
> Racke
>

Hi Racke,

I had already tried that, that line on its own causes the same error.

Regards,
Andy




_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
> On Mar 8, 2018, at 9:33 AM, IC <ic@tvcables.co.uk> wrote:
>
>> Hi Andy,
>>
>> This sounds like an issue with Safe; had you previously done an
>> AllowGlobal or similar on the old server that you did not replicate to the
>> new setup? The other way to fix this is to write a wrapper global usertag
>> or adjust the surrounding ITL to have the [data] tag called as a parse-
>> level construct instead of in a [perl] or [calc] block.
>>
>> David
>
> Hi David,
>
> It should be identical to the old server, same interchange.cfg and catalog.cfg and same IC version just newer OS etc
>
> I don't quite understand how to move forward with a global usertag for this, could you elaborate please?
>
> Thanks,
> Andy.

You’d have to wrap up the logic that you’re currently dong in ITL into something like this:

interchange/code/UserTag/foo.tag:
UserTag foo Routine <<
sub {
my $content = ‘';
# blah blah blah; everything in the [calc] or [perl] block
$content .= $::Tag->data({…});
# blah blah blah
return $content;
}
EOF

Then calling in the page like:

[foo]

Before you did that, you should also make sure that a normal [data] interpolation works as expected in the content; you may be able to so something like:

[tmp data_result][data …][/tmp]

[perl]
# blah blah blah
return $Scratch->{data_result};
[/perl]

If that works, it’s like an issue with the AllowGlobal (or also could be an issue with Safe using different versions of Perl, like changes in which symbols we need to export in Safe::Hole.)

Best,

David
--
David Christensen
End Point Corporation
david@endpoint.com
785-727-1171
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 09/03/18 04:33, IC wrote:
>>
>> $Tag->perl({ tables => 'cat2' });
>
> I had already tried that, that line on its own causes the same error.

In that case, try this in catalog.cfg (or wherever you define the
actionmap):

AutoLoad <<EOA
[perl cat2][/perl]
EOA

... It should work but it will result in cat2 being pre-loaded for
everything. This shouldn't have any significant impact on performance,
though.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 09/03/18 12:43, Peter wrote:
> On 09/03/18 04:33, IC wrote:
>>>
>>> $Tag->perl({ tables => 'cat2' });
>>
>> I had already tried that, that line on its own causes the same error.
>
> In that case, try this in catalog.cfg (or wherever you define the
> actionmap):
>
> AutoLoad <<EOA
> [perl cat2][/perl]
> EOA

Note other alternatives that should work:

Define your actionmap in interchange.cfg instead of catalog.cfg.

Change your actionmap to ITL so it looks like this:

Actionmap foo <<EOA
[perl cat2]
# ...your code here
[/perl]
EOA


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 2018-03-07 04:38 PM, IC wrote:
> I'm just setting up a new server with IC 5.10, Centos 7.4 and mysql 5.7.21, whilst testing the catalog on the new server I get an error which is being caused by the data tag in an actionmap.
>
> This is the line that causes the error:-
>
> my $page = $Tag->data({ table => 'cat2', column => 'which_page', foreign => 'name', key => $c2 });
>
> The error is:-
>
> Sorry, there was an error in processing this form action. Please report the error or try again later. (Can't locate object method "open_table" via package "Vend::Table::DBI" (perhaps you forgot to load "Vend::Table::DBI"?) at /usr/local/interchange/lib/Vend/Data.pm line 995. )
> ?
> I don't get this error on the old server, centos 5.8, mysql 5.6 and IC 5.10.
>
> Any suggestions how to fix it?
>
> TIA
> Andy
>
>

Hey Andy,

I created the following ActionMap in a fresh demo catalog:

ActionMap test <<EOR
sub {
$Tag->data({ table => 'affiliate', column => 'name', key => 'hardhat' });
1;
}
EOR

This generated the same error you received.

Adding the catalog to AllowGlobal in interchange.cfg fixes the issue. I don't think there is any way to use $Tag->data in an ActionMap without AllowGlobal.

See the relevant docs
http://interchange.rtfm.info/icdocs/Creating_custom_Interchange_tags.html#Routine
http://interchange.rtfm.info/icdocs/config/AllowGlobal.html

Cheers,

Andrew

--
https://github.com/pullingshots ... https://metacpan.org/author/BAERGAJ

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 11/03/18 13:52, Andrew Baerg wrote:
> I don't think there is any way to use $Tag->data in an ActionMap
> without AllowGlobal.
Ummm, see my previous responses where I gave three different ways to
make it work.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 2018-03-11 03:46 AM, Peter wrote:
> On 11/03/18 13:52, Andrew Baerg wrote:
>> I don't think there is any way to use $Tag->data in an ActionMap
>> without AllowGlobal.
> Ummm, see my previous responses where I gave three different ways to
> make it work.
>
>
> Peter
>

Right, sorry for not noting that.

But I don't see any way to use $Tag->data directly in an ActionMap sub defined on the catalog level the way Andy had without setting AllowGlobal for the catalog. I don't think Andy's ActionMap could have been working on the previous system without AllowGlobal.


--
https://github.com/pullingshots ... https://metacpan.org/author/BAERGAJ

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 12/03/18 03:53, Andrew Baerg wrote:
> On 2018-03-11 03:46 AM, Peter wrote:
>> On 11/03/18 13:52, Andrew Baerg wrote:
>>> I don't think there is any way to use $Tag->data in an ActionMap
>>> without AllowGlobal.
>> Ummm, see my previous responses where I gave three different ways
>> to make it work.
>
> Right, sorry for not noting that.
>
> But I don't see any way to use $Tag->data directly in an ActionMap
> sub defined on the catalog level the way Andy had without setting
> AllowGlobal for the catalog.

...because two of the three ways I mentioned involve doing just that and
should work.

The issue is that the data tag needs access to the db table and hence
the table itself must be pulled into the Safe container space before
this can happen. Sometimes it works to do $Tag->perl('tablename'), but
since this code itself has to run in a Safe container it often times
fails (as it is for the OP). When this doesn't work then it is required
to pull the tablename in outside of the safe space which is done by
running the perl tag as ITL either ahead of the code that includes
$Tag->data() or surrounding it as in these two examples:

AutoLoad <<EOA
[perl tablename][/perl]
EOA
Actionmap foo <<EOA
sub {
$Tag->data(..);
...
}
EOA


...or...


Actionmap foo <<EOA
[perl tablename]
$Tag->data(...);
...
[/perl]
EOA

...either one of the above should work with a catalog-level Actionmap.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 2018-03-11 12:13 PM, Peter wrote:
> On 12/03/18 03:53, Andrew Baerg wrote:
>> On 2018-03-11 03:46 AM, Peter wrote:
>>> On 11/03/18 13:52, Andrew Baerg wrote:
>>>> I don't think there is any way to use $Tag->data in an ActionMap
>>>> without AllowGlobal.
>>> Ummm, see my previous responses where I gave three different ways
>>> to make it work.
>>
>> Right, sorry for not noting that.
>>
>> But I don't see any way to use $Tag->data directly in an ActionMap
>> sub defined on the catalog level the way Andy had without setting
>> AllowGlobal for the catalog.
>
> ...because two of the three ways I mentioned involve doing just that and
> should work.
>
> The issue is that the data tag needs access to the db table and hence
> the table itself must be pulled into the Safe container space before
> this can happen. Sometimes it works to do $Tag->perl('tablename'), but
> since this code itself has to run in a Safe container it often times
> fails (as it is for the OP). When this doesn't work then it is required
> to pull the tablename in outside of the safe space which is done by
> running the perl tag as ITL either ahead of the code that includes
> $Tag->data() or surrounding it as in these two examples:
>
> AutoLoad <<EOA
> [perl tablename][/perl]
> EOA
> Actionmap foo <<EOA
> sub {
> $Tag->data(..);
> ...
> }
> EOA
>
>
> ...or...
>
>
> Actionmap foo <<EOA
> [perl tablename]
> $Tag->data(...);
> ...
> [/perl]
> EOA
>
> ...either one of the above should work with a catalog-level Actionmap.

Thanks for the explanation!

In case it helps anyone else, it doesn't seem to matter which tablename you put into the perl ITL, so if you stick the following in your catalog.cfg you can use $Tag->data for any table in all ActionMap subs and [calc] blocks.

AutoLoad [perl products][/perl]

On a side note, it seems strange to me that catalog UserTag subs can use the $Tag->data without any issue. The code must run in a slightly different Safe container I suppose.

Cheers!

Andrew

--
https://github.com/pullingshots ... https://metacpan.org/author/BAERGAJ

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 12/03/18 16:12, Andrew Baerg wrote:
> In case it helps anyone else, it doesn't seem to matter which
> tablename you put into the perl ITL, so if you stick the following in
> your catalog.cfg you can use $Tag->data for any table in all
> ActionMap subs and [calc] blocks.
>
> AutoLoad [perl products][/perl]

I actually hadn't realized this, but it explains a lot. Internally
Interchange will share the same dbh handle for any tables that have the
same DSN, the handle will be created when it is first needed. This
means that it's likely that the dbh handle can't be created in the Safe
container, so by accessing a table outside of the safe container first
the dbh handle is created and is then usable inside any Safe containers
after that.

So your statement above is mostly, but not entirely true. It would
likely not work to open the products table ahead of time and then try to
access a table on a completely different database (with a different DSN).

To be safe (no pun intended) I would pre-open the table(s) that you
actually want to access.

> On a side note, it seems strange to me that catalog UserTag subs can
> use the $Tag->data without any issue. The code must run in a slightly
> different Safe container I suppose.

This would be because those usertags are accessed on page code in a
place where the table (or at least a table on the same dbh) has already
been opened previously. Actionmaps, on the other hand, are run before
any other page code and so no tables have been opened yet.

So it's not about running it on a different Safe container, it's about
*when* the db access occurs in relation to other db accesses for the
same dbh handle.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On 2018-03-11 09:24 PM, Peter wrote:
> On 12/03/18 16:12, Andrew Baerg wrote:
>> In case it helps anyone else, it doesn't seem to matter which
>> tablename you put into the perl ITL, so if you stick the following in
>> your catalog.cfg you can use $Tag->data for any table in all
>> ActionMap subs and [calc] blocks.
>>
>> AutoLoad [perl products][/perl]
>
> I actually hadn't realized this, but it explains a lot. Internally
> Interchange will share the same dbh handle for any tables that have the
> same DSN, the handle will be created when it is first needed. This
> means that it's likely that the dbh handle can't be created in the Safe
> container, so by accessing a table outside of the safe container first
> the dbh handle is created and is then usable inside any Safe containers
> after that.
>
> So your statement above is mostly, but not entirely true. It would
> likely not work to open the products table ahead of time and then try to
> access a table on a completely different database (with a different DSN).
>
> To be safe (no pun intended) I would pre-open the table(s) that you
> actually want to access.
>
>> On a side note, it seems strange to me that catalog UserTag subs can
>> use the $Tag->data without any issue. The code must run in a slightly
>> different Safe container I suppose.
>
> This would be because those usertags are accessed on page code in a
> place where the table (or at least a table on the same dbh) has already
> been opened previously. Actionmaps, on the other hand, are run before
> any other page code and so no tables have been opened yet.
>
> So it's not about running it on a different Safe container, it's about
> *when* the db access occurs in relation to other db accesses for the
> same dbh handle.
>
>

Thanks for the explanation Peter!

I have submitted a pull request to add better error messaging/handling when there is no access to a db/table in a Safe container.

https://github.com/interchange/interchange/pull/110

Cheers,

Andrew

--
https://github.com/pullingshots ... https://metacpan.org/author/BAERGAJ

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Error with Tag->data in actionmap after upgrade to Centos 7.4 mysql 5.7.21 [ In reply to ]
On Mon, 12 Mar 2018, Andrew Baerg wrote:

> I have submitted a pull request to add better error messaging/handling
> when there is no access to a db/table in a Safe container.
>
> https://github.com/interchange/interchange/pull/110

I tested that out locally and that is helpful in the error logs. It's
merged now. Thanks, Andrew!

Jon

--
Jon Jensen
End Point Corporation
https://www.endpoint.com/

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users