Webmastersite.net
Register Log In

Random Links Malfunction

Comments on Random Links Malfunction

Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
Posted Apr 03, 2005 - 6:07 PM:

Today I tried adding a toplist that displays 8 random links, and appears on a variety of pages on my site. It worked fine on most pages, but whenever I went to a link details page, the toplist displayed the link of the details page that I was on 8 times. I went to a few other link details pages, and each time, it showed 8 of that link instead of random links.

Here's the toplist code I used:
<CONFIG>links,rand(),8,ascending,,,4,0,0,0,0</CONFIG>

Thanks,
Adam
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Apr 04, 2005 - 8:27 AM:

Link details pages are within the scope of links variables. Thus any links toplist on that page will show the link data for the page rather than the toplist.
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
Posted Apr 04, 2005 - 8:32 AM:

Why would this operator change based on the page it is on? Shouldn't it be consistant throughout the entire site? It seems strange (and not very useful) to have a rand() operator that doesn't work on all pages, especially since I'm specifically asking for a random link.

I'm basically trying to show random links at the bottom of most of my pages (Random Picks of the Day), but I can't do because the rand() variable isn't working on all pages.

Is there any way to get around this, or put in place some sort of mod that allows rand() to work on all pages?

Adam
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
Posted Apr 05, 2005 - 10:34 AM:

I managed to find a workaround that does the job. I use static file generation using this link:

www.gamelinks.com/exporter....?number[1]=8&field[1]=rand()&ascdesc[1]=descending&type[1]=links&template=javascript_export2

and saving to this link:

randomgames.js

All was working good until WSN Links automatically updated the static files. When it updated, it left randomgames.js as a 0 byte file. When I update manually, it works every time, but for some reason when it does it automatically, it doesn't work.

Any ideas?

Adam
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Apr 05, 2005 - 7:14 PM:

It has nothing to do with rand(). I would expect that no links toplists would work on the link details page, since it would be a template variable conflict.
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
Posted Apr 06, 2005 - 9:48 AM:

All was working good until WSN Links automatically updated the static files. When it updated, it left randomgames.js as a 0 byte file. When I update manually, it works every time, but for some reason when it does it automatically, it doesn't work.


The past 3 times WSN automatically updated the static HTML files, the above worked once and failed twice. Both times it failed and created a 0-byte file it was during the noon static html update, and it successfully created the file only during the midnight update. Would there be any reason for this? Could a visitor be accessing that file during the exact time it's updating it cause a problem? I don't see why it works sometimes and not all the time.

Adam
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
Posted Apr 06, 2005 - 10:02 PM:

I ran a few more tests. It was just a coincidence that it worked at night and didn't during the day update, because this time around (at night), one of my files didn't create properly.

Here's what my static file generation page looks like:

www.gamelinks.com/exporter....?number[1]=8&field[1]=rand()&ascdesc[1]=descending&type[1]=links&template=javascript_export2
www.gamelinks.com/exporter....?number[1]=8&field[1]=rand()&ascdesc[1]=descending&type[1]=links&template=javascript_export2
www.gamelinks.com/rssfeed.p...cending&thecondition=type='regular'&title=GameLinks.com

randomgames.js
randomgamestest.js
rss/new-games.xml

During tonights automatic 12 hour static file update, the first one (randomgames.js) ended up as a 0 byte file, while the second (randomgamestest.js) generated properly. By looking at the time stamps, it tried (unsuccessfully) to create randomgames.js first, and then created randomgamestest.js afterwards successfully. The RSS file has always generated properly.

It looks as if WSN Links is coming across something when generating these files that causes it to malfunction. Sometimes it works, sometimes it doesn't. When I generate manually, it works every time, so there appears to be something different going on when it generates automatically every 12 hours.

My javascript_export2.tpl is this:

<!-- BEGIN TOPLIST 10 -->
<CONFIG>links,rand(),8,ascending,,,4,0,0,0,0</CONFIG>
<td width="80" valign="top" align="center" class=<? if (({NUMBER} % 2) == 0) echo "bg1"; else echo "bg2"; ?>>
<strong>
<a href="link.php?action=detail&id={LINKID}">
<img src="http://www.gamelinks.com/thumbnails/{LINKGAMEICON}" name="icon" width="80" height="69" alt="{LINKTITLE}" style="background-color: #0066FF; border:1px solid #000"><br>
<font color="#FFFFFF">{LINKBOOKMARKTITLE}</font></a>
</strong>
</td>
<!-- END TOPLIST 10 -->


Any ideas? I really want to keep this functionality on my site but can't if I have to keep manually updating it.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Apr 08, 2005 - 9:20 AM:

Syonezeer wrote:
Could a visitor be accessing that file during the exact time it's updating it cause a problem?


It's a necessity, PHP can't run without a visitor. A visitor stoping the page load before it completes could cause a problem though, I suppose.

Since rss is a subdirectory, are you sure the main directory doesn't have a chmod issue?
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
Posted Apr 08, 2005 - 10:06 AM:

No directory chmod issues. I moved them to the javascript directory yesterday (which is 777) and the .js files are 666.

One thing I noticed today is that it generated one of the two files successfully, then a few minutes later that file was a 0 byte file, right before my eyes. Perhaps it's not closing the file correctly, causing it to end up a 0 byte file after a few minutes? Or it's not ending the routine properly? This would explain why the manual works fine and the automatic has problems (if they are indeed running a different subroutine).

Whatever it is, I think it's sucking up a lot of system resources. When it automatically ran today, it crashed my Apache after slowing my server down. It never does that when I do it manually, but when it runs automatically, that's when the problems occur. And I run the manual at busy times, so I don't think it's because of too much traffic.

Another thing I noticed (maybe a coincidence), is that whatever order I put those two files to be generated, the first one generally fails, and the 2nd one is generated correctly.

Unfortunately, I'm going to have to disable this function for my site until/if this problem is fixed.

EDIT: Here's apparently what was going on with my server when it was running the static file generations:

Apr 8 11:55:00 Hawkeye: CRITICAL load 17 - killing unneeded services

The main things taking up the load were Apache and MySQL processes. Pretty much the only PHP I'm running is the site running WSN Links, and that time is when the static file generation runs. Would using the rand() function with lots of links possibly cause this sort of high load?

Thanks,
Adam
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#10 - Quote - Permalink
Posted Apr 09, 2005 - 11:17 PM:

Again, rand() has no relation to anything. Static generation of any sort is likely to cause a high load during the time it generates. The more of them you do at once, the longer it takes and the more likely people are to not let the page fully load which could cause it to have to try again with the next person increasing the load, I suppose.
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
#11 - Quote - Permalink
Posted Apr 10, 2005 - 8:23 AM:

Again, rand() has no relation to anything. Static generation of any sort is likely to cause a high load during the time it generates. The more of them you do at once, the longer it takes and the more likely people are to not let the page fully load which could cause it to have to try again with the next person increasing the load, I suppose.


What would be the difference then doing it automatically as opposed to doing it manually? When I do it manually, it's done quickly and never has a problem. When it does it automatically, that's when there are problems. Also, when it does it automatically, it's doing it at 1am in the morning. There's not a lot of traffic at that time to the site. When I do it manually, I've done it during the busiest times of the day without a glitch.

It was not working when I had just 2 static files being generated. And it always had problems with the same files, the ones that I was trying to create a set of random links. Would just 2 be enough to overload the system?

Is there some other way I can have these automatically generated other than the way they are now, since the current way doesn't appear to work well with my site?

Thanks,
Adam
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#12 - Quote - Permalink
Posted Apr 10, 2005 - 7:21 PM:

If it does it quickly manually, there really shouldn't be a difference. I did just work through a bunch of issues with javascript static generation with someone a few weeks ago though, so is this 3.15 you're using?
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
#13 - Quote - Permalink
Posted Apr 10, 2005 - 7:29 PM:

I'm using 3.14. I didn't want to update yet because there were several things you fixed for me that weren't added to 3.15 yet.

I'm using static file generation to create a .js file, rather than using the javascript export to create it, because I want to use a different template for this file than what the other javascript exports are using, which static file generation let's me do.
Synozeer
Forum Regular

Usergroup: Customer
Joined: Jun 02, 2004

Total Topics: 32
Total Comments: 142
#14 - Quote - Permalink
Posted Apr 14, 2005 - 6:20 AM:

Just updated to the most recent version, but that didn't fix it.

Is there any way we can choose multiple templates with the javascript export function? The only reason I'm using static file export for this is because I need to use a separate template than what I'm using for my other javascript exports.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#15 - Quote - Permalink
Posted Apr 14, 2005 - 11:10 PM:

It occours to me that using the static export there causes a double URL grabbing, since it grabs exporter.php which in turn grabs the url of a custom template that'd create the toplist needed. Try grabbing it more directly to bypass half of that load, by using
index.php?custom=yes&TID=custom-thetemplate&usewrapper=no&allyourtoplistparamaters
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.