fix some longstanding bugs and stamp out deprecation warnings

This commit is contained in:
Michael Becker 2025-12-04 19:17:31 -05:00
parent abcf832f47
commit 4bb5738075
3 changed files with 80 additions and 56 deletions

View File

@ -323,10 +323,10 @@
$this->resParser = \xml_parser_create (); $this->resParser = \xml_parser_create ();
\xml_parser_set_option($this->resParser, XML_OPTION_CASE_FOLDING, 0); \xml_parser_set_option($this->resParser, XML_OPTION_CASE_FOLDING, 0);
\xml_set_object($this->resParser, $this); // \xml_set_object($this->resParser, $this);
\xml_set_element_handler($this->resParser, "tagOpen", "tagClosed"); \xml_set_element_handler($this->resParser, $this->tagOpen(...), $this->tagClosed(...));
\xml_set_character_data_handler($this->resParser, "tagData"); \xml_set_character_data_handler($this->resParser, $this->tagData(...));
$this->strXmlData = \xml_parse($this->resParser, $input); $this->strXmlData = \xml_parse($this->resParser, $input);
if(!$this->strXmlData) if(!$this->strXmlData)
@ -336,7 +336,9 @@
die(sprintf("XML error: %s at line %d", $message, $lineNumber)); die(sprintf("XML error: %s at line %d", $message, $lineNumber));
} }
\xml_parser_free($this->resParser); if (PHP_VERSION_ID < 80000) {
\xml_parser_free($this->resParser);
}
return MarkupObjectModel::FromArray($this->mvarOutput); return MarkupObjectModel::FromArray($this->mvarOutput);
} }

View File

@ -621,7 +621,7 @@
return $_GET["virtualpath"]; return $_GET["virtualpath"];
} }
} }
return null; return "";
} }
public static function IncludeFile($filename, $isRequired) public static function IncludeFile($filename, $isRequired)
{ {
@ -882,6 +882,17 @@
*/ */
public static function ParsePathVariables(string $template, string $pathstr) public static function ParsePathVariables(string $template, string $pathstr)
{ {
if ($pathstr == "")
{
if ($template == "")
{
return [ ];
}
else
{
return false;
}
}
$l = strlen($template); $l = strlen($template);
$i = 0; $i = 0;
@ -1056,45 +1067,48 @@
} }
$path = System::GetVirtualPath(); $path = System::GetVirtualPath();
if (System::$Configuration["Runtime.DisableAutomaticExtensionParsing"] !== true) if (System::GetConfigurationValue("Runtime.DisableAutomaticExtensionParsing") !== true)
{ {
// strip path extension if there is one // strip path extension if there is one
$pathLast = $path[count($path) - 1]; if (count($path) > 0)
$ix = strripos($pathLast, ".");
if ($ix !== false)
{ {
$pathExt = substr($pathLast, $ix + 1); $pathLast = $path[count($path) - 1];
$path[count($path) - 1] = substr($pathLast, 0, $ix); $ix = strripos($pathLast, ".");
if ($ix !== false)
switch ($pathExt)
{ {
case "json": $pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
switch ($pathExt)
{ {
System::$WebPageFormat = WebPageFormat::JSON; case "json":
break;
}
case "xml":
{
System::$WebPageFormat = WebPageFormat::XML;
break;
}
case "html":
{
System::$WebPageFormat = WebPageFormat::HTML;
break;
}
case "js":
{
System::$WebPageFormat = WebPageFormat::JavaScript;
break;
}
default:
{
if ($path[count($path) - 1] != "")
{ {
$path[count($path) - 1] = $path[count($path) - 1]; System::$WebPageFormat = WebPageFormat::JSON;
System::Redirect("~/" . implode("/", $path)); break;
return; }
case "xml":
{
System::$WebPageFormat = WebPageFormat::XML;
break;
}
case "html":
{
System::$WebPageFormat = WebPageFormat::HTML;
break;
}
case "js":
{
System::$WebPageFormat = WebPageFormat::JavaScript;
break;
}
default:
{
if ($path[count($path) - 1] != "")
{
$path[count($path) - 1] = $path[count($path) - 1];
System::Redirect("~/" . implode("/", $path));
return;
}
} }
} }
} }
@ -1138,7 +1152,7 @@
if (!$success) if (!$success)
{ {
$retval = call_user_func(System::$ErrorEventHandler, new ErrorEventArgs("The specified resource is not available on this server. (" . (System::$EnableTenantedHosting ? ("Tenanted - " . System::GetTenantName()) : "Non-Tenanted") . ")<br />Path: " . $_GET["virtualpath"])); $retval = call_user_func(System::$ErrorEventHandler, new ErrorEventArgs("The specified resource is not available on this server. (" . (System::$EnableTenantedHosting ? ("Tenanted - " . System::GetTenantName()) : "Non-Tenanted") . ")<br />Path: " . (isset($_GET["virtualpath"]) ? $_GET["virtualpath"] : "")));
return false; return false;
} }
return true; return true;

View File

@ -59,12 +59,15 @@
{ {
$path = System::GetVirtualPath(); $path = System::GetVirtualPath();
// strip path extension if there is one // strip path extension if there is one
$pathLast = $path[count($path) - 1]; if (count($path) > 0)
$ix = strripos($pathLast, ".");
if ($ix !== false)
{ {
$pathExt = substr($pathLast, $ix + 1); $pathLast = $path[count($path) - 1];
$path[count($path) - 1] = substr($pathLast, 0, $ix); $ix = strripos($pathLast, ".");
if ($ix !== false)
{
$pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
}
} }
return System::ExpandRelativePath("~/" . implode("/", $path)); return System::ExpandRelativePath("~/" . implode("/", $path));
} }
@ -557,10 +560,10 @@
} }
$initializingEventArgs = new CancelEventArgs(); $initializingEventArgs = new CancelEventArgs();
$initializingEventArgs->RenderingPage = $renderingPage; // $initializingEventArgs->RenderingPage = $renderingPage;
$initializedEventArgs = new EventArgs(); $initializedEventArgs = new EventArgs();
$initializedEventArgs->RenderingPage = $renderingPage; // $initializedEventArgs->RenderingPage = $renderingPage;
if (method_exists($this, "OnInitializing")) if (method_exists($this, "OnInitializing"))
{ {
@ -941,10 +944,13 @@
if ($e->Cancel) if ($e->Cancel)
return; return;
if (method_exists($this->ClassReference, "OnPreRender")) if ($this->ClassReference != null)
{ {
$retval = $this->ClassReference->OnPreRender($e); if (method_exists($this->ClassReference, "OnPreRender"))
if ($e->Cancel) return; {
$retval = $this->ClassReference->OnPreRender($e);
if ($e->Cancel) return;
}
} }
$handled = false; $handled = false;
@ -1300,13 +1306,15 @@
} }
} }
if ($this->ClassReference != null)
if (method_exists($this->ClassReference, "RenderContents"))
{ {
ob_start(); if (method_exists($this->ClassReference, "RenderContents"))
$this->ClassReference->RenderContents($e); {
$tagBODY->Content = ob_get_contents(); ob_start();
ob_end_clean(); $this->ClassReference->RenderContents($e);
$tagBODY->Content = ob_get_contents();
ob_end_clean();
}
} }
$tagHTML->Controls[] = $tagBODY; $tagHTML->Controls[] = $tagBODY;