Salta la navigazione

Questo è il forum di assistenza tecnica di WPML, il plug-in multilingue di WordPress.

La sua lettura è permessa a tutti, ma la pubblicazione è riservata esclusivamente ai clienti di WPML. Il team di WPML risponde sul forum 6 giorni su 7, 22 ore su 24.

Nessun supporter è disponibile a lavorare oggi sul forum Italian. Sentitevi liberi di creare ticket e li gestiremo il prima possibile quando saremo online. Grazie per la comprensione.

Sun Mon Tue Wed Thu Fri Sat
- 11:00 – 15:00 11:00 – 15:00 11:00 – 15:00 11:00 – 15:00 11:00 – 15:00 -
- 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 -

Fuso orario del fornitore: Europe/Rome (GMT+02:00)

Etichettato: 

Questo ticket contiene 34 risposte, ha 3 voci.

Ultimo aggiornamento da enricob-50 1 giorno, 5 ore fa.

Assistito da: Laura.

Autore Messaggi
Agosto 26, 2024 a 5:45 am #16102348

enricob-50

Contesto del problema:
Ciao,
sto riscontrando un problema sulla memoria.

Dai log vedo spesso questo errore esatto:

- PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /srv/htdocs/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php on line 154
- PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /srv/htdocs/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/collect/src/Illuminate/Support/Traits/Macroable.php on line 56

Nel momento in cui si genera questo errore nella lingua tradotta, per esempio inglese, quando si fa lo switch, da errore critico.
E' random, non lo fa sempre.

La memoria è settata a 512MB. Nel server non è possibile aumentarla ulteriormente.

Da cosa può dipendere?

I plugin di WPML sono tutti all'ultima versione.

Grazie dell'aiuto

Sintomi:

Domande:

Agosto 26, 2024 a 8:19 am #16103050

Marsel Nikolli

Buongiorno,

Grazie per aver contattato il supporto WPML. Sarò felice di aiutarti.

Questi errori indicano che il limite di memoria PHP (attualmente impostato a 512MB) è insufficiente per le operazioni del plugin. In particolare, il plugin cerca di allocare più memoria di quella disponibile, causando un errore fatale.

A volte, le configurazioni del server sovrascrivono le impostazioni di wp-config.php. Assicurati che il file php.ini sul tuo server abbia un valore di memory_limit adeguato:

memory_limit = 1024M

Nota: Assicurati di avere un backup completo del tuo sito web prima di apportare eventuali aggiornamenti/cambiamenti al sito.

Fammi sapere se questo aiuta,
Marsel

Agosto 26, 2024 a 12:54 pm #16104589

enricob-50

Ho chiesto al server se è possibile aumentare la memoria come da voi suggerito.

Ho notato che questo accade solo nella lingua inglese, ovvero: link nascosto

In italiano, francese e spagnolo no...

Potrebbe esserci un motivo particolare?

Agosto 26, 2024 a 1:04 pm #16104619

Marsel Nikolli

Ciao,

Grazie per l'aggiornamento.

Sarebbe possibile verificare se il problema si presenta in una configurazione minima, ovvero:

- impostare un tema predefinito di WordPress
- mantenere attivi solo i plugin WPML, WCML plugin e i plugin essenziali
- disabilitare tutti gli altri plugin

Dopo, verifica se il problema persiste.

**Nota:** Assicurati di avere un backup completo (file e database) prima di provare qualsiasi modifica sul tuo sito web.

Fammi sapere come procede,
Marsel

Settembre 5, 2024 a 7:00 am #16143288

enricob-50

Ciao, ho atteso un pò a rispondere perchè mi sono interfacciato con l'hosting corrente con il fine di risolvere il problema, ma per ora nulla di fatto.

Premessa: in questo hosting (Pressable) non è possibile aumentare la memoria oltre a 512MB, questa la loro risposta:

....

"In the Pressable environment, auto-scaling is used. This means that memory is allocated per worker thread, and each worker thread is allocated a maximum of 512Mb. The site can scale to a maximum of 110 threads, each with 512Mb, meaning that in practice, the equivalent static server would be running something over 55Gb of RAM.

That's the theoretical math, but you can see from this that the limit is far more than a site should naturally be using, and if the site is running out of memory, there have to be other factors at play.

Pressable can see that certain options on the site are using considerable resource. They can also see that the site was recently upgraded to PHP 8.3, and have suggested switching that back if you feel that this has triggered more errors."

....

A questo punto abbiamo portato la versione alla 8.1, ma ovviamente non è cambiato nulla.

Abbiamo ricontattato l'assistenza del server e ci dicono:

....

One thing to note: WPML is currently preventing the caching system from running. This is putting extreme pressure on the servers, as all pages are delivered dynamically, rather than leveraging cache.

There is also an issue in your theme functions.php file which is causing issues: it appears that, on some occasions, the contstant ICL_LANGUAGE_CODE is called but is not defined.

We recommend wrapping this code block in a try{}catch(Exception $ex){} block to defend against these fatal errors, or adding other defensive code to prevent this from causing a crash should the constant not be defined.

....

Ho corretto il codice come da loro indicazione e il warning è sparito. Ma l'errore sulla memoria rimane.

Detto ciò mi dicono:

....

This prevents Batcache from setting the WPML cookies as skip cookies (by default, Batcache will exclude from memcached any cookie starting with wp).

It also sets the memcached caching period to 1800 seconds (30 minutes) and ensures that the page is cached on the first visit.

//Batcache Customizations
global $batcache;

//Check if batcache params are in an object or an array, apply customizations accordingly
if ( is_object( $batcache ) ) {
$batcache->max_age = 1800; // Seconds the cached render of a page will be stored
$batcache->seconds = 0; // Time number of visitors required to cache, 0 = instant
$batcache->times = 1; // Number of visitors required to cache
$batcache->noskip_cookies = array( 'wordpress_test_cookie','wp-wpml_current_language','wpml_browser_redirect_test' ); // Cookies that prevent caching
} elseif ( is_array( $batcache ) ) {
$batcache['max_age'] = 1800; // Seconds the cached render of a page will be stored
$batcache['seconds'] = 0; // Time number of visitors required to cache, 0 = instant
$batcache['times'] = 1; // Number of visitors required to cache
$batcache['noskip_cookies'] = array( 'wordpress_test_cookie','wp-wpml_current_language','wpml_browser_redirect_test' ); // Cookies that prevent caching
}
// End Batcache Customizations

This appears to be working well on staging but I have not tested extensively. Could you take a look at this for me, test, and decide?

Then: on the live server we see Nitropack using setcookie to handle the currency cookies. On staging, Nitropack is not enabled, and caching, with the changes above, is working well. However, the way Nitropack is handling these cookies is preventing the advanced-cache.php from working correctly.

Memcached is an in-memory caching system that allows your site to store cached pages in server RAM. It also interacts with the Pressable edge caching system. However, Nitropack is using setcookie on every request, which is preventing the caching from taking place.

....

Replico sul sito live e non risolve e mi dicono nuovamente:

....

Regarding the Out of Memory (OOM) errors, when I checked the site it appeared that you had not disabled the autoloading options as suggested by my colleague. I went ahead and created an on demand backup of your database and then turned off autoload for the following options:
all siteground_* options
duplicator_pro_package_active
ws_menu_editor_pro
otgs-installer
rank-math*
wp_rocket_settings
br_ce_options
9d05698bc2c834e9623f132819ab2830
reVAndESTOehiLdOwdr_user_roles

Since disabling those I have not been able to replicate additional OOM errors. Can you please check the site and see if this is also the case for you? If you do experience one of these errors, please share exactly what you were doing on the site when it occurred so that we can more easily try to replicate the case.

....

Non risolve e come ultima loro risposta ho questo:

Thank you for sharing that video. I was able to duplicate this but not consistently.

Digging a bit more on the site, the only other thing I was able to turn up is a request that appears to be tied to WPML authentication:

|Toggle|2.684,3 ms|385.3 ms|POST|link nascosto 38&website_uuid=36363531-6636-5532-b634-313236336363&ui_language_code= it&site_key=OQUsTQZi2c&signature=qBkq80QKbBQBf79dQpS3nm6zdHA%3D|426|

Associated with that request I see the following which seems to indicate that WPML still has the wrong URL set:

"status":426,"title":"Api error non-matching site finger print","fingerprint_confirmed":true,"stored_fingerprint":{"wp_url":"https ://difiaba.presentazionesitoweb.com"},"identical_url_before_movement":false,"site_moved":false,"received_fingerprint":"{\"wp_url\":\"https:\\/\\/difiaba.it\" }"}],"cw_request_id":"9a08a13bd21c487d8e95e7096bf56954"}

I'm also seeing a notice in the WPML status logs that indicates the same but there appears to be no way to update this via the UI.
2024/09/04 10:45:25 PM
ATE Server Communication
WPML has detected a change in your site's URL. To continue translating your site, go to your WordPress Dashboard and tell WPML if your site has been moved or copied.
0 0 {"url":"https:\/\/ate.wpml.org\/api\/wpml\/languages\/check_pairs","requestArgs":{"method":"POST","body":[{"source_language":"it","target_languages":["en","fr","es"]}]},"status":426}

Can you please check with WPML what the recommended next steps might be here? I beleive you may need to delete the otgs_wpml_tm_ate_cloned_site_lock option but since this is not a plugin made by us I'm not sure.

Il link del video è questo che mostro cosa succede: link nascosto

Potete aiutarmi a risolvere? Perchè se tutto è legato alla memoria allora non lo risolveremo mai se non viene aumentata.

Grazie

Settembre 5, 2024 a 1:40 pm #16145490

Laura
Supporter

Lingue: Inglese (English ) Italiano (Italiano )

Fuso orario: Europe/Rome (GMT+02:00)

Salve,

mi occuperò io del ticket d'ora in poi.

Come prima cosa vorrei capire dove viene usata la costante ICL_LANGUAGE_CODE in quanto è deprecata e non andrebbe utilizzata affatto, questo potrebbe comportare dei problemi.

Inoltre da quello che leggo il sito è stato spostato o ha cambiato URL ma non è stata risolta la notifica che invia WPML, quello può creare problemi. Non hai un messaggio blu nella dashboard?

Settembre 6, 2024 a 7:20 am #16147461

enricob-50

Posso fornirti le credenziali ADMIN cosi puoi verificare direttamente?

E ti indico dove verificare...

Settembre 6, 2024 a 9:12 am #16147863

Laura
Supporter

Lingue: Inglese (English ) Italiano (Italiano )

Fuso orario: Europe/Rome (GMT+02:00)

La notifica è nella dashboard di WordPress, se non c'è o l'hai risolta, ma questo lo puoi sapere solo tu, oppure c'è qualche problema che ne impedisce la visualizzazione, però non è una cosa che posso verificare solo accedendo al sito.

Idem per la costante, di solito viene aggiunta al wp-config.php ma a prescindere mi serve sapere perché è stata aggiunta e questo non lo posso sapere solo guardando il file.

Settembre 6, 2024 a 9:31 am #16147917

enricob-50

Ti rispondo per punti:

- La notifica sulla dashboard di WordPress non è presente. WPML è collegato al sito live e non ho notifiche relative a siti diversi da quello live.

- la costante: è stata aggiunta al file functions.php per mettere la condizione su quale lingua eseguire il codice.

Esempio:

if(defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE == 'en'){
//
}
elseif(defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE == 'fr'){
}
ecc...

Ci sono metodi alternativi per sapere la lingua sulla quale eseguire il codice?

Settembre 6, 2024 a 9:55 am #16148079

Laura
Supporter

Lingue: Inglese (English ) Italiano (Italiano )

Fuso orario: Europe/Rome (GMT+02:00)

Il metodo che suggeriamo ora è usare l'hook wpml_current_language, vedi qui e qui per più informazioni.

Settembre 6, 2024 a 12:15 pm #16148916

enricob-50

Ok grazie.

Fisicamente nella condizione if, puoi farmi un esempio pratico?

Settembre 6, 2024 a 12:17 pm #16148935

enricob-50

Quindi potrebbe essere:

$lingua_corrente = apply_filters( 'wpml_current_language', NULL );

if(lingua_corrente == 'en'){
}

esatto?

Settembre 6, 2024 a 1:45 pm #16149215

Laura
Supporter

Lingue: Inglese (English ) Italiano (Italiano )

Fuso orario: Europe/Rome (GMT+02:00)

Senza sapere cosa vuoi fare esattamente e qual è il resto del codice mi risulta impossibile dare indicazioni.

Settembre 7, 2024 a 12:23 pm #16151268

enricob-50

Ciao Laura,

penso che stiamo andando fuori tema, il problema attuale sul sito è che sto riscontrando un problema sulla memoria.

Se leggi tutta la conversazione il servizio attuale di hosting imputa tale problema a WPML.

Quando si presenta il problema? Non sempre, random, ma 100% delle volte allo switch della lingua inglese, non delle altre lingue. Si vede un errore critico e sui log cè l'avviso della memoria.

Fammi sapere che tipo di informazioni ti servono per poter trovare una soluzione al problema.

Grazie mille dell'aiuto.

Settembre 9, 2024 a 11:37 am #16155905

Laura
Supporter

Lingue: Inglese (English ) Italiano (Italiano )

Fuso orario: Europe/Rome (GMT+02:00)

Non mi sembra che stiamo andando fuori tema. E' stato l'hosting stesso a dirti che il problema può essere la costante

There is also an issue in your theme functions.php file which is causing issues: it appears that, on some occasions, the contstant ICL_LANGUAGE_CODE is called but is not defined.

visto che è deprecata, dovresti sostituirla con l'hook e vedere se questo aiuta con il problema della memoria. Ma con le indicazioni che mi hai dato non mi è possibile dirti se stai usando l'hook correttamente.