SimplePortal

Development => Bugs => Fixed or Bogus Bugs => Topic started by: AngelinaBelle on June 15, 2009, 10:19:41 PM

Title: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 15, 2009, 10:19:41 PM
I thought my problem was "Standalone portal Fatal error: Call to undefined function: sportal_init()", but I think I'm chasing down some bad install problems.

SMF 1.1.9 (from 1.1.8 )
Colorized Membergroups 1.0
Custom Profile Field Mod 3.20
Custom BBCode 2.00
SimplePortal 2.2.2

The install seemed to go fine.  Sportal1-1.php is in Sources, right where it is supposed to be, and contains the function sportal_init.

I decided to start with the forum in standalone mode while we look into transitioning from the current site front page to the portal. 

I'm not getting any complaints about "Failed opening required", so I assume it succeeds in opening SPortal1-1.php.  So why can't it find it?

I'm getting
Quote
Fatal error: Call to undefined function: sportal_init() in /<smf directory>/SPStandalone.php on line 50

And then I discovered that the edits never got made to SSI.php.  I manually made the SSI.php edits.  And, guess what? it seems to load SPortal1-1.php and get sportal_init().  But now I'm getting out-of-memory errors when I load SPportal.php

The out-of-memory error seems to occur in sp_image_resize;, sometimes at var possible_images = document.getElementsByTagName("img"); and sometimes at window_oldSPImageOnload();

Subs.php seems appropriately modified.  None of the other php's should be involved, right?  Did I do the manual edit incorrectly?

I've attached SSI.php.

Thanks for any advice.
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 15, 2009, 11:48:19 PM
Here's something else odd I just realized.  At http://rockhallsailingclub.org/smf/SPStandalone.php, $context['html_headers'] is output twice.  $context['html_headers']  is set in sportal_init (in SPortal1-1.php), but I haven't figured out where it is echoed.  Or why it is echoed twice.  Is this a red herring or not?
Code: [Select]
<link rel="stylesheet" type="text/css" href="http://rockhallsailingclub.org/smf/Themes/default/portal.css?22rc1" />
<!--[if lt IE 7]>
<script defer type="text/javascript" src="http://rockhallsailingclub.org/smf/Themes/default/sp_pngfix.js"></script>
<![endif]-->
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var sp_images_url = "http://rockhallsailingclub.org/smf/Themes/default/images/sp";
function sp_collapseBlock(id)
{
mode = document.getElementById("sp_block_" + id).style.display == "" ? 0 : 1;
smf_setThemeOption("sp_block_" + id, mode ? 0 : 1, null, "218794d1531f3f01b0af5efff0006a14");
document.getElementById("sp_collapse_" + id).src = smf_images_url + (mode ? "/collapse.gif" : "/expand.gif");
document.getElementById("sp_block_" + id).style.display = mode ? "" : "none";
}
function sp_collapseSide(id)
{
var sp_sides = new Array();
sp_sides[1] = "sp_left";
sp_sides[4] = "sp_right";
mode = document.getElementById(sp_sides[id]).style.display == "" ? 0 : 1;
smf_setThemeOption(sp_sides[id], mode ? 0 : 1, null, "218794d1531f3f01b0af5efff0006a14");
document.getElementById("sp_collapse_side" + id).src = sp_images_url + (mode ? "/collapse.png" : "/expand.png");
document.getElementById(sp_sides[id]).style.display = mode ? "" : "none";
}
var window_oldSPImageOnload = window.onload;
window.onload = sp_image_resize;
function sp_image_resize()
{
var possible_images = document.getElementsByTagName("img");
for (var i = 0; i < possible_images.length; i++)
{
if (possible_images[i].className != "sp_article")
continue;

var temp_image = new Image();
temp_image.src = possible_images[i].src;

if (temp_image.width > 300)
{
possible_images[i].height = (300 * temp_image.height) / temp_image.width;
possible_images[i].width = 300;
}
else
{
possible_images[i].width = temp_image.width;
possible_images[i].height = temp_image.height;
}
}

if (typeof(window_oldSPImageOnload) != "undefined" && window_oldSPImageOnload)
{
window_oldSPImageOnload();
window_oldSPImageOnload = null;
}
}
// ]]></script>

Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: ???1031 on June 16, 2009, 12:55:03 AM
Normla only the index.template.php output the $context['html_header']; Hmmm i think i must look if this really happen =).
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 16, 2009, 09:09:52 AM
Normla only the index.template.php output the $context['html_header']; Hmmm i think i must look if this really happen =).
Thanks for offering to look at this.  Should I attach any other files?
 
Here's something else I just noticed.  At http://rockhallsailingclub.org/smf/SPStandalone.php (http://rockhallsailingclub.org/smf/SPStandalone.php), and also at http://rockhallsailingclub.org/smf/index.php (http://rockhallsailingclub.org/smf/index.php),
the bit about shrinkHeaderIC(mode) is in there twice, in slightly different versions, but I don't think this is the source of my out-of-memory problem.
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 16, 2009, 12:08:13 PM
I followed up on this a bit, and I've come to the conclusion that the out of memory problem is due to recursion in sp_image_resize caused by a problem in the way window.onload is handled, in the doubled "sp_image_resize" section in http://rockhallsailingclub.org/smf/SPStandalone.php (http://rockhallsailingclub.org/smf/SPStandalone.php)
 
The problem is that, effectively, two functions that need to execute at window.onload time are using the same global variable to store their "old_window_onload" information.  One calls the other, and recursion results.  Not only that, the two functions have the same name.
 
Here's the gist of it:
1) window.onload is null
2) window_oldSPImageOnload gets set to window.onload (null)
   window.onload gets set to sp_image_resize
3) window_oldSPImageOnload gets set to window.onload (sp_image_resize)
    window.onload gets set to sp_image_resize
4) window_oldOnload gets set to window.onload (sp_image_resize)
    window.onload gets set to smf_codeFix
5) After the page loads, window.onload (=smf_codeFix) is executed
6) smf_codeFix  calls window_oldOnload() (=sp_image_resize)
7) sp_image_resize calls window_oldSPImageOnload (=sp_image_resize)
8) sp_image_resize calls window_oldSPImageOnload (=sp_image_resize)
 
And the recursion begins  -- the code never has a chance to come to the part where it sets window_oldSPImageOnload to null.
 
Here is some breakpoint action, and the 3 onload variables at each point:
Code: [Select]
window_oldSPimageOnload -- null
 window.onload -- null
 window_oldOnload -- undefined
44  var window_oldSPImageOnload=window.onload
 window_oldSPimageOnload -- null
 window.onload -- null
 window_oldOnload -- undefined
45  window.onload=sp_image_resize
 window_oldSPimageOnload -- null
 window.onload -- sp_image_resize
 window_oldOnload -- undefined
99 var window_oldSPImageOnload = window.onload;
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- sp_image_resize
 window_oldOnload -- undefined
100 var window_oldSPImageOnload = window.onload;
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- sp_image_resize
 window_oldOnload -- undefined
742 var window_oldOnload = window.onload;
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- sp_image_resize
 window_oldOnload -- sp_image_resize
743 window.onload = smf_codeFix;
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codeFix
 window_oldOnload -- sp_image_resize
755 (window_oldOnload)
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codeFix
 window_oldOnload -- sp_image_resize
757 window_oldOnload();    is sp_image_resize
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
124 (window_oldSPImageOnload)
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
126 window_oldSPImageOnload      is sp_image_resize
 
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
69 (window_oldSPImageOnload)
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
71 window_oldSPImageOnload();                   is sp_image_resize
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
69 (window_oldSPImageOnload)
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
71 window_oldSPImageOnload                    --- sp_image_resize
 window_oldSPimageOnload -- sp_image_resize
 window.onload -- smf_codefix
 window_oldOnload -- sp_image_resize
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)
69 (window_oldSPImageOnload)

(repeat until out of memory error)
 
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 16, 2009, 12:18:03 PM
(Two lengthy posts are awaiting moderation above.)
 
I just discovered that switching to the CORE theme, rather than the board default (slightly modified) theme causes the problem to go away.  -- no memory error, no doubled sections.
 
This means the problem could be in my RHSC theme.

Themes/default/index.template.php seems to have been properly edited by the automatic install.  But these edits did not happen in Themes/RHSC/index.template.php.  So I guess I'll have to work through that by hand.
 
I have set up a test account at
http://rockhallsailingclub.org/SPstandalone.php (http://rockhallsailingclub.org/SPstandalone.php)
 

Manual editing was a partial success.  Now, I have gotten rid of the parts that were duplicated in the forum page, but which are not responsible for the memory error problem.  Plus, I've got all the navigation buttons I was supposed to have.  So that's important.
 
But on the standalone portal page, I still have the duplication of the sp_image_resize block, and the out of memory error that comes with it.
 
Of the files sportal lists in Themes/default, index.template.php is the only one I have in Themes/RHSC.  So I'm almost certain this is the problem file.  Am I missing something obvious?
 
Thanks for any advice
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: ???1031 on June 17, 2009, 03:30:50 PM
Can i see the site with the double entries?

Hmmm i looked at the theme and i think everything is done correct, at my first look...

Oh i see it now... i was blind... hmmm *testing*, so i can confirm this is a bug... i will see if there is a way to fix it...

Ah first fix is:
Code: (search for) [Select]
if (!empty($context['template_layers']) && !in_array('portal', $context['template_layers']))
$context['template_layers'][] = 'portal';

Code: (Replace with) [Select]
if (!empty($context['template_layers']) && !in_array('portal', $context['template_layers']))
$context['template_layers'][] = 'portal';

// The function is one time loaded.
$initialized = true;
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: [SiNaN] on June 17, 2009, 04:55:22 PM
I don't have net access ATM, posting this from my phone. I'll check this myself after 20th. This will fix your js issue until then:

SPortal(1-1|2).php
Find:
$modSettings['sp_resize_images'] = true;
Replace:
$modSettings['sp_resize_images'] = false;
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 17, 2009, 08:48:18 PM
Thanks for the advice!  That ought to keep things for a while.  I guess the problem is in index.template.php, but I just haven't found it.
 
I just realized that the problem happens when I use IE8 in compatability mode, but not if I turn compatability mode off.  The the php generates a different set of js for the onload event in the two cases.
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 17, 2009, 09:50:13 PM
I decided it would be easier to find and fix the problem if I started with a clean copy of the Default theme-- the one that works.  So I did that, using "Create a copy of Default named:"  Then, as soon as I applied the theme, I got the error. I hadn't modified the new theme at all.
 
This makes me think the problem is not in template.index.php, but in another file altogether.  Puzzling!
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 18, 2009, 12:03:30 PM
Sportal_init concatenates that stuff to $context['html_headers'] twice. 
 
It appears that sportal_init is called twice.  The second call to sportal_init is in SPstandalone.php. 
 
The first call to sportal_init is in SSI.php.
 
I think this is the source of my problem.  Is there a reason for SPstandalone.php to call sportal_init a second time?  If so, can you introduce some flags sportal_init to use to figure out if it has already done the $context['html_headers'] stuff?
 
I see that sportal_init has a static variable $initialized to do just that.  It is checked for empty, but it is never set.
 
Should it be set in the if (empty($initialized)) block?   $initialized=True, right at the top of the block seems to fix that problem.
 
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: ???1031 on June 19, 2009, 04:33:29 AM
http://simpleportal.net/index.php?topic=2613.msg17295#msg17295
That what the fix do ;).
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 19, 2009, 07:08:23 AM

Oh i see it now... i was blind... hmmm *testing*, so i can confirm this is a bug... i will see if there is a way to fix it...

Code: (search for) [Select]
   if (!empty($context['template_layers']) && !in_array('portal', $context['template_layers']))
      $context['template_layers'][] = 'portal';

Code: (Replace with) [Select]
   if (!empty($context['template_layers']) && !in_array('portal', $context['template_layers']))
      $context['template_layers'][] = 'portal';
   
   // The function is one time loaded.
   $initialized = true;
Yes, that's exactly the fix I made to sportal_init.  It means that, the second time through, sportal_init will skip adding all that stuff to $context['html_headers'].  And it did solve my problem.
 
I am still mildly curious why, even before the fix, I did not have the problem when I used Theme/Default.  There may be something else going on there.
 
But my problem is fixed.  Except, of course, for those running ie8 browsers -- the onload event can't run, because SMF doesn't recognize ie8 and SimplePortal does the wrong onload event for the sp_image_resize. But that's a different topic!
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: [SiNaN] on June 21, 2009, 06:17:49 AM
Setting the $initialized variable to true was missing only for SMF 1.1 versions. Moved to the bug reports.

I'll check the other issue later.
Title: Re: install problem (SSI.php) and out of memory error in SPStandalone.php javascript
Post by: AngelinaBelle on June 21, 2009, 10:22:14 PM
I think the IE8 issue is a feature of SMF 1.1
http://www.simplemachines.org/community/index.php?topic=318651.0 (http://www.simplemachines.org/community/index.php?topic=318651.0)
 
Thanks for verifying my problem as a bug.  I'm happy with simpleportal.  It is simple to use now.
SimplePortal 2.3.8 © 2008-2024, SimplePortal