[TYPO3-core] RFC: #1527: t3lib_svbase: Method init returns wrong value
Stefano Kowalke
blueduck at gmx.net
Sun Feb 1 12:30:52 CET 2009
Hi,
this is a SVN patch request.
Branches: 4.1, 4.2, trunk
Type: Bugfix
BT reference: http://bugs.typo3.org/view.php?id=1527
Problem:
The method t3lib_svbase::init() should, according to inline documentation
and usage in tslib_div::makeInstanceService() return a boolean value.
In case of an error the method returns the last error code instead of
boolean false. Using this default implementation as template results in
always signaling a service to be available.
Solution:
Change the last line to
return (true === $this->getLastError());
Notice:
To test this i installed cc_svauthdemo extension.
Goto the getLastError() function and put
array_push($this->error, array('nr'=>-2, 'msg'=>'T3_ERR_SV_NOT_AVAIL'));
right after the function head:
function getLastError() {
// for testing
array_push($this->error,
array('nr'=>-2, 'msg'=>'T3_ERR_SV_NOT_AVAIL'));
if(count($this->error)) {
$error = end($this->error);
return $error['nr'];
} else {
return TRUE; // means all is ok - no error
}
}
then i put dump_var() in class.t3lib_svbase.php around line 669. Here the
init() function:
function init() {
// do not work :-( but will not hurt
register_shutdown_function(array(&$this, '__destruct'));
// look in makeInstanceService()
$this->reset();
// check for external programs which are defined by
$info['exec']
if (trim($this->info['exec'])) {
if (!$this->checkExec($this->info['exec'])) {
// nothing todo here or?
}
}
// test the current output
var_dump($this->getLastError());
$result = ($this->getLastError() === true);
// test the fixed output
var_dump($result);
return $result;
}
If the function getLastError() returns 'true' and 'boolean' as type in
$result 'true' was stored, otherwise getLastError() gives the error number
(e.g. -2) and 'false' was stored.
Thanks a lot to Michael Miousse to share his knowledge about services in
TYPO3 and help me to figure out how i could test the patch.
Regards
Stefano
--
Seit dem 1.1.2008 werden Daten zu jeder E-Mail verdachtsunabhängig gespeichert!
Weitere Informationen: www.vorratsdatenspeicherung.de
GPG-ID: 0x2B08936D
Key-Fingerprint: 7F31 BCF0 70C0 B3B1 1235 07E9 1777 D7A0 2B08 936D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class.t3lib_svbase.php.diff
Type: text/x-diff
Size: 350 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090201/ce071833/attachment.diff
More information about the TYPO3-team-core
mailing list