Debian 10 with PHP 7.3.4-2 – Calling the undefined function curl_init ()

I'm using a VPS with Debian 10, Apache 2.4.38, PHP 7.3.4-2, MariaDB 10.3.15 and Curl 7.64.0.

On one of the hosted, older sites, I run a script that uses curl_init(); which fails with the following error:

Error: Uncaught Error: Call to undefined function curl_init() in /var/www/example.com/public_html/_function.php:218
Stack trace:
#0  

For older versions of Debian / Ubuntu, the solution was to use the ppa:ondrej/php and then install php7.1-curl or later.

When I try to add the repository, the following error message appears:

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see 
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press (ENTER) to continue or ctrl-c to cancel adding it

gpg: keybox '/tmp/tmp013x8d0y/pubring.gpg' created
gpg: /tmp/tmp013x8d0y/trustdb.gpg: trustdb created
gpg: key 4F4EA0AAE5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no valid OpenPGP data found.

I would appreciate your feedback on how to fix the main problem and if this is the recommended way curl_init(); work in the described setting.

google sheets – TypeError: Property "metrics" can not be read by undefined

I can not figure that out. I can run this script a few times to get Pagespeed Insights. Recently, however, the error message "TypeError: Property" audits "Can not be read by undefined" is displayed. I go to the API Explorer and everything works, but I can not figure out why this is happening.

function insertPageSpeedData() {
  var urls = getData();
  var sheet = SpreadsheetApp.openById('15DGtJb4hW2L8HIaLpreDQE8MJTZvt27Kh1rw8a2').getSheetByName('InputData');  
  for(var i = 0; i < urls.length; i++){
    pageSpeedData = getPageSpeedData(urls(i));
    sheet.appendRow((pageSpeedData.id, 
                     parseFloat(pageSpeedData.firstContentfulPaint, 10),
                     parseFloat(pageSpeedData.firstInputDelay, 10), 
                     pageSpeedData.performanceScore,
                     parseFloat(pageSpeedData.firstMeaningfulPaint, 10),
                     parseFloat(pageSpeedData.timetoInteractive, 10)
                    ));
  }

 }

function getPageSpeedData (url) {
  var url = url;
  var pageSpeedApi = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=" + url + "&strategy=desktop&key=AIzaSyC62fdejPrYL5CKmoVO3rL_ARWMk505&prettyPrint=true";
  var source = UrlFetchApp.fetch(pageSpeedApi, {muteHttpExceptions: true}).getContentText();
  var data = JSON.parse(source);
  var lighthouse = data.lighthouseResult.audits;
  var categories = data.lighthouseResult.categories;


  return {
    id: data.id,
    firstContentfulPaint: (lighthouse('first-contentful-paint').displayValue != undefined ? lighthouse('first-contentful-paint').displayValue : ' '),
    firstInputDelay: (lighthouse('max-potential-fid').displayValue != undefined ? lighthouse('max-potential-fid').displayValue : ' '),
    performanceScore: (categories('performance').score != undefined ? categories('performance').score : ' '),
    firstMeaningfulPaint: (lighthouse('first-meaningful-paint').displayValue != undefined ? lighthouse('first-meaningful-paint').displayValue : ' '),
    timetoInteractive: (lighthouse('interactive').displayValue != undefined ? lighthouse('interactive').displayValue : ' '),


  }
}

Visual Studio Code – Undefined variable in Python

I tried to create a simple personal assistant to learn a bit more about the Python language (I'm 16 and have not started teaching in class yet).

And I came across a strange bug that says that a variable within a function is undefined. However, I'm pretty sure I've declared it, and I should accept it.

Here I leave my code.

# Importar Librerías

import speech_recognition as sr # Reconocimiento de voz.

from gtts import gTTS # Conversión de texto a MP3.
import playsound # Lectura de MP3.

# Declarar Variables

username = ""
myName = "Vewi"

microphone = sr.Recognizer()

tts = ""
audioNumber = 0 # Ésta es la variable declarada.

lang = "es-ES"

# Función Presentarse

def ImVewi():
    audioText = ("Hola, soy " + myName + ". Mi trabajo será ayudarte. Para comunicarte conmigo, prueba a hablarle al micrófono. Ahora, te haré unas preguntas rápidas para poder mejorar tu experiencia.")
    TextToSpeech(audioText)
    ChangeUsername()

# Función Obtener Username

def ChangeUsername():
    global audioText
    with sr.Microphone() as source:
        audioText = ("¿Cómo te llamas?")
        TextToSpeech(audioText)
        print("a")
        audio = microphone.listen(source)
        print("Listened")
    try:
        username = microphone.recognize_google(audio, language=lang)
        audioText = ("Perfecto, ahora te llamaré " + username + ".")
        TextToSpeech(audioText)
    except sr.UnknownValueError:
        audioText = ("Disculpa, no te he entendido. ¿Podrías repetirlo?")
        TextToSpeech(audioText)
        ChangeUsername()
    except sr.RequestError:
        audioText = ("Disculpa, se ha producido un error. ¿Podrías repetirlo?")
        TextToSpeech(audioText)
        ChangeUsername()

# Transformar Texto a Audio

def TextToSpeech(audioText): # Ésta es la función con el error.
    audioNumber+=audioNumber # El error lo da en esta línea.
    tts = gTTS(text=audioText, lang = lang)
    tts.save("Audio/Speech"+str(audioNumber)+".mp3")
    playsound.playsound("Audio/Speech"+str(audioNumber)+".mp3", True)

# Llamar Funciones

ImVewi()

I should create an MP3 file named "Speech1.mp3" because previously created files can not be overwritten by default. It can not simply be "Speech.mp3" or a predefined name.

In the terminal I get this problem:

Undefined variable & # 39; audioNumber & # 39; // line 58, column 5

It would also help me if someone knew another way or overwrites the previously created MP3 files.

I tried it for a while and could not fix it.
Thanks in advance.

ajax – Uncaught TypeError: The property & # 39; arrayToDataTable & # 39; from undefined can not be read

//google.charts.load(&#39;current & # 39 ;, {& # 39; packages & # 39 ;: ['corechart'] });
//google.charts.setOnLoadCallback (displayDonut ());

var displayDonut = function () {
var elementId = & # 39; & # 39 ;;
var inputData = [];
$ (& # 39; donutChart & # 39;). each (function (i, value) {
elementId = value.getAttribute (& # 39; id & # 39;);
$ .ajax ({
URL: "/ Home / getChartData",
dataType: "json",

Type: "GET",
contentType: "application / json; charset = utf-8",
Success: Function (Response) {
if (inputData.length <= 0) {
inputData.push (["Task", "Hours"]);
}
$ .each (answer, function (key, value) {
inputData.push ([value.Task, value.Hours]);

});

//console.log(inputData);
var options = {
& # 39; title & # 39 ;, & # 39;
"pieHole": 0.7,
To dye: ['#FA0A0A', '#FBD900', '#ABA2A2'].
pieSliceText: & # 39; none & # 39 ;,
Legend: "none"
};
var dataChart = new google.visualization.arrayToDataTable (inputData);

var chart = new google.visualization.PieChart (document.getElementById (id));
chart.draw (dataChart, options);

}
});


});
};


google.charts.load (& # 39; current & # 39 ;, & # 39; packages & # 39 ;: ['corechart'] });
google.charts.setOnLoadCallback (displayDonut ());
error:
customchart.js: 32 Uncaught TypeError: The property & # 39; arrayToDataTable & # 39; from undefined can not be read
at Object.success (customchart.js: 32)
at c (jquery.min.js: 2)
at Object.fireWith [as resolveWith] (jquery.min.js: 2)
at l (jquery.min.js: 2)
at XMLHttpRequest. (jquery.min.js: 2)

magento2 – Undefined property: DOMDocument :: $ documentElement in

Note: Undefined property: DOMDocument :: $ documentElement in /var/www/html/projectnenny/vendor/magento/framework/Config/Dom.php on line 148

Fatal Error: TypeError not caught: Argument 1 passed to Magento Framework Config Dom :: _ mergeNode () must be an instance of DOMElement stored in / var / www / html / projectnenny / vendor / magento / framework / config is specified as null /Dom.php on line 148 and defined in /var/www/html/projectnenny/vendor/magento/framework/Config/Dom.php:164 Stack trace: # 0 / var / www / html / projectnenny / vendor / magento / framework / Config / Dom.php (148): Magento Framework Config Dom -> _ mergeNode (NULL, & # 39; & # 39;) # 1 / var / www / html / projectnenny / vendor / magento / framework / Config / Reader / Filesystem. PHP (151): Magento Framework Config Dom-> merge (& # 39; _ readFiles (object (Magento Framework Config FileIterator)) # 3 / var / www / html / projectnenny / generated / code / Magento / Framework / ObjectManager /Config/Reader/Dom/Proxy.php(95): Magento Framework Config Reader Filesystem-> read (& # 39; global & # 39;) # 4 / var / www / html / projectnenny / vendor / magento / framework / Interception / C in /var/www/html/projectnenny/vendor/magento/framework/Config/Dom.php on line 164

I usually use PHP 7.2 for Magento 2.
Recently I received a complete project in Magento that is not running in PHP 7.2, so I am also changing my PHP version to 7.0.
Install all required extensions in PHP 7.0 version

and when I open my project home page this error is displayed.
Then you also execute all problem-related commands like: –
sudo apt-get install php7.0-dom
and
sudo apt-get install php7.0-xml

but my problem is not solved.

please help

Plugins – Form does not appear after upgrading to Ninja Forms 3 (backbone is undefined)

After upgrading to Ninja Forms 3, the forms on my site will not load on pages. The preview form loads without problems, but when the form is added to a page, it does not load.

The charging indicator is displayed, so I know that at least something is happening.

I've checked the console log and it reads that backbone is not defined in … / wp-content / plugins / ninja-forms / assets / js / min / front-end-deps.js

I tried to clear my site's cache, but no luck.

Enter image description here

8 – Variables inserted or set in a twig file are undefined after the first position of an entity reference field

I have a paragraph configuration with an entity reference field that allows an editor to select multiple nodes for use in an ad.

Based on the number of nodes, I want to trigger a class. I thought a way to do that would be with you hook_preprocess_node () on topic:

$ onItem = $ node -> _ImportItem;
if (! empty ($ onItemItem)) {
$ referringEntity = $ onItem-> getEntity ();

if (
! empty ($ matchingEntity)
&& ($ referingEntity instance of NodeInterface || $ referingEntity instance of paragraph)
) {
$ referringEntityType = $ matchingEntity-> getType ();
$ referringEntityTypeId = $ matchingEntity-> getEntityTypeId ();
}
}

if ($ referringEntityType == & # 39; homepage_feature & # 39;) {
$ count = $ referingEntity-> get (& # 39; field_items & # 39;) -> count ();

// Default.
$ variable['top_image'] = FALSE;
$ variable['right_image'] = FALSE;

// Should this be only 1 AND it is the first delta element in field_feature?
// If not, each element of the Homepage feature gets a top image, which may not be there
// he wishes.
if ($ count == 1) {
$ variable['top_image'] = TRUE;
}
}

The above logic could be too complicated. Basically, I look back to see which paragraph type was used so I can pass new variables to the template.

What I noticed is that although the code for each listed node is hit, the variables only exist in the first node. I have written them in the template and it is correct there, but in the other nodes they are undefined.

In Twig, I tried to put the variable at the top of the template:

{{}} Top_image

I can see it in the first record 1 over the markup, and then it never appears again.

How can I ensure that the variables are correctly passed to the template each time?

To edit:

This can cause you to use the same node with the same view mode in different paragraphs or entity references on the same page.

Is it the solution to add cache tags / context to the rendered node to take into account which parent it outputs?

php – Undefined index: total

I perform an array operation so I put the sum total of the selected products in a shopping cart and get the error message undefined index.

    public static function statsCarrito () {
$ stats = array (
= Count => 0 #,
Total => 0 & # 39;
);
if (isset ($ _ SESSION['carrito'])) {
$ stats['count'] = count ($ _ SESSION['carrito']);

foreach ($ _SESSION['carrito'] as a $ product) {
$ stats['total'] + = $ Product['precio']* $ Product['unidades'];
}
}

return $ stats;
}