php (wordpress) - server not respond to file changes - php

I'm facing weird problem which a bit complicated to understand. So the situation is that:
we have 2 installs (actually more, but not relevant for now)
both installs places on same server (apache + nginx)
we update our code and therefore deploy to staging - first install works great, second one has problem.
the code is 100% percent the same
there is no influence of other plugin (wordpress) on the specific part of code
The relevant code is the following:
$track = new trackClass();
$track->store_parameters();
$parameters = unserialize($track->parameters);
class trackClass // this class sits on different file
{
public $parameters;
public function __construct() {
...
}
method...
method...
method ..
public function store_parameters()
{
...
}
}
Before we modify our code, the function store_parameters was private, now its public.
So when on the second install the code is running its raise an error that the store_paramters() function is private and not accessible (remind you that it happens only on the second install).
I tried another thing get_class_methods($track) and the response was all the methods except the store_parameters(). Again - weird.
Next step, put wp_die('test') in the top of the file of the class. Refreshing the page and all as usual (the file is definitely loaded). If I try to access the admin (wp-admin) the changes make difference - the page is killed, blank screen and 'test' on it.
Next step, remove this file completely from the server. Refreshing the page and nothing happen. Their is ajax request from the class file which run as usual, like the file is exists and everything is ok. Again, going to the admin page and the error is raised (require_once ... not found).
Its doesn't seems like its code or development problem. The code is same. I'm afraid that its something on the server side / environment (apache, nginx) but unfortunately I've no access to the linux, I only can chat with the support of the hosting company.
They are insists that is code problem. No matter the tests I wrote above.
What can cause this kind of problem? I'm losing my mind here with no lead, its like the file is stuck somewhere.

Related

I can not addimage to ad revive server

I want to upload ad image to ad revive server, when i create or update d banner.
when i click to save changes page will response the The connection time out.
.
I try to change the file permissions 0755 to 0777. but sill i can upload/change ad image.
Log Output (debug.log):
May 13 21:15:36 +0000 OX-5af8aaf8338bc [ warning] Declaration of HTML_QuickForm_file::_findValue() should be compatible with HTML_QuickForm_element::_findValue(&$values)
I can't understand the above log output.
Please help me to understand and debug.
Thanks
The warning you paste is because the class being used is overriding a static function _findValue, and declares it differently than the parent class.
You can get rid of that warning by changing the line in the child class (probably given by the warning: "in file... at line...") from
public (or protected) static function _findValue() {
to
public (or protected) static function _findValue(&$values) {
As for what is causing the timeout, I'm afraid there are just too many possibilities. Try inspecting the communication using Firefox or Chrome Web Developer Tools, see whether anything comes up.
Failing that, you'd need to debug the server, either by using a developer setup (IDE plus remote debugger, say XDebug or Zend) or the old fashioned, plodding way by inserting die() statements along the execution path. Both require some experience and some time. If you've never done it, I'm afraid you need to find someone who can.

CodeIntel with PHP in Sublime Text 2 not working

I am trying for 2 hours now to get SublimeCodeIntel working with PHP. Well, some things work, but CodeIntel doesnt autocomplete class methods and parameters when outside of the class.
I use Sublim Text 2 for Windows (7) and the last version of the plugin.
I have a class Page in classes/Page.php, and a index.php.
In index.php:
$page = new Page('home',$_GET['page']);
And when I type
$page->
I can read in taskbar "Info: processing 'PHP': Please Wait" for a few seconds and then nothing happens.
When working in Page.php, I can start typing $this->.. and it somewhat works (actually it doesnt show functions parameters).
Same with Alt+clicking on functions and variables (only works if they are defined in the current file)
I tried several things:
1/ Deactivating "detect_slow_plugins" (error message doesn't appear anymore, but the plugin is not working better)
2/ Changing SublimeCodeIntel.sublime-settings config (copy paste the whole file and editing values):
"codeintel_language_settings": {
"PHP": {
"php": "E:/wamp/bin/apache/Apache2.2.21/bin",
"codeintel_scan_extra_dir": [],
"codeintel_scan_files_in_project": true,
"codeintel_max_recursive_dir_depth": 15
}
}
I don't even know if the "php" value is important (I found several snippets on the internet)...
3/ Same thing in Sublim Text User settings
4/ Re-building indexes as advised here
I use an PHP autoloader and I don't get how the plugin knows for sure which file defines which class. Could be an issue ?
I am completely stuck here, I tried everything I found, and read some setup tutorials (each one of them being something like "install and it just works!"... very annoying).
Does anyone have a solution? Or something to check, or try...
Thanks!

Kohana can't find template on the server, but it works fine on localhost

I'm working out the kinks in the deployment of my webapp in development, but I've finally hit one I can't figure out on my own.
I have a post-commit hook in my svn that deploys all of my commits to a staging site, to ensure nothing breaks before I push to production. Thus, assuming my local working copy has no pending commits, localhost and staging have identical files.
Right now, my localhost works perfectly fine (the codebase isn't complete, but that's an entirely separate issue). On my staging site, however, I get the following exception from Kohana framework:
View_Exception [ 0 ]: The requested view index.tpl could not be found
If I manually visit the uris for my other controllers, I get the same message, with the template filename substituted. Following the stack trace, the error is occurring in the before function of the View factory, when the framework attempts to load my template file -- as expected.
My views directory (and all the files contained therein) has the same permissions as all of the other directories in my project, so I'm not sure why PHP wouldn't be able to read the directory or the files. I've also confirmed that the files do in fact exist on the server.
My error log shows nothing; my access log shows a 500 error. The Kohana logfile shows the same information that appears on-screen.
I'm genuinely confused as to why this is happening. The framework is obviously functioning, as I'm getting Kohana's formatted exception and the Kohana log is being written to. The autoloader is finding my controller classes, because the "missing" file changes appropriately as I visit my various controllers which use different templates. But the server's behavior doesn't match my localhost, and I'm left scratching my head.
After looking at Kohana::find_file, the method that's returning false, I came to the conclusion that Kohana was looking for index.tpl.php. I added some trace debugging to confirm, and I was correct: on my localhost, Kohana is looking for views\index.tpl while on my server, it's looking for views/index.tpl.php. However, a second oddity appeared, which may explain the first. Here is the full list of files that find_file tries to look for when loading up my index page on my local machine and my server:
LOCAL: SERVER:
classes\I18n.php classes/I18n.php
classes\Kohana\I18n.php classes/Kohana/I18n.php
classes\HTTP.php classes/HTTP.php
classes\Kohana\HTTP.php classes/Kohana/HTTP.php
classes\Kohana\Exception.php classes/Kohana/Exception.php
classes\Kohana\Kohana\Exception.php classes/Kohana/Kohana/Exception.php
classes\Log.php classes/Log.php
classes\Kohana\Log.php classes/Kohana/Log.php
classes\Config.php classes/Config.php
classes\Kohana\Config.php classes/Kohana/Config.php
classes\Log\File.php classes/Log/File.php
classes\Kohana\Log\File.php classes/Kohana/Log/File.php
classes\Log\Writer.php classes/Log/Writer.php
classes\Kohana\Log\Writer.php classes/Kohana/Log/Writer.php
classes\Config\File.php classes/Config/File.php
classes\Kohana\Config\File.php classes/Kohana/Config/File.php
classes\Kohana\Config\File\Reader.php classes/Kohana/Config/File/Reader.php
classes\Kohana\Config\Reader.php classes/Kohana/Config/Reader.php
classes\Kohana\Config\Source.php classes/Kohana/Config/Source.php
classes\Route.php classes/Route.php
classes\Kohana\Route.php classes/Kohana/Route.php
classes\Cookie.php classes/Cookie.php
classes\Kohana\Cookie.php classes/Kohana/Cookie.php
classes\Session.php classes/Session.php
classes\Kohana\Session.php classes/Kohana/Session.php
classes\Request.php classes/Request.php
classes\Kohana\Request.php classes/Kohana/Request.php
classes\HTTP\Request.php classes/HTTP/Request.php
classes\Kohana\HTTP\Request.php classes/Kohana/HTTP/Request.php
classes\HTTP\Message.php classes/HTTP/Message.php
classes\Kohana\HTTP\Message.php classes/Kohana/HTTP/Message.php
classes\HTTP\Header.php classes/HTTP/Header.php
classes\Kohana\HTTP\Header.php classes/Kohana/HTTP\Header.php
classes\Request\Client\Internal.php classes/Request/Client/Internal.php
classes\Kohana\Request\Client\Internal.php classes/Kohana/Request/Client/Internal.php
classes\Request\Client.php classes/Request/Client.php
classes\Kohana\Request\Client.php classes/Kohana/Request/Client.php
classes\Arr.php classes/Arr.php
classes\Kohana\Arr.php classes/Kohana/Arr.php
classes\Response.php classes/Response.php
classes\Kohana\Response.php classes/Kohana/Response.php
classes\HTTP\Response.php classes/HTTP/Response.php
classes\Kohana\HTTP\Response.php classes/Kohana/HTTP/Response.php
classes\Profiler.php classes/Profiler.php
classes\Kohana\Profiler.php classes/Kohana/Profiler.php
classes\Controller\Home.php classes/Controller/Home.php
classes\Controller\HFTemplate.php classes/Controller/HFTemplate.php
classes\Controller\Template.php classes/Controller/Template.php
classes\Kohana\Controller\Template.php classes/Kohana/Controller/Template.php
classes\Controller.php classes/Controller.php
classes\Kohana\Controller.php classes/Kohana/Controller.php
classes\View.php classes/View.php
classes\Kohana\View.php classes/Kohana/View.php
classes\Smarty\View.php
config\smarty.php
classes\Config\Group.php
classes\Kohana\Config\Group.php
vendor\smarty/libs/Smarty.class.php
classes\URL.php
classes\Kohana\URL.php
classes\Smarty\Helper.php
classes\Kohana\Smarty\Helper.php
views\index.tpl views/index.tpl.php
classes\Auth.php
classes\Kohana\Auth.php
config\auth.php
classes\Auth\ORM.php
classes\Kohana\Auth\ORM.php
config\session.php
classes\Session\Database.php
classes\Kohana\Session\Database.php
classes\Database.php
classes\Kohana\Database.php
config\database.php
classes\Database\PDO.php
classes\Kohana\Database\PDO.php
classes\DB.php
classes\Kohana\DB.php
classes\Database\Query\Builder\Select.php
classes\Kohana\Database\Query\Builder\Select.php
classes\Database\Query\Builder\Where.php
classes\Kohana\Database\Query\Builder\Where.php
classes\Database\Query\Builder.php
classes\Kohana\Database\Query\Builder.php
classes\Database\Query.php
classes\Kohana\Database\Query.php
classes\Database\Result\Cached.php
classes\Kohana\Database\Result\Cached.php
classes\Database\Result.php
classes\Kohana\Database\Result.php
classes\ORM.php
classes\Kohana\ORM.php
classes\Model.php
classes\Kohana\Model.php
classes\Model\User.php
classes\Model\Auth\User.php
classes\Inflector.php
classes\Kohana\Inflector.php
config\inflector.php
classes\UTF8.php
classes\Kohana\UTF8.php
classes\Model\Role.php
classes\Model\Auth\Role.php
classes/View/Exception.php
classes/Kohana/View/Exception.php
classes/Debug.php
classes/Kohana/Debug.php
classes/Date.php
classes/Kohana/Date.php
views/kohana/error.php
classes/Text.php
classes/Kohana/Text.php
(page content) (exception page content)
classes\Database\Query\Builder\Update.php
classes\Kohana\Database\Query\Builder\Update.php
There is a gap where the system ought to be getting the Smarty module classes, but isn't. After seeing this, I confirmed that the Smarty module does in fact exist on the server and that it's enabled in Kohana's bootstrap. Yet it isn't being loaded. Any ideas?
As it turns out, the root of the issue was case-sensitivity on Linux. I arrived at this conclusion with the help of the module author on his GitHub repository. I assume he will fix this error in the repository in the near future, however, the fix was changing the names of 4 files:
MODPATH/smarty/classes/view.php to View.php
MODPATH/smarty/classes/Smarty/view.php to View.php
MODPATH/smarty/classes/Smarty/helper.php to Helper.php
MODPATH/smarty/classes/Kohana/Smarty/helper.php to Helper.php

Laravel's Response::json() returns nothing to the client under HHVM

I have HHVM running on a virtualbox VM, with the webroot mapping to my local laravel install, being served out at an internal IP.
Locally, I'm serving the site out under http://[localhost]:8000.
The codebase is identical.
code of MembersController.php (resourceful controller):
public function show($id)
{
$member = Member::findOrFail($id);
$data = array();
$data['id'] = $member->id;
$data['first_name'] = $member->first_name;
$data['last_name'] = $member->last_name;
return Response::json($data);
}
Assuming everything is working normally:
When I run a GET request to LOCALHOST: http://[localhost]:8000/api/v1/member/1, the client returns the JSON as normal - all good.
When I run a GET request to HHVM (same client, identical codebase): http://[vm_ip_address]/api/v1/member/1, the client receives no data.
The data is being passed back through the calls within HHVM though, as if I change the 'return' to 'echo', the payload is returned in both cases (headers also)
It looks like HHVM is affecting with laravel's Response::json() function and disallowing the reply contents from being displayed in the client.
Has anyone else seen this?
This is not something I can set up a unit test for, as it always passes, because the final reply always has data in it :/
Any input would be great - I'm interested to learn how to get around this.
Thanks.
Sadly you're probably going to have to get your hands dirty debugging. HHVM probably has a very slight difference in how it does something which this code-path is sensitive to. We pass 100% of laravel unit tests, but there probably isn't one covering this case.
If you can, please trace down the code to where the data changes. Put in echos and error_logs until you can build a very small test case then then open an issue on github and we'll get it fixed.

Is it possible to dynamically reload PHP code while script is running?

I'm having a multiplayer server that's using PHPSockets, and thus is written entirely in PHP.
Currently, whenever I'm making any changes to the PHP server-script I have to kill the script and then start it over again. This means that any users online is disconnected (normally not a problem because there aren't so many at the moment).
Now I am rewriting the server-script to use custom PHP classes and sorten things up a little bit (you don't want to know how nasty it looks today). Today I was thinking: "Shouldn't it be possible to make changes to the php source without having to restart the whole script?".
For example, I'm planning on having a main.php file that is including user.php which contains the class MyUser and game.php which contains the class MyGame. Now let's say that I would like to make a change to user.php and "reload" the server so that the changes to user.php goes into effect, without disconnecting any online users?
I tried to find other questions that answered this, the closest I got is this question: Modifying a running script and having it reload without killing it (php) , which however doesn't seem to solve the disconnection of online users.
UPDATE
My own solutions to this were:
At special occations, include the file external.php, which can access a few variables and use them however it'd like. When doing this, I had to make sure that there were no errors in the code as the whole server would crash if I tried accessing a method that did not exist.
Rewrite the whole thing to Java, which gave me the possibility of adding a plugin system using dynamic class reloading. Works like a charm. Bye bye PHP.
Shouldn't it be possible to make changes to the php source without having to restart the whole script?
[...]
I'm planning on having a main.php file that is including user.php
which contains the class MyUser
In your case, you can't. Classes can only be defined once within a running script. You would need to restart the script to have those classes redefined.
I am not too familiar with PHP but I would assume that a process is created to run the script, in doing so it copies the instructions needed to run the program and begins execution on the CPU, during this, if you were to "update" the instructions, you'd need to kill the process ultimate and restart it. Includes are a fancy way of linking your classes and files together but ultimately the processor will have that information separate from where the file of them are stored and it is ultimately different until you restart the process.
I do not know of any system in which you can create code and actively edit it and see the changes while that code is being run. Most active programs require restart to reload new source code.
Runkit will allow you to add, remove, and redefine methods (among other things) at runtime. While you cannot change the defined properties of a class or its existing instances, it would allow you to change the behavior of those objects.
I don't recommend this as a permanent solution, but it might be useful during development. Eventually you'll want to store the game state to files, a database, Memcache, etc.
How about storing your User object into APC cache while your main script loads from the cache and checks every so often for new opcode.
To include a function in the cache, you must include the SuperClosure Class. An example would be:
if (!apc_exists('area')) {
// simple closure
// calculates area given length and width
$area = new SuperClosure(
function($length, $width) {
return $length * $width;
}
);
apc_store('area', $area);
echo 'Added closure to cache.';
} else {
$func = apc_fetch('area');
echo 'Retrieved closure from cache. ';
echo 'The area of a 6x5 polygon is: ' . $func(6,5);
}
See here for a tutorial on APC.
Simple solution use $MyUser instead of MyUser
require MyUserV1.php;
$MyUser = 'MyUserV1';
$oldUser = new $MyUser('your name');
//Some time after
require MyUserV2.php;
$MyUser = 'MyUserV2';
$newUser = new $MyUser('your name');
Every declared class stay in memory but become unused when the last MyUserV1 logout
you can make them inherit from an abstract class MyUser for using is_a
You cannot include again a file with the same class, but you can do so with an array. You can also convert from array to class, if you really need to do so. This only applies to data, though, not to behavior (methods).
I don't know much about these things with the games on PC but you can try to get all the variables from your database for the user and then update the text fields or buttons using those variables
In web is using AJAX (change data without refreshing the page).Isn't one for programming?

Categories