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 ();
\xml_parser_set_option($this->resParser, XML_OPTION_CASE_FOLDING, 0);
\xml_set_object($this->resParser, $this);
\xml_set_element_handler($this->resParser, "tagOpen", "tagClosed");
// \xml_set_object($this->resParser, $this);
\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);
if(!$this->strXmlData)
@ -336,7 +336,9 @@
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);
}

View File

@ -621,7 +621,7 @@
return $_GET["virtualpath"];
}
}
return null;
return "";
}
public static function IncludeFile($filename, $isRequired)
{
@ -882,6 +882,17 @@
*/
public static function ParsePathVariables(string $template, string $pathstr)
{
if ($pathstr == "")
{
if ($template == "")
{
return [ ];
}
else
{
return false;
}
}
$l = strlen($template);
$i = 0;
@ -1056,45 +1067,48 @@
}
$path = System::GetVirtualPath();
if (System::$Configuration["Runtime.DisableAutomaticExtensionParsing"] !== true)
if (System::GetConfigurationValue("Runtime.DisableAutomaticExtensionParsing") !== true)
{
// strip path extension if there is one
$pathLast = $path[count($path) - 1];
$ix = strripos($pathLast, ".");
if ($ix !== false)
if (count($path) > 0)
{
$pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
switch ($pathExt)
$pathLast = $path[count($path) - 1];
$ix = strripos($pathLast, ".");
if ($ix !== false)
{
case "json":
$pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
switch ($pathExt)
{
System::$WebPageFormat = WebPageFormat::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] != "")
case "json":
{
$path[count($path) - 1] = $path[count($path) - 1];
System::Redirect("~/" . implode("/", $path));
return;
System::$WebPageFormat = WebPageFormat::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::Redirect("~/" . implode("/", $path));
return;
}
}
}
}
@ -1138,7 +1152,7 @@
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 true;

View File

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