PHP - LDAPHelper Class not found - php

I've finished a web site that runs on my computer and on the old server. The problem is that the old server is dying and my employer wanted to move it to a new server.
When he moved it, one web page shows me an error:
The autoloader expected class "Equips\FrontendBundle\Helper\LDAPHelper" to be defined in file "/var/www/sinfratic_dev/src//Equips/FrontendBundle/Helper/LDAPHelper.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
and it's like "what?" because I haven't done anything of that part (I just worked with another part of the web). And I've checked that file and inside there is the class "LDAPHelper".
I know what a server LDAP is, but I don't know if that problem is because the new server cannot communicate with out LDAP server or it doesn't have all things installed (I've installed ldap-auth-client, ldap-auth-config, libaprutil1-ldap, libldap-2.4-2, libldap2-dev, libnss-ldap, libpam-ldap and php5-ldap; things that were on the old server but not in the new, but it still doesn't work).
Any idea?
Thanks you so much.
EDIT
Thanks for the comment. Here is the header of the file:
<?
namespace Equips\FrontendBundle\Helper;
class LDAPHelper {

Ok, it was PHP and something unexpected.
By default, short_open_tag is off, so this .php could not be readed properly.
Just needed to put it on in php.ini.

Related

Issue with the implementation of the simplesamlphp library into my web application

I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.

OpenX: Moved to different Server

I moved the installation to a different server. I updated the configfile in the var/ directory and the banners are served, but the admin interface is not working.
i get the error:
A fatal error occurred OpenX can't connect to the database. Because of
this it isn't possible to use the administrator interface
i cleaned the cache directory in var but then i get
PHP Fatal error: Call to undefined method MDB2_Error::quoteIdentifier() in /[path]/opx/lib/OA/Upgrade/VersionController.php on line 50
I dont know which version this is, but it looks like its at least 2 years old.
Is there any special cache in place im not aware of?
Any help on this would be much appreciated.
Mental note,.. if you have the db on a different server then openx it does not matter if you set the host to the ip of the db server and the port.. as long if you not set protocol=protocol !!!
this is by far the most stupidest thing i have ever seen, there is no need for a protocol config, as php always uses the socket if you set "localhost".
It's not easy to tell exactly what's wrong here, but one can make a good guess:
As we can see from the error message, there is an object in your code that doesn't implement the method quoteIdentifier().
There are mainly two possible reasons for this: Either we're calling an older or newer version of the same Class instance which doesn't implement the method. Maybe because it's deprecated or who knows. Or the object simply isn't of the expected type.
Lo and behold, if we look for an MDB2 related class that DOES implement this method, it's the class MDB2. Not MDB2_Error! So now we know the reason for the error, it's time to speculate about the root cause.
Connecting to a database with MDB2 works roughly like this:
$mdb2 =& MDB2::connect('pgsql://usr:pw#localhost/dbnam');
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
There it is. We can see that $mdb2 can actually be of type MDB2_Error, in case connecting goes wrong for some reason. So that is the cause: Your code cannot connect to the DB for some reason. So the next obvious step should be checking if your db user has the correct rights and is using the correct password. I am 100% sure your admin backend doesn't use the right credentials.

Cannot use X as Y because the name is already in use, even though it's not

I'm using PHP 5.4, and have a PSR-0 class structure similar to the following.
A\Library\Session.php:
namespace A\Library;
class Session { ... }
My\Application\Session.php:
namespace My\Application;
class Session { ... }
My\Application\Facebook.php:
namespace My\Application;
use A\Library\Session;
class Facebook { ... }
When I try to run the application, I get the following error:
Cannot use A\Library\Session as Session because the name is already in use in My\Application\Facebook.php
Even though it's not, at least not in this file. The Facebook.php file declares only the Facebook class, and imports exactly one Session class, the A\Library one.
The only problem I can see is that another Session class exists in the same namespace as the Facebook class, but as it was never imported in the Facebook.php file, I thought it did not matter at all.
Am I wrong (in that case please point to the relevant documentation), or is this a bug?
There is a bug confirmed in PHP that may affect the behavior you see. It is supposed to fatal error, but with opcache enabled, it may still execute flawlessly.
https://bugs.php.net/bug.php?id=66773
If it still concerns you, please vote for the bug.
No, this is not a bug. As mentioned in Using namespaces: Aliasing/Importing
use A\Library\Session;
is the same as:
use A\Library\Session as Session;
So try using something like:
use A\Library\Session as AnotherSessionClassName;
The only problem I can see is that another Session class exists in the
same namespace as the Facebook class, but as it was never imported in
the Facebook.php file, I thought it did not matter at all.
Yes, it does matter. This is why you don't need to "import" classes from the same namespace. If you have conflicting names from different namespaces, you need to alias the class.
namespace My\Application;
use A\Library\Session as ASession; // choose a proper alias name here
class Facebook { ... }
I've read the thread about the issue, but I tested on many PHP versions (php 5.5, 5.6, 7.*, x32, x64, vc11, vc14, vc5). I'm using Laravel with Laragon. But, when I build up the server with php artisan serve (and open the server at http://localhost:8000) I have the problem of "the namespace that some Class was already used" and stuff.
I tested with and without opcache extension and nothing works, then I tested the virtual domain that Laragon provides and... voila, the error just disappeared and now I can work OK. I don't know what was happening, my namespaces were OK, I had an alias but the same code works in many machine without problem (AWS, local, prod, dev, etc) but only in my machine I had the problem just as I described it.
So, if someone is working with Laravel (5.1) and is having this issue, try the virtual host of Laragon.

PHP Fatal error: Class not found

I am getting Class 'Splash\\SiteBundle\\Util\\Resize' not found when running my app on prod. This does not happen on dev.
Here is the code from the error:
$resize = new \Splash\SiteBundle\Util\Resize($this->getAbsolutePath());
I have a file called Splash\SiteBundle\Util\Resize.php with this namespace
namespace Splash\SiteBundle\Util;
Class Resize{ ... }
Any thoughts?
So the quick fix is to add this include dirname(__FILE__) . "/../Util/Resize.php"
I am not sure why my production machine would need the include while my dev machine works fine without it. Using Symfony2 and the autoloader I have never needed to include a file. Not sure whats goin on but this get me past it for now
One of the possible thing that could lead this to happen could ne not cleared cache
php app/console cache:clear -e prod
Another stupid thought could be that production has merge conflicts within that file and PHP doesn't see the class compiled.
I love when its the little things. My util folder was not capitalized. I changed this and it works now. I'm surprised my dev machine did not fail w this error.

Zend Framework: Model class not found

The following exception is thrown on my server:
Fatal error: Class 'My_Model_Bo_User_Agenda_Doctors' not found in...
Though in localhost everything is working fine.
I checked that everything was correctly uploaded; all the files are present and not corrupted. I also tried to upload several times. So this doesn't seem to be the problem.
Any idea why a class couldn't be found on the server ?
You don't say so in your question, but I suspect that you are developing on windows and hosting on Linux.
Windows is not case sensitive to path names, but Linux is! Check that:-
Doctors.php is not doctors.php
Agenda/ is not agenda/ .etc
Lastly check the class name in the class declaration is correct and correctly cased.
Do not just think to yourself, yes I've done that, go and check them carefully. Believe me, bitter experience has taught me this problem is always due to a trivial oversight like this.

Categories