Update PHP version to 8.2 facing Issue with DomDocument

44 Views Asked by At

I am using php-dynamics-crm-2011(https://github.com/Rocketeer007/php-dynamics-crm-2011/tree/master) libaray to connect with the CRM365 and it's working as expected below PHP version 8.

In PHP8.2 when I tried to connect it through fatal error

Fatal error: Uncaught Exception: Serialization of 'DOMDocument' is not allowed, unless serialization methods are implemented in a subclass in [no active file]:0 Stack trace: #0 [internal function]: DOMNode->__sleep() #1 {main} thrown in [no active file] on line 0

When I further debug I found issue with the saveXML line. Below is the code

$securityDOM = new DOMDocument();
$securityDOM->loadXML($security_xml);

/* Get the two CipherValue keys */
$cipherValues = $securityDOM->getElementsbyTagName("CipherValue");
$securityToken0 = $cipherValues->item(0)->textContent;
$securityToken1 = $cipherValues->item(1)->textContent;

/* Get the KeyIdentifier */
$keyIdentifier = $securityDOM->getElementsbyTagName("KeyIdentifier")->item(0)->textContent;

/* Get the BinarySecret */
$binarySecret = $securityDOM->getElementsbyTagName("BinarySecret")->item(0)->textContent;

/* Make life easier - get the entire RequestedSecurityToken section */
$requestedSecurityToken = $securityDOM->saveXML($securityDOM->getElementsByTagName("RequestedSecurityToken")->item(0));
preg_match('/<trust:RequestedSecurityToken>(.*)<\/trust:RequestedSecurityToken>/', $requestedSecurityToken, $matches);
$requestedSecurityToken = $matches[1];

I have tried following code to get the token but it's not working as expected. Not return the expected XML string

dom = new DOMDocument();

// Load the XML string
$dom->loadXML($xmlString);

// Get the specific node
$specificNode = $dom->getElementsByTagName('node2')->item(0);

// Output the value of the specific node
echo "Value of specific node: " . $specificNode->nodeValue;
0

There are 0 best solutions below