I'm getting this error Deprecated: "Required parameter $field follows optional parameter $post_id" with a number of item like this one - wordpress-theming

The website had been sitting for a while. I login and update the site. The homepage went blank. I set debug and get this error.
Deprecated: Required parameter $field follows optional parameter $post_id in /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-content/themes/my-listing/includes/extensions/advanced-custom-fields/plugin/includes/acf-value-functions.php on line 54
Deprecated: Required parameter $field follows optional parameter $value in /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-content/themes/my-listing/includes/extensions/advanced-custom-fields/plugin/includes/acf-value-functions.php on line 166
Deprecated: Required parameter $value follows optional parameter $key in /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-content/themes/my-listing/includes/extensions/advanced-custom-fields/plugin/includes/ajax/class-acf-ajax.php on line 76
Fatal error: Uncaught Error: Class "Elementor\Scheme_Typography" not found in /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-content/themes/my-listing/includes/elementor/elementor.php:393 Stack trace: #0 /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-includes/class-wp-hook.php(308): MyListing\Elementor\Elementor->load_custom_fonts() #1 /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #2 /home/johnson/web/hfyc.hereforyoucentral.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #
I change php version from 7.4 to 8.0. But changing it now does nothing.

Related

Verify a function in PowerShell has run succesfully

I'm writing a script to backup existing bit locker keys to the associated device in Azure AD, I've created a function which goes through the bit locker enabled volumes and backs up the key to Azure however would like to know how I can check that the function has completed successfully without any errors. Here is my code. I've added a try and catch into the function to catch any errors in the function itself however how can I check that the Function has completed succesfully - currently I have an IF statement checking that the last command has run "$? - is this correct or how can I verify please?
function Invoke-BackupBDEKeys {
##Get all current Bit Locker volumes - this will ensure keys are backed up for devices which may have additional data drives
$BitLockerVolumes = Get-BitLockerVolume | select-object MountPoint
foreach ($BDEMountPoint in $BitLockerVolumes.mountpoint) {
try {
#Get key protectors for each of the BDE mount points on the device
$BDEKeyProtector = Get-BitLockerVolume -MountPoint $BDEMountPoint | select-object -ExpandProperty keyprotector
#Get the Recovery Password protector - this will be what is backed up to AAD and used to recover access to the drive if needed
$KeyId = $BDEKeyProtector | Where-Object {$_.KeyProtectorType -eq 'RecoveryPassword'}
#Backup the recovery password to the device in AAD
BackupToAAD-BitLockerKeyProtector -MountPoint $BDEMountPoint -KeyProtectorId $KeyId.KeyProtectorId
}
catch {
Write-Host "An error has occured" $Error[0]
}
}
}
#Run function
Invoke-BackupBDEKeys
if ($? -eq $true) {
$ErrorActionPreference = "Continue"
#No errors ocurred running the last command - reg key can be set as keys have been backed up succesfully
$RegKeyPath = 'custom path'
$Name = 'custom name'
New-ItemProperty -Path $RegKeyPath -Name $Name -Value 1 -Force
Exit
}
else {
Write-Host "The backup of BDE keys were not succesful"
#Exit
}
Unfortunately, as of PowerShell 7.2.1, the automatic $? variable has no meaningful value after calling a written-in-PowerShell function (as opposed to a binary cmdlet) . (More immediately, even inside the function, $? only reflects $false at the very start of the catch block, as Mathias notes).
If PowerShell functions had feature parity with binary cmdlets, then emitting at least one (non-script-terminating) error, such as with Write-Error, would set $? in the caller's scope to $false, but that is currently not the case.
You can work around this limitation by using $PSCmdlet.WriteError() from an advanced function or script, but that is quite cumbersome. The same applies to $PSCmdlet.ThrowTerminatingError(), which is the only way to create a statement-terminating error from PowerShell code. (By contrast, the throw statement generates a script-terminating error, i.e. terminates the entire script and its callers - unless a try / catch or trap statement catches the error somewhere up the call stack).
See this answer for more information and links to relevant GitHub issues.
As a workaround, I suggest:
Make your function an advanced one, so as to enable support for the common -ErrorVariable parameter - it allows you to collect all non-terminating errors emitted by the function in a self-chosen variable.
Note: The self-chosen variable name must be passed without the $; e.g., to collection in variable $errs, use -ErrorVariable errs; do NOT use Error / $Error, because $Error is the automatic variable that collects all errors that occur in the entire session.
You can combine this with the common -ErrorAction parameter to initially silence the errors (-ErrorAction SilentlyContinue), so you can emit them later on demand. Do NOT use -ErrorAction Stop, because it will render -ErrorVariable useless and instead abort your script as a whole.
You can let the errors simply occur - no need for a try / catch statement: since there is no throw statement in your code, your loop will continue to run even if errors occur in a given iteration.
Note: While it is possible to trap terminating errors inside the loop with try / catch and then relay them as non-terminating ones with $_ | Write-Error in the catch block, you'll end up with each such error twice in the variable passed to -ErrorVariable. (If you didn't relay, the errors would still be collected, but not print.)
After invocation, check if any errors were collected, to determine whether at least one key wasn't backed up successfully.
As an aside: Of course, you could alternatively make your function output (return) a Boolean ($true or $false) to indicate whether errors occurred, but that wouldn't be an option for functions designed to output data.
Here's the outline of this approach:
function Invoke-BackupBDEKeys {
# Make the function an *advanced* function, to enable
# support for -ErrorVariable (and -ErrorAction)
[CmdletBinding()]
param()
# ...
foreach ($BDEMountPoint in $BitLockerVolumes.mountpoint) {
# ... Statements that may cause errors.
# If you need to short-circuit a loop iteration immediately
# after an error occurred, check each statement's return value; e.g.:
# if (-not $BDEKeyProtector) { continue }
}
}
# Call the function and collect any
# non-terminating errors in variable $errs.
# IMPORTANT: Pass the variable name *without the $*.
Invoke-BackupBDEKeys -ErrorAction SilentlyContinue -ErrorVariable errs
# If $errs is an empty collection, no errors occurred.
if (-not $errs) {
"No errors occurred"
# ...
}
else {
"At least one error occurred during the backup of BDE keys:`n$errs"
# ...
}
Here's a minimal example, which uses a script block in lieu of a function:
& {
[CmdletBinding()] param() Get-Item NoSuchFile
} -ErrorVariable errs -ErrorAction SilentlyContinue
"Errors collected:`n$errs"
Output:
Errors collected:
Cannot find path 'C:\Users\jdoe\NoSuchFile' because it does not exist.
As stated elsewhere, the try/catch you're using is what is preventing the relay of the error condition. That is by design and the very intentional reason for using try/catch.
What I would do in your case is either create a variable or a file to capture the error info. My apologies to anyone named 'Bob'. It's the variable name that I always use for quick stuff.
Here is a basic sample that works:
$bob = (1,2,"blue",4,"notit",7)
$bobout = #{} #create a hashtable for errors
foreach ($tempbob in $bob) {
$tempbob
try {
$tempbob - 2 #this will fail for a string
} catch {
$bobout.Add($tempbob,"not a number") #store a key/value pair (current,msg)
}
}
$bobout #output the errors
Here we created an array just to use a foreach. Think of it like your $BDEMountPoint variable.
Go through each one, do what you want. In the }catch{}, you just want to say "not a number" when it fails. Here's the output of that:
-1
0
2
5
Name Value
---- -----
notit not a number
blue not a number
All the numbers worked (you can obvious surpress output, this is just for demo).
More importantly, we stored custom text on failure.
Now, you might want a more informative error. You can grab the actual error that happened like this:
$bob = (1,2,"blue",4,"notit",7)
$bobout = #{} #create a hashtable for errors
foreach ($tempbob in $bob) {
$tempbob
try {
$tempbob - 2 #this will fail for a string
} catch {
$bobout.Add($tempbob,$PSItem) #store a key/value pair (current,error)
}
}
$bobout
Here we used the current variable under inspection $PSItem, also commonly referenced as $_.
-1
0
2
5
Name Value
---- -----
notit Cannot convert value "notit" to type "System.Int32". Error: "Input string was not in ...
blue Cannot convert value "blue" to type "System.Int32". Error: "Input string was not in a...
You can also parse the actual error and take action based on it or store custom messages. But that's outside the scope of this answer. :)

How can I fix this error invalid command name "_o10 in NS2

You are missing the MIH / MIPv6 addition provided by ns-2.29-nist-mob-022707.tgz.This is for ns-2.29,but I usens-allinone-2.35.Is it the same procedure? Thanks!
This is my code link
https://drive.google.com/file/d/1Aan1OeAh5tIeDrt5MjgFTqvNSeahNWVy/view?usp=sharing
While running my tcl script for new protocol in NS2 it shows error as:
num_nodes is set 10
invalid command name "Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1"
while executing
"Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1 create _o216 "
invoked from within
"catch "$className create $o $args" msg"
invoked from within
"if [catch "$className create $o $args" msg] {
if [string match "__FAILED_SHADOW_OBJECT_" $msg] {
delete $o
return ""
}
global errorInfo
error "class $..."
(procedure "new" line 3)
invoked from within
"new Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1"
invoked from within
"set handover [new Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1]"
(file "bear2.tcl" line 177)
How can I modify it?

I have a warning on all of my posts on my page after I updated my theme

I have just updated my theme and the following error occurs:
Warning: sprintf(): Too few arguments in /home/itsallab/public_html/wp-content/themes/covernews/lib/breadcrumb-trail/inc/breadcrumbs.php on line 254
On this line of the file it writes :
:sprintf('%s', $item );
What part could cause this error?
i found the resolution. it had two '' more that needed in here "'.esc_url( $link_item ).'"
dont know why after the update it changed but i
String concatenation and sprintf should not been combined in a single line. Try using the following:
sprintf('%s', esc_url( $link_item ), $item );

Why is ::cmdline::getoptions throwing an error?

Why does the following code:
#!/usr/bin/env tclsh
package require cmdline;
set options {{d.arg "" "destination directory"}}
set usage ": $::argv0 \[options] filename ...\noptions:"
set params [::cmdline::getoptions ::argv $options $usage]
throw the following error upon execution of ./main.tcl -help?
main : ./main.tcl [options] filename ...
options:
-d value destination directory <>
-help Print this message
-? Print this message
while executing
"error [usage $optlist $usage]"
(procedure "::cmdline::getoptions" line 15)
invoked from within
"::cmdline::getoptions ::argv $options $usage"
invoked from within
"set params [::cmdline::getoptions ::argv $options $usage]"
(file "./main.tcl" line 8)
It should display the usage information, but I didn't expect the error afterwards. Did I do something wrong?
From what I understand from the docs (emphasis mine):
The options -?, -help, and -- are implicitly understood. The first two abort option processing by throwing an error and force the generation of the usage message, whereas the the last aborts option processing without an error, leaving all arguments coming after for regular processing, even if starting with a dash.
using -help or -? will always throw an error.
Further down in the docs you can see an example where try { ... } trap { ... } is being used in conjunction with ::cmdline::getoptions, which might be how you might want to do it:
try {
array set params [::cmdline::getoptions ::argv $options $usage]
} trap {CMDLINE USAGE} {msg o} {
# Trap the usage signal, print the message, and exit the application.
# Note: Other errors are not caught and passed through to higher levels!
puts $msg
exit 1
}

php mysql simplexml_load_string() error mysql_escape_string

I save a XML file content in MySQL database with:
$content = mysql_escape_string($content);
$insert = mysql_query("insert into $db_table_xml (url,content) values ('$url','$content')" );
//content type : TEXT in MySQL
simplexml_load_string($content);
it returns an error:
Warning: simplexml_load_string()
[function.simplexml-load-string]:
Entity: line 361: parser error :
AttValue: ' expected in
D:\mkw\dev\Web\PHPnow-1.5.6\htdocs\yt2\common.php
on line 84
Notice: Trying to get property of
non-object in
D:\mkw\dev\Web\PHPnow-1.5.6\htdocs\yt2\common.php
on line 146
Warning: Invalid argument supplied for
foreach() in
D:\mkw\dev\Web\PHPnow-1.5.6\htdocs\yt2\common.php
on line 146
This error means it is not valid xml, inspect the xml file to see if there is anything wrong with it.
Look for line 361 in it, there is probably special character or similar error
Edit.
Obviously when you escape the xml, you introduced invalid characters in your xml,
use.
$content_escape = mysql_escape_string($content);
$insert = mysql_query("insert into $db_table_xml (url,content) values ('$url','$content_escape')" ); //content type : TEXT in MySQL
now your $contents is not affected
Looks to me like your variable $content contains single quotes that are affecting the termination of the string. This is what your can do if this is the case:
$content= addslashes($content);
Then you write this into your record.