WordPress更新后出现Call-time pass-by-reference移除致命错误求助
Hey there! Let's break down this error and get your site back up and running smoothly.
What's causing the error?
This issue pops up because PHP 5.4 and later versions completely removed support for call-time pass-by-reference—that’s the & you added before variables when calling a function, like &$Anno and &$Mese in your line 4. This syntax was deprecated long before PHP 5.4, so when WordPress updates (which often require newer PHP versions), old code using this outdated trick will throw this fatal error.
How to fix your code
The fix is straightforward: just remove the & symbols from the function call. Here's your corrected code snippet:
if (!empty($catid)) { $Anno=0; $Mese=0; Pasw13_MeseAnnoCorrenti($Anno, $Mese); // Removed the & before $Anno and $Mese $ArchiviMesiAnno=Pasw13_ElencoAnniMesi("mesi",$catid,$Anno); $ArchiviAnni=Pasw13_ElencoAnniMesi("anni",$catid,$Anno); if (!empty($ArchiviMesiAnno) || !empty($ArchiviAnni)){
A quick check to ensure it works
For this fix to fully function, the Pasw13_MeseAnnoCorrenti function must already have reference parameters defined in its original code. That means the function should look something like this (you don’t need to change this unless it’s missing the &):
function Pasw13_MeseAnnoCorrenti(&$anno, &$mese) { // Function logic here that modifies $anno and $mese }
If the function doesn’t have those & symbols in its definition, you’ll need to add them there instead—this is where PHP expects references to be declared now.
Bonus tip
While we’re at it, PHP recommends using || instead of Or for logical OR operations, as it has higher precedence and avoids potential unexpected behavior. I swapped that in the code snippet above too!
内容的提问来源于stack exchange,提问作者kowalski215

