No Code Attached Yet bug
avatar heelc29
heelc29
24 Mar 2023

Steps to reproduce the issue

enable debug mode

Expected result

Only one debug bar should be present

Actual result

Two debug bars are present
image

System information (as much as possible)

J4.3.0-rc1 (Atum Template)

Additional comments

I've already found out that it has something to do with the guided tours model

<button type="button" class="dropdown-item text-center" data-bs-toggle="modal" data-bs-target="#modGuidedTours-modal">

add the mobile status menu

if (strpos($out, 'data-bs-toggle="modal"') !== false) {
$dom = new \DOMDocument();
$dom->loadHTML('<?xml encoding="utf-8" ?>' . $out);
$els = $dom->getElementsByTagName('a');
$moduleCollapsedHtml[] = $dom->saveHTML($els[0]); //$els[0]->nodeValue;
} else {
$moduleCollapsedHtml[] = $out;
}

Output:

<div class="header-dd-item dropdown-item" data-item="1">
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <?xml encoding="utf-8" ?>
    <html>
        <body>
            <div class="header-item-content dropdown header-tours d-none d-sm-block">
                <button class="dropdown-toggle d-flex align-items-center ps-0 py-0" data-bs-toggle="dropdown" type="button" title="Take a Tour">
                    <div class="header-item-icon">
                        <span class="icon-map-signs" aria-hidden="true"></span>
                    </div>
                    <div class="header-item-text">
                        Take a Tour        
                    </div>
                    <span class="icon-angle-down" aria-hidden="true"></span>
                </button>
                <div class="dropdown-menu dropdown-menu-end">
                    <button type="button" class="button-start-guidedtour dropdown-item" data-id="3">
                        <span class="icon-map-signs" aria-hidden="true"></span>How to create articles?
                    </button>
                    [...]
                    <button type="button" class="dropdown-item text-center" data-bs-toggle="modal" data-bs-target="#modGuidedTours-modal">
                        Show all tours
                    </button>
                </div>
            </div>
        </body>
    </html>
</div>

As you can see, the div elements contain a second body node which probably causes this behavior.

echo str_replace('</body>', $debugBarRenderer->renderHead() . $debugBarRenderer->render() . '</body>', $contents);

avatar heelc29 heelc29 - open - 24 Mar 2023
avatar joomla-cms-bot joomla-cms-bot - change - 24 Mar 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 24 Mar 2023
avatar obuisard
obuisard - comment - 24 Mar 2023

In trying to replicate the issue, all seems alright under PHP 7.4 or 8.0.
All gets loose on PHP 8.1 and higher.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40185.

avatar heelc29
heelc29 - comment - 25 Mar 2023

In trying to replicate the issue, all seems alright under PHP 7.4 or 8.0. All gets loose on PHP 8.1 and higher.

@obuisard I can also reproduce in PHP 7.2 and 8.0
image
image

avatar Fedik
Fedik - comment - 25 Mar 2023

I cannot reproduce it on php 8.1
What "DOM/XML API Version" and "libxml Version" your php have? Maybe it something from that.

DOM/XML API Version: 20031129
libxml Version: 2.9.14
avatar Fedik
Fedik - comment - 25 Mar 2023

I found, that it related to DOMDocument behavior https://www.php.net/manual/en/domdocument.savehtml.php#85165
We probably should avoid it here, somehow.

avatar Fedik Fedik - change - 25 Mar 2023
Labels Added: bug
avatar Fedik Fedik - labeled - 25 Mar 2023
avatar heelc29
heelc29 - comment - 25 Mar 2023

What "DOM/XML API Version" and "libxml Version" your php have? Maybe it something from that.

dom version
DOM/XML API Version 20031129
libxml Version 2.9.12

image

avatar Fedik
Fedik - comment - 25 Mar 2023

@heelc29 Can you please try change the code to

if ($els[0]) {
  $moduleCollapsedHtml[] = $dom->saveHTML($els[0]); //$els[0]->nodeValue;
}

Whether it works for you?

I think I found, that when element not found it export whole Document

avatar joomdonation
joomdonation - comment - 25 Mar 2023

@Fedik Yes, that seems to fix the issue. But anyone really understands what we are trying to do with this block of code https://github.com/joomla/joomla-cms/blob/4.3-dev/administrator/templates/atum/html/layouts/status.php#L30-L38 ? In case the a tag is not found, should we add module output to $moduleCollapsedHtml array, something like ?

if ($els->length > 0) {
	$moduleCollapsedHtml[] = $dom->saveHTML($els[0]); //$els[0]->nodeValue;
} else {
	$moduleCollapsedHtml[] = $out;
}
avatar Fedik
Fedik - comment - 25 Mar 2023

No, that will not work, or maybe will, no idea :)
That code is extracting bootstrap toggler in this strange way, and skipping it if there is none.

avatar joomdonation
joomdonation - comment - 25 Mar 2023

Yes, strange/buggy code. Seems it wants to find a tag which has data-bs-toggle="modal". If found, only add a tag to $moduleCollapsedHtml, if not, add the whole module output to $moduleCollapsedHtml array, but who knows :)

Anyway, your code fixed the reported issue. So please make PR.

avatar brianteeman
brianteeman - comment - 25 Mar 2023

iirc that is for the mobile views

avatar heelc29
heelc29 - comment - 25 Mar 2023

But anyone really understands what we are trying to do with this block of code

I think it's used for the multilangstatus module ... to not add the $modalHTML twice (normal and collapsed)

<a data-bs-target="#multiLangModal" class="header-item-content multilanguage" title="<?php echo Text::_('MOD_MULTILANGSTATUS'); ?>" data-bs-toggle="modal" role="button">
<div class="header-item-icon">
<span class="icon-language" aria-hidden="true"></span>
</div>
<div class="header-item-text">
<?php echo Text::_('MOD_MULTILANGSTATUS'); ?>
</div>
</a>
<?php echo $modalHTML; ?>

avatar Fedik Fedik - close - 25 Mar 2023
avatar Fedik
Fedik - comment - 25 Mar 2023

Please test #40194

avatar Fedik Fedik - change - 25 Mar 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-03-25 14:59:26
Closed_By Fedik

Add a Comment

Login with GitHub to post a comment