Ticket #572: database.patch

File database.patch, 4.4 kB (added by charlie, 3 months ago)

Patch to update all other database drivers to autoload result objects

  • system/libraries/drivers/Database/Mysqli.php

     
    226226        // autoloading is disabled to save a lot of stupid overhead. 
    227227        if ($this->fetch_type == 'fetch_object') 
    228228        { 
    229             $this->return_type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     229            $this->return_type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    230230        } 
    231231        else 
    232232        { 
     
    257257 
    258258                // NOTE - The class set by $type must be defined before fetching the result, 
    259259                // autoloading is disabled to save a lot of stupid overhead. 
    260                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     260                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    261261            } 
    262262            else 
    263263            { 
     
    271271 
    272272            if ($fetch == 'fetch_object') 
    273273            { 
    274                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     274                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    275275            } 
    276276        } 
    277277 
  • system/libraries/drivers/Database/Mssql.php

     
    392392        // autoloading is disabled to save a lot of stupid overhead. 
    393393        if ($this->fetch_type == 'mssql_fetch_object') 
    394394        { 
    395             $this->return_type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     395            $this->return_type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    396396        } 
    397397        else 
    398398        { 
     
    423423 
    424424                // NOTE - The class set by $type must be defined before fetching the result, 
    425425                // autoloading is disabled to save a lot of stupid overhead. 
    426                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     426                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    427427            } 
    428428            else 
    429429            { 
     
    437437 
    438438            if ($fetch == 'mssql_fetch_object') 
    439439            { 
    440                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     440                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    441441            } 
    442442        } 
    443443 
  • system/libraries/drivers/Database/Pdosqlite.php

     
    385385 
    386386        if ($this->fetch_type == PDO::FETCH_OBJ) 
    387387        { 
    388             $this->return_type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     388            $this->return_type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    389389        } 
    390390        else 
    391391        { 
     
    415415 
    416416                // NOTE - The class set by $type must be defined before fetching the result, 
    417417                // autoloading is disabled to save a lot of stupid overhead. 
    418                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     418                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    419419            } 
    420420            else 
    421421            { 
     
    429429 
    430430            if ($fetch == PDO::FETCH_OBJ) 
    431431            { 
    432                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     432                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    433433            } 
    434434        } 
    435435        try 
  • system/libraries/drivers/Database/Pgsql.php

     
    395395        // autoloading is disabled to save a lot of stupid overhead. 
    396396        if ($this->fetch_type == 'pg_fetch_object') 
    397397        { 
    398             $this->return_type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     398            $this->return_type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    399399        } 
    400400        else 
    401401        { 
     
    426426 
    427427                // NOTE - The class set by $type must be defined before fetching the result, 
    428428                // autoloading is disabled to save a lot of stupid overhead. 
    429                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     429                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    430430            } 
    431431            else 
    432432            { 
     
    440440 
    441441            if ($fetch == 'pg_fetch_object') 
    442442            { 
    443                 $type = class_exists($type, FALSE) ? $type : 'stdClass'; 
     443                $type = (is_string($type) AND Kohana::auto_load($type)) ? $type : 'stdClass'; 
    444444            } 
    445445        } 
    446446