class automatically extended ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ehsanch
    New Member
    • Mar 2010
    • 11

    class automatically extended ?

    in end of nusoap.php io have this code:
    Code:
    if (!extension_loaded('soap')) {
    echo "not loaded";
            class [B]soapclient [/B]extends nusoap_client {}
    }
    else {
    echo "loaded";
            class [B]soap_client [/B]extends nusoap_client {}
    }
    $x = new soap_client;
    RESULT :
    not loaded
    Warning: Missing argument 1 for nusoap_client:: nusoap_client() , called in nusoap2.php on line 7996 and defined in nusoap2.php on line 7112
    line 7112 is first function of class nusoap_client.

    when i run ths script i get "not loaded" , mean extension not loaded. but class soap_client also will load !!! .
    in cli it will not load but in cgi it will load. so i think there is something in php.ini that cause class extend automatically.

    What is the cause for it ?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    I don't know NuSOAP very well, but PHP does have it's own soapclient class, and it appears that your code checks whether or not the extension containing that class is loaded or not, and if it isn't, assumes the soapclient class name for it's nusoap_client class.

    The warning is issued because, apparently, the nusoap_client class - which is extended your code on line #7 as soap_client - is being used on line #9, but the code fails to provide it with any parameters, and it seems it is expecting at least one. -- Note that this is just a warning. The code can go on without it being fixed. If you turn of the error messages it will be silenced. - However, it is usually best not to ignore warnings.

    Comment

    • ehsanch
      New Member
      • Mar 2010
      • 11

      #3
      Problem is that soap extension is not loaded and commands in else will not execute... but soap_client class will load!
      i must get an undefined class error.... but class exist!

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        If the class exists it is being defined somewhere, and if you are getting "not loaded" printed from the snipped above, it's not happening there. - It must be happening somewhere else in the code. Perhaps NuSOAP creates the "alias" earlier, when it creates the class itself?

        Comment

        • ehsanch
          New Member
          • Mar 2010
          • 11

          #5
          ... ...

          Comment

          • ehsanch
            New Member
            • Mar 2010
            • 11

            #6
            i create another simple php script :
            Code:
            <?php
            class newclass {
                public function newfunc() {
                    echo 'class exist';
                }
            }
            
            if (true) {
                class myclass1 extends newclass {}
            }
            else {
                class myclass2 extends newclass {}
            }
            
            $test = new myclass2;
            $test->newfunc();
            in browser i get
            class exist
            , but in cli i get
            Fatal error: Class 'myclass2' not found in test.php on line 15
            --------------------run with php vs php-cgi--------------------
            [root@server]# php test.php
            Fatal error: Class 'myclass2' not found in test.php on line 15

            [root@server]# php-cgi test.php
            X-Powered-By: PHP/5.2.6
            Content-type: text/html
            class exist

            im astonished!

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              That's odd.
              Using your code on my Ubuntu setup, I get this:
              atli@atli-desktop:~$ php /var/www/test/test.php
              Fatal error: Class 'myclass2' not found in /var/www/test/test.php on line 15
              atli@atli-desktop:~$ php-cgi /var/www/test/test.php
              X-Powered-By: PHP/5.2.10-2ubuntu6.4
              Content-type: text/html; charset=utf-8

              Fatal error: Class 'myclass2' not found in /var/www/test/test.php on line 15
              (Note the first one is a custom built version 5.3.1, but the second the php5-cgi package from the Ubuntu repositories.)

              I can't seem to find any configuration options that would cause this. PHP should not be defining the "myclass2" class in this code.

              Perhaps this was a bug that has now been fixed? Have you considered updating your PHP version? (You seem to be lagging a few versions behind.)

              Comment

              • ehsanch
                New Member
                • Mar 2010
                • 11

                #8
                i upgrade php to 5.2.13 and first it didnt solved ! but after refresh the page it solved suddenly !!!

                note that it worked before ... today i found this bug in a program that worked as expected for 1 year!

                very bad headache :(

                Comment

                • ehsanch
                  New Member
                  • Mar 2010
                  • 11

                  #9
                  i tested in another server with 5.2.6 version and work as expected on that server....
                  i didint find the cause of it!

                  Comment

                  • ehsanch
                    New Member
                    • Mar 2010
                    • 11

                    #10
                    Finally i found the cause after 1 full day.
                    this was because of XCache !
                    removing it solve problem.
                    hope save someones time...

                    Comment

                    • Atli
                      Recognized Expert Expert
                      • Nov 2006
                      • 5062

                      #11
                      Ahh ok. It had to be something like that. It just didn't make any sense :)

                      Glad you got it all worked out!

                      Comment

                      Working...