Undefined index: attribute_price error after update from 1.7.7.5 to 1.7.7.7 - prestashop

After the update from 1.7.7.5 to 1.7.7.7 the error 'Undefined index: attribute_price' appears.
It fails on line 3418 (1.7.7.7) in Product.php.
'attribute_price' => $row['attribute_price'] ?: null,
Bevore line 3408 (1.7.7.5) there was this code that works:
'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null),
It fails only if the feature Combination is disabled.
I don't understand because this code works in the same environment:
$array2 = [
"foo" => "bar",
"bar" => "foo",
];
echo $array2['foos'] ?: "gugus";
PrestaShop version: 1.7.7.7
PHP version: 7.2.24 on Ubuntu

Looks like a core bug to me..
They changed the previous correct statement to the shorthand operator ?: (that states for if...else) without considering that if Combination::isFeatureActive() is not active, $row['attribute_price'] is not set in the query :
if (Combination::isFeatureActive()) {
$sql->select('IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute, product_attribute_shop.`price` AS attribute_price, product_attribute_shop.default_on, product_attribute_shop.`ecotax` AS attribute_ecotax');
$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.id_product = p.id_product AND product_attribute_shop.id_shop = ' . (int) $id_shop . ')');
} else {
$sql->select('0 as id_product_attribute');
}
You can edit ?: to ?? or restore the 1.7.7.5 code to avoid the notice.

Related

Complex MongodbDB query in Mule4

I am trying to make a Mongodb query in Mule with the $in function, but mule says Invalid input '$', expected Namespace or NameIdentifier
have a collection that stores user authorization
{
"_id" : ObjectId("584a0dea073d4c3e976140a9"),
"partnerDataAccess" : [
{
"factoryID" : "Fac-1",
"partnerID" : "Part-1"
}
],
"userID" : "z12",
}
{
"_id" : ObjectId("584f5eba073d4c3e976140ab"),
"partnerDataAccess" : [
{
"factoryID" : "Fac-1",
"partnerID" : "Part-2"
},
{
"factoryID" : "Fac-2",
"partnerID" : "Part-2"
}
],
"userID" : "w12",
}
the flow will submit a userID and partnerID and query the database to see if authorization exist
when I query from Robo 3T, I write queries like this
e.g. user w12 and partner Part-2
db.getCollection('user').find({
userID:"w12", "partnerDataAccess.partnerID": {$in : ["Part-2", "ALL"]}
})
The $in was used because there is the "ALL" setting for admins
but while I try to put the find part into the Mongodb connector, Mule gives error during development and runtime
Hardcoded:
<mongo:find-one-document collectionName="user" doc:name="Find one document" doc:id="a03a6689-6b9d-473c-b8a6-3b8d1e989e38" config-ref="MongoDB_Config">
<mongo:find-query ><![CDATA[#[{
userID:"w12",
"partnerDataAccess.partnerID": {$in : ["Part-2", "ALL"]}
}]]]></mongo:find-query>
</mongo:find-one-document>
parametized
<mongo:find-one-document collectionName="user" doc:name="Find one document" doc:id="a03a6689-6b9d-473c-b8a6-3b8d1e989e38" config-ref="MongoDB_Config">
<mongo:find-query ><![CDATA[#[{
userID: payload.User,
"partnerDataAccess.partnerID": {$in : [ payload.partner, "ALL"]}
}]]]></mongo:find-query>
</mongo:find-one-document>
Error:
during development:
Invalid input '$', expected } or ~ or , (line 3, column 38):
Runtime:
Message : "Script '{
userID:"w12",
"partnerDataAccess.partnerID": {$in : ["Part-2", "ALL"]}
} ' has errors:
Invalid input '$', expected Namespace or NameIdentifier (line 3, column 38):
at 3 : 3" evaluating expression:
I have tried removing the $ or escaping the $ with backslash but it does not work
I know my query is not actually complex, welcome any help
seems to have found the correct way
><![CDATA[#[{
userID:"w12",
"partnerDataAccess.partnerID": {"\$in" : ["Part-2", "ALL"]}
}]]]>

Karate - actual value is not a string

I am checking for an 'OK' parameter in response but getting above mentioned error. The same code was working with my previous karate version, now I am using 0.9.0 - This might be some issue with my coding, can't figure out.
Response:
"testResponse": {
"planSummary": {
"includedServicesList": [
{
"some elements goes here": "test"
}
],
"status": {
"statusCd": "200",
"statusTxt": "OK"
}
}
}
My Feature File Code:
When method get
Then status 200
Then match response contains 'OK'
I get expected: 'OK', reason: actual value is not a string error.
I tried with Then match response contains {statusTxt: 'OK'} as well.
You can try this,
* match response.testResponse.planSummary.status contains {'statusTxt' : 'OK'}
OR
* match response.testResponse.planSummary.status.statusTxt == 'OK'

RStudio shiny datatables save csv unquoted?

How can I save the output of an RStudio Shiny DataTables table using the Save to CSV extension, but have the content saved unquoted instead of the default, which is in double-quotes:
For example, for a single column with two entries, I get a file.csv like this:
"column_name"
"foo"
"bar"
And instead I would like either:
column_name
foo
bar
Or even better, without the header:
foo
bar
My current code looks like this:
output$mytable <- renderDataTable({
entries()
}, options = list(colnames = NULL, bPaginate = FALSE,
"sDom" = 'RMDT<"cvclear"C><"clear">lfrtip',
"oTableTools" = list(
"sSwfPath" = "copy_csv_xls.swf",
"aButtons" = list(
"copy",
"print",
list("sExtends" = "collection",
"sButtonText" = "Save",
"aButtons" = list("csv","xls")
)
)
)
)
)
EDIT:
I tried with one of the suggested answers, and ajax is not allowed, the page complains when I click on SaveTXT. If I do the following, it still puts things within double quotes:
list("sExtends" = "collection",
"sButtonText" = "SaveTXT",
"sFieldBoundary" = '',
"aButtons" = list("csv")
Any ideas?
It should be possible through button options:Button options
And changing sFieldBoundary value.
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [
{
"sExtends": "ajax",
"sFieldBoundary": '"'
}
]
}
} );
} );
But I couldn't get it working in shiny.

EVAL inside grok logstash

I am trying to add new filed in grok filter which supposed to an arithmetic expression of the fields that are extracted by grok match command.
Unfortunately was not able to figure out the correct syntax for that... Anybody?
I found somewhere that {(8*6)} supposed to return 48, but what about variables instead of constants?
====
`if [type] == "f5" {
grok {
match => [ message, "...%{WORD:was_status}...%{NUMBER:hour}hr:%{NUMBER:min}min:%{NUMBER:sec}sec" ]
add_field => [ "duration_%{was_status}", "\{((%{hour} * 3600) + (%{min} * 60) + %{sec})}" ]
}
}`
====
got the result, but EVAL obviously not working correctly:
message: .... [ was down for 0hr:0min:4sec ]
duration_down \`{((0 * 3600) + (0 * 60) + 4)}`
Thanks a lot,
Yuri
There is an outstanding feature request for a math filter, but I'm not aware of any such feature at this time.
In the meantime, you can use the ruby filter to run arbitrary Ruby code on your event.
Here's a simple example:
input {
generator {
count => 1
message => "1 2 3"
}
}
filter {
grok {
match => ["message", "%{NUMBER:a:int} %{NUMBER:b:int} %{NUMBER:c:int}"]
}
ruby {
code => "event['sum'] = event['a'] + event['b'] + event['c']"
}
}
output {
stdout {
codec => rubydebug{}
}
}
Note that grok will usually parse values into strings. If I hadn't converted them to integers, Ruby would have handled the + operator as a string concatenation (and sum would end up equaling 123).
Your ruby filter might look more like this:
ruby {
code => "event['duration_down'] = event['hour']*3600 + event['min']*60 + event['sec']"
}

Data not being passed to the server from Datatables

I have a really simple Datatable configuration,
$("#providerTable").dataTable({
"bLengthChange":false,
"bAutoWidth":false,
"bProcessing": true,
"bServerSide":true,
"sAjaxSource":"${createLink(controller: 'authorization', action: 'fetchProvider')}" ,
"bInfo": true,
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "more_data", "value": "my_value" } );
},
"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
return ("Showing " + iStart +" to "+ iEnd + " of " + iTotal);
}
});
Everything is working fine except that the variable more_data that should have been passed to the server is not passed. I'm using Grails at the server side and a quick parameter dump from the Ajax request gives the following result:
wrappedMap=[iSortCol_0:0, sSearch_2:, bRegex:false, sSearch_3:, sSearch_0:, sSearch_1:, sSearch:, iSortingCols:1, mDataProp_0:0, mDataProp_1:1, mDataProp_2:2, mDataProp_3:3, mDataProp_4:4, bSortable_2:true, bSortable_1:true, bSortable_4:true, bSortable_3:true, bSortable_0:true, sColumns:, iColumns:5, _:1347175565036, sSearch_4:, bRegex_2:false, bSearchable_2:true, bSearchable_1:true, bRegex_3:false, bSearchable_0:true, bRegex_4:false, sSortDir_0:asc, iDisplayStart:0, iDisplayLength:10, sEcho:1, bSearchable_4:true, bRegex_0:false, bSearchable_3:true, bRegex_1:false, action:fetchProvider, controller:authorization]
see, there's no sign of the variable named more_data. All other default Datatable variables along with the controller and action name are being passed except for the more_data variable. What mistake could I be making here?
Thanks
fnServerParams is a new 1.8.2 interface. if you have 1.8.1 or earlier,
there is no fnServerParams
Question about fnServerParams
upgrade to a 1.8.2 or later in order to use the fnServerParams