Prestashop with smarty_internal_templatebase - php

PrestaShop 1.6.1.10
PHP 5.5.7
When I turn on debugging in PrestaShop, appear as errors like this, I would fix it, but I do not understand how to fix it.
Notice: Undefined index: br in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 34 Notice: Trying to get property of
non-object in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 34 Notice: Undefined index: hookPaymentShow in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 44 Notice: Trying to get property of
non-object in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 44 Notice: Undefined index: manifestPDFFooter
in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 52 Notice: Trying to get property of
non-object in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 52 Notice: Undefined index: desc in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 54 Notice: Trying to get property of
non-object in
public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157)
: eval()'d code on line 54

It means somewhere in a tpl there is a call to hookPaymentShow (for example) in an array that is not defined (doesn't exist).
Try to find the location where the notice is thrown, and you can delete the entry or use something like {if isset($array['variable'])}$array['variable']{/if}

Related

Wordpress fatal error when editing post and using accent/non english letters

I updated w wordpress blog site to 6.0.1 and everything is okay except the post editing page doesn't load in (fatal error), when I use non english letters like "á".
If I create a new post and I write the content to "a" it is good.
Then if I change it to "á" it is bad.
If I deactivate the block editor in the user profile and I create a new post and I write "a" it is good.
If I then change it to "á" it is good.
Something is bad with the block editor.
The character coding of the tables and columns are utf8mb4_unicode_ci.
The php version is 7.4.
The MySQL version is 5.5.5-10.5.15-MariaDB.
Things I have tried:
deactivated every plugin
changed themes to twntytwentytwo
Notice:
Trying to access array offset on value of type null in blog/wp-content/plugins/wp-hide-post/admin/settings/class_settings.php
on line 324
Notice:
Undefined offset: 0 in blog/wp-includes/class-wp-block.php
on line 224
Notice:
Trying to get property 'parsed_block' of non-object in blog/wp-includes/class-wp-block.php
on line 228
Notice:
Trying to access array offset on value of type null in blog/wp-includes/block-supports/elements.php
on line 100
Notice:
Trying to get property 'parsed_block' of non-object in blog/wp-includes/class-wp-block.php
on line 233
Notice:
Trying to get property 'parsed_block' of non-object in blog/wp-includes/class-wp-block.php
on line 236
Notice:
Trying to access array offset on value of type null in blog/wp-includes/blocks/gallery.php
on line 20
Notice:
Trying to access array offset on value of type null in blog/wp-includes/blocks/latest-posts.php
on line 234
Notice:
Trying to access array offset on value of type null in blog/wp-includes/blocks/navigation.php
on line 666
Warning:
Creating default object from empty value in blog/wp-includes/class-wp-block.php
on line 236
Notice:
Undefined property: stdClass::$context in blog/wp-includes/class-wp-block.php
on line 239
Fatal error: Uncaught Error: Call to undefined method stdClass::render() in blog/wp-includes/class-wp-block.php:241
Stack trace:
#0 blog/wp-includes/blocks.php(901): WP_Block->render()
#1 blog/wp-includes/blocks.php(939): render_block(Array)
#2 blog/wp-includes/class-wp-hook.php(307): do_blocks('

Elementor conflicts with Ekommart Theme

I have a problem with elementor and Ekommart wordpress theme , I think there's is a conflict betweed this two , Tried to install the last version of Elementor and Ekommart but this problem happens :
Notice: Undefined offset: 1 in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 53
Notice: Trying to access array offset on value of type null in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 53
Notice: Undefined offset: 1 in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 53
Notice: Trying to access array offset on value of type null in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 53
Notice: Undefined offset: 2 in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 54
Notice: Trying to access array offset on value of type null in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 54
Notice: Undefined offset: 2 in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 54
Notice: Trying to access array offset on value of type null in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 54
Notice: Undefined offset: 3 in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 55
Notice: Trying to access array offset on value of type null in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 55
Notice: Undefined offset: 3 in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 55
Notice: Trying to access array offset on value of type null in /home/cphdigit/b2b.cph-hydro.com/wp-content/themes/cph-hydro/inc/elementor/class-elementor.php on line 55

Fetching Data from a Json API endpoint and saving the data in an array. Basically Creating variables from Json data received from an API callback

I am trying to fetch data from an api, saving the data into variables which i plan to finally save in the database. The problem is that the project is throwing errors which i have not been able to solve.
This code is for PHP and JSON. I am working on an online payment system and i want to save the data received from callbacks into my database. However, i am not able to do this because the data received in JSON format, is proving to be a headache extracting it.
Here is the PHP code of how i am extracting the variables:
$amount=$callbackData->Body->CallbackMetadata->Item[0]->Value;
$mpesaReceiptNumber=$callbackData->Body->stkCallback->CallbackMetadata->Item[1]->Value;
$balance=$callbackData->Body->stkCallback->CallbackMetadata->Item[2]->Value;
$b2CUtilityAccountAvailableFunds=$callbackData->Body->stkCallback->CallbackMetadata->Item[3]->Value;
$transactionDate=$callbackData->Body->stkCallback->CallbackMetadata->Item[4]->Value;
$phoneNumber=$callbackData->Body->stkCallback->CallbackMetadata->Item[5]->Value;
Here is the JSON Data:
{
"Body":{
"stkCallback":{
"MerchantRequestID":"22571-1918158-1",
"CheckoutRequestID":"ws_CO_DMZ_357840864_13022019182443436",
"ResultCode":0,
"ResultDesc":"The service request is processed successfully.",
"CallbackMetadata":{
"Item":[
{
"Name":"Amount",
"Value":1.00
},
{
"Name":"MpesaReceiptNumber",
"Value":"NBD5TUW3AV"
},
{
"Name":"Balance"
},
{
"Name":"TransactionDate",
"Value":20190213182502
},
{
"Name":"PhoneNumber",
"Value":254727304011
}
]
}
}
}
}
Here is the error I am getting:
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Undefined property: stdClass::$CallbackMetadata in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 25
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Item' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 25
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Value' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 25
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Undefined property: stdClass::$CallbackMetadata in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 26
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Item' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 26
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Value' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 26
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Undefined property: stdClass::$CallbackMetadata in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 27
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Item' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 27
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Value' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 27
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Undefined property: stdClass::$CallbackMetadata in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 28
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Item' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 28
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Value' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 28
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Undefined property: stdClass::$CallbackMetadata in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 29
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Item' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 29
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Value' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 29
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Undefined property: stdClass::$CallbackMetadata in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 30
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Item' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 30
[13-Feb-2019 14:46:07 Europe/London] PHP Notice: Trying to get property 'Value' of non-object in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 30
[13-Feb-2019 14:46:07 Europe/London] PHP Warning: json_decode() expects parameter 1 to be string, array given in /home/vinemupw/public_html/project/callbacks/stkcallback.php on line 64
Did you json_decode the response ? Suggesting $data holds the json string you have to do
$arr = json_decode($data, true);
Then you can access the ResultCode for example with:
$arr['Body']['stkCallback']['ResultCode'];
To access the Item list
$callbackMetadata = $data['Body']['stkCallback']['CallbackMetadata'];
$amount = $callbackMetadata['Item'][0];
As a note: The second parameter in json_decode defines if an assoc array or an object should be returned.
Edit : The json you posted above has an invalide structure, did you maybe remove some values ?

drupal 7 : Undefined index: text_processing in text_content_migrate_instance_alter()

This issue is on the migration of Drupal 6 CCK fields to Drupal 7 fields.
Here is Error that repeat many time
Notice: Undefined index: text_processing in
text_content_migrate_instance_alter() (line 113 of
E:\wamp\www\travel-local\sites\all\modules\cck\modules\content_migrate\modules\content_migrate.text.inc).
Notice: Undefined index: min in
number_content_migrate_instance_alter() (line 162 of
E:\wamp\www\travel-local\sites\all\modules\cck\modules\content_migrate\modules\content_migrate.number.inc).
Notice: Undefined index: max in
number_content_migrate_instance_alter() (line 163 of
E:\wamp\www\travel-local\sites\all\modules\cck\modules\content_migrate\modules\content_migrate.number.inc).
Notice: Undefined index: prefix in
number_content_migrate_instance_alter() (line 164 of
E:\wamp\www\travel-local\sites\all\modules\cck\modules\content_migrate\modules\content_migrate.number.inc).
Notice: Undefined index: suffix in
number_content_migrate_instance_alter() (line 165 of
E:\wamp\www\travel-local\sites\all\modules\cck\modules\content_migrate\modules\content_migrate.number.inc)
Please reply
thanks
this is due to "Date Migration Example" modules. Before migration we should uninstall this modules and related content.

Drupal error after creating new theme ,Undefined variable: hide_site_name and other similar error

I am new to drupal theme . I have created a direcory mytheme and added mytheme.info to it and copied other files from drupal's default theme directory . Now after editing the page.tpl.php, drupal is showing the errors below .
Notice: Undefined variable: hide_site_name in include() (line 99 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined variable: hide_site_name in include() (line 109 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: featured in include() (line 168 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: highlighted in include() (line 187 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: sidebar_second in include() (line 212 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_first in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_middle in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_last in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_firstcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_secondcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_thirdcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_fourthcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
After searching on google, I have found that clearing cache will solve the problem . But even after clearing my cache,it remains the same !
Generally these errors occurred when you call a region in your page.tpl.php file that doesn't exist in the theme's .info file.
In your page.tpl.php:
$page['footer_firstcolumn'];
In your theme's .info:
regions[footer_firstcolumn] = Footer first column
After rechecking all regions, don't forget to flush the cache.
If you want to create a fresh theme best practice is to use something like Zen. It's blank and fully customizable.
As long as you follow the prescribed instructions, you will avoid nasty errors like the ones you have above
i had almost the same problem of messages saying "Notice: undefined index: myIndex in include() (line n in some/path/myPage.tpl.php)" whe i was coding my custom sub-template
I kind of solved the problem using php's function isset() for every line told in the Notice message.
For example in your line 99 i would use:
if(isset(hide_site_name)){
//use hide_site_name in the normal way
}
or in your line 168
if(isset( some_var[featured] )){
//use "featured" index in the normal way
}
hope this helps someone as this helped me after a long time searching for a solution.
i never found the cause of this behavior btw.
sorry for bad grammar, if there's any.
I had the same problem after creating a sub theme and I followed the answer by Meiker and it worked great about including isset. But as I do not have a lot of experience with programing I ran into a snag with line 220 and multiple triptych in the same line.
Notice: Undefined index: triptych_first in include() (line 220 of
C:\wamp\www\dtest\sites\all\themes
So I added isset like this:
if(isset($page['triptych_first']) || (isset($page['triptych_middle']) || (isset($page['triptych_last'])))) :
and did the same for similar error lines and now I do not have any more errors appearing.
I hope this helps others who are programming challenged.

Categories