Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: CerealGuy on June 18th, 2014, 11:00 AM

Title: 'ViewRemote' not found or invalid function name
Post by: CerealGuy on June 18th, 2014, 11:00 AM
Code: [Select]
http://localhost:8080/wedge/index.php?action=viewremote;filename=latest-news.js
Kann den "main" Template block nicht finden.

Code: [Select]
http://localhost:8080/wedge/index.php?action=viewremote;filename=latest-news.js
2: call_user_func() expects parameter 1 to be a valid callback, function 'ViewRemote' not found or invalid function name
Datei: /var/www/wedge/index.php

Only appears sometimes, not sure when exactly :niark: Perhaps someone else has an idea?!
Title: Re: viewremote latest-news.js error
Post by: CerealGuy on December 1st, 2014, 03:32 PM
Looks like app/ViewRemote.php is sometimes not properly loaded :hmm:
Dont know why this happens only sometimes...
Title: Re: 'ViewRemote' not found or invalid function name
Post by: Nao on February 20th, 2015, 12:18 PM
Has anyone been getting this since...?

And more importantly, if you've been getting this: is it on a local (localhost, 127.0.0.1, etc.) server, or an actual, online server..?
Title: Re: 'ViewRemote' not found or invalid function name
Post by: CerealGuy on February 20th, 2015, 01:35 PM
Got it on my localhost and on an online server. But really can't reproduce it, it just happens sometimes. But if no one else ever got this error, perhaps it's my own fault?!
Title: Re: 'ViewRemote' not found or invalid function name
Post by: Nao on February 20th, 2015, 03:00 PM
I got it in the past too, but only locally, and not recently... I always assumed it was due to some weird thing done by an unexpected call to localhost. (For instance, trying to access a domain name that redirects to 127.0.0.1 might trigger errors in your local Wedge. That's the reason I made a recent fix to suppress a potential harmless error message.)
Title: Re: 'ViewRemote' not found or invalid function name
Post by: CerealGuy on December 19th, 2016, 04:36 PM
Still getting it, but low priority i guess. Nothing looks broken, just this odd error.
Title: Re: 'ViewRemote' not found or invalid function name
Post by: Nao on January 27th, 2017, 01:57 AM
Still unable to get 'why'.
And I'm not really ready to put an extra safeguard in index.php just to catch that specific error-- meaning it'd slow down EVERY single page by a few cycles. Meh!

Still, maybe if it's just during the debugging period...
Or, who cares.
Title: Re: 'ViewRemote' not found or invalid function name
Post by: Nao on January 27th, 2017, 01:12 PM
From what I could gather, the error is partly reproduceable by just deleting the /gz/app/ViewRemote.php file. Wedge will then re-create it, and in the same second (but is that BEFORE or AFTER it was created..?!), you'll get the error.
I did that about half an hour ago...
And then tried again, and it worked just fine, lol.

Still a mystery.
Title: Re: 'ViewRemote' not found or invalid function name
Post by: CerealGuy on January 28th, 2017, 04:55 PM
I can reproduce it if gz/app/ViewRemote.php is an empty file. Maybe this happens if file gets renewed and in the same moment you  try to access it? So file is still empty or something and you try to load the file?

What makes me wonder is that this only happens to ViewRemote. Never saw a similiar error with any other required files...

EDIT: I have a theory:
When we go to admin panel, we fire two ajax requests against ?action=viewremote
?action=viewremote;filename=current-version.js and
?action=viewremote;filename=latest-news.js

If ViewRemote isn't cached, wedge will try to create it very likely on the current-version.js request. But in the same time we will ask again for viewremote, maybe the file is already created, but not completed. So the first thread (current-version.js) is creating the file, but not finished. In the same time the second thread (latest-news.js) is trying to loadSource('ViewRemote'), loadSource checks if file exists (it exists) and then requires it. But it's empty or not done yet. So second thread will result in an error. So this could be kind of a race condition.
Title: Re: 'ViewRemote' not found or invalid function name
Post by: Nao on January 30th, 2017, 02:27 PM
Hmmmmm... That might actually explain it! I was thinking of exclusive locks but couldn't figure out why this would only happen with ViewRemote.
I'll give it a look.

:edit: I don't know... The first thing that gets called is copy(). Meaning the file SHOULD exist, in its entirety, by the time a second AJAX request is triggered. Of course it could still be unsuccessfully copied or something.
Title: Re: 'ViewRemote' not found or invalid function name
Post by: CerealGuy on January 30th, 2017, 08:29 PM
Quote from Nao on January 30th, 2017, 02:27 PM
Hmmmmm... That might actually explain it! I was thinking of exclusive locks but couldn't figure out why this would only happen with ViewRemote.
I'll give it a look.

:edit: I don't know... The first thing that gets called is copy(). Meaning the file SHOULD exist, in its entirety, by the time a second AJAX request is triggered. Of course it could still be unsuccessfully copied or something.
I don't know how copy() is exactly working. It's possible that the function first creates the file and then streams to it. Would make sense because you can use copy with network resources. So maybe it would already be an improvement if apply_plugin_mods does it manually. I think the file gets written on the fclose call to the disk, but i'm not sure about that.
Another option would be to set LOCK_EX with flock() until the file is completely written and minified, and then test on other requests if it can safely be acccessed with LOCK_SH. However, i don't know if those fopen + flock calls are imperformant? Also it's not possible to pass an file resource to require_once()..
Problem is, that it's a pain in the ass to test this thing. Don't know how to provocate this race condition.
If we are able to create a test for this, it shouldn't be too hard to fix.