Author Topic: Important hints from core-dev-team  (Read 42241 times)

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 2978
  • Gender: Female
Important hints from core-dev-team
« on: May 17, 2012, 12:38:57 AM »
Information only - Information only - Information only - Information only - Information only - Information only

This thread is used by the Core-Dev-Team to inform the Addon-Developers about changes and other important things concerning the core and the module interfaces.

This thread is read-only! Please do not answer and do not discuss here! Any answer will be deleted!

« Last Edit: October 02, 2014, 02:52:39 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf ihnen Hirn vom Himmel !

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 2978
  • Gender: Female
Deprecated List
« Reply #1 on: May 17, 2012, 01:16:07 AM »
This is a list of all things which are marked as deprecated or are invalid


  • (17) 2015-03 (from WB 2.8.4)
    Concerns: class WbDatabase and class mysql
    Deprecated: all of the Alias-methods and Alias-properties are set deprecated and will be removed in next version.
    Take care: do no more make use  of the method mysql::fetchRow() if you like to request an assoziated array. From next version the method will deliver a numeric array only (like the corresponding method in class mysqli_result).
  • (16) 2014-11 (from WB 2.8.4)
    Concerns: Handling of all Translation / Language files[/i]
    Deprecated: the complete handling, well known until WB-2.8.3 is set deprecated
    Replacement: use class Translate, witch controls and load all translation and also provides the translated replacements.
  • (15) 2014-11 (from WB 2.8.4)
    Concerns: all Addons like modules, tools, themes, templates and any witch uses an info.php
    Changes: each of the info.php files is set deprecated and will never work from 2014/06/01.
    Replacement: the new info.ini file. A detailed description about you can find in the WB-Wiki: Hello-World
  • (14) 2014-11 (from WB 2.8.4)
    Removed: from class frontend these methods are removed:
     -> prepocess() : this method is without functionality since Rev.1702 from 2012/08/27
     -> menu() and show_menu(): this methods are outdated. Use show_menu2() instead!
  • (13) 2014-11 (from WB 2.8.4)
    Changes: use and requesting of wb/config.php is deprecatet
    Replacement: request wb/framework/initialize.php instead
  • (12) 2013-12 (from WB 2.8.4)
    Changes: Inline javascript is deprecated in all HTML-Output
    Replacement:Use external javascript files. Use the DSP- Whitelist HTTP-Header to define allowed 3rd party scripts.
  • (11) 2013-12 (from WB 2.8.4)
    Changes: Most of all used global Constants are set deprecated now..
    Replacement: all of these values are accessible now by the WbAdaptor(future registry).
  • (10) 2013-12 (from WB 2.8.4)
    Changes: With view of PHP-5.4 the ini-setting of magic_quotes=on no longer is suportet.
    Replacement: change the php.ini file or add a _htaccess file to switch this setting to off.
  • (09) 2013-05 (from WB 2.8.4)
    Changes: The use of PHP function md5() for password hashing is set deprecated.
    Replacement: to hash and compare passwords use the methods hashPassword() and checkPassword from the class Password instead.
  • (08) 2013-02 (from WB 2.8.4)
    Changes: All of the language arrays, provided by the language files, are set deprecated. The whole handling of the language files, well known since the beginning of WB, is set deprecated.
    Replacement: All of the translations will be supported now completely by the class Translation. See Description for Translate-Packet(still in german only) for more detailed information about.
  • (07) 2012-12 (from WB 2.8.4)
    Statement: global database; is removed from core
    Replacement: use $database = WbDatabase::getInstance(); to get a valid database handle
  • (06) 2012-12 (from WB 2.8.4)
    Changes: the file config.php is replaced by setup.ini.php. See related post.
    All defined methods aliases are set deprecated.
  • (05) 2012-12 (from WB 2.8.4)
    Changes: Class WbDatabase. See related post. Lots of methods are set deprecated.
    Replacement: described in the linked post!
  • (04) 2012-05 (from rev.1690)
    Statement: global database; is set deprecated
    Replacement: use $database = WbDatabase::getInstance(); to get a valid database handle
  • (03) 2012-05 (from rev.1689)
    Statement: the class database is removed from core
    Replacement: use $database = WbDatabase::getInstance(); to get a valid database handle
  • (02) 2010
    Statement: concerning language files: $TEXT['MODULE']['TITLE'] is deprecated
    Replacement: $TEXT['MODULE_TITLE']
  • (01) 2010-11
    Statement: $database = new database();
    Replacement: use global $database; instead.
« Last Edit: April 04, 2015, 02:53:41 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf ihnen Hirn vom Himmel !

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 2978
  • Gender: Female
Class WbDatabase() [from rev. 1689]
« Reply #2 on: May 17, 2012, 02:21:13 AM »
The new class WbDatabase is a full replacement for the old class database.
Class database is never needed, and it's also not possible, to create multiple instances of this class to connect the same database.
the only one instance for use inside WB will be created and connected by the core.
Using everywhere in the code $database = WbDatabase::getInstance() will deliver a valid database handle.
With that handle you can use the object identical like the old class database. i.e. $database->query($sql);.

As a new feature you can use this class to connect a different database too.
To do so you need a connection URI like:
mysql://username:password@host[:port]/databasename
The argument for the port is optional if your mySQL server is listening on a port different from default(3306).
Warning: For security reasons do never store the access data in a global var or any constant!! This can be read from the template engine without problems!!
Code: (connection Example) [Select]
<?php

function anyFunction() {
    
$oPrivateDb WbDatabase::getInstance('myPrivateDb');
    
$oResult $oPrivateDb->doQuery('SELECT * FROM table');
    
// ...
}

$oPrivateDb WbDatabase::getInstance('myPrivateDb');
$oPrivateDb->doConnect('mysql://username:password@host[:port]/databasename');

// ... do all your code ... 
anyFunction();


WbDatabase::killInstance('myPrivateDb');

?>

Hint: Try to instantiate an old class database() will throw an exception!

New methods in WbDatabase:
(string) ::escapeLike(string $sText) -> escapes wildcards in LIKE arguments

New Methods in mysql:
(object) ::fetchObject(string $sClass = null, array $aParams = null)
(array) ::fetchAll(int $iType = MYSQLI_ASSOC)




« Last Edit: April 04, 2015, 02:32:46 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf ihnen Hirn vom Himmel !

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 2978
  • Gender: Female
Change from config.php into setup.ini.php [WB 2.8.4]
« Reply #3 on: May 17, 2012, 12:37:45 PM »
Important: For critical security reasons the old config.php is never in use from WB 2.8.4!

All configuration settings are stored now in the file setup.ini.php. For backward compatibility the old config.php will be used as simply forwarding to /framework/initialize.php for a short time.

The old global constants DB_TYPE, DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME are removed and also no longer available.

The new workflow is:
read the configuration -> instantiate and connect the default database object -> unset all database configuration vars.

The format/syntax of the new config file is a simple text file using the easy to understand 'ini' syntax.
No more PHP-codes or something else to take care for.

Here is an example for the new configuration file:
Code: (setup.ini.php) [Select]
;################################################
;<?php die('illegal file access'); ?>
;################################################
;
[Constants]
DEBUG  = true
AppUrl = "http://domain.tld/wb/"
AcpDir = "admin/"
;
[DataBase]
type    = "mysql"
user    = "dummyuser"
pass    = "my!secret"
host    = "localhost"
socket  = ""
port    = "3306"
name    = "mydatabase"
charset = "utf8"
table_prefix  = "wb_"
;
;################################################

In same pass the connect method of WbDatabase changes into the standard DSN style like:
Code: [Select]
<?php
doConnect
(string $sDsn ''string $sUser ''string $sPassword '', array $aAttributes = array()) : bool
?>
Attention: This changes first time will be published in version 2.8.4.
Also from this revision the installer and the upgrade script will handle the new formatting completely.
For the users there will be no difficult changes or special attention.

Important hint:
We've seen some code which includes the /config.php or /index.php in a circular manner. This is definitely NOT a desired kind of coding! We urgently ask all authors to correct their modules accordingly!!
WB-2.8.4 will NOT accept this kind of coding!!
« Last Edit: October 02, 2014, 11:16:17 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf ihnen Hirn vom Himmel !

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 2978
  • Gender: Female
Classes WbDatabase() / MySql() [from WB 2.8.4]
« Reply #4 on: December 12, 2012, 12:39:20 PM »
There are some changes done. This was needed for compatibility with the new coding standards of WB 2.8.4 and security reasons also.

The biggest, structural modification is to distribute the classes WbDatabase() and Mysql() in two different files and
add the class WbDatabaseException().

Changes in WbDatabase():
Some methods are renamed now. For a short deprecated period the old names still exists as aliases.

Table contains changes only!
New Methods Available Aliases  Deprecated Methods
doConnect()
doQuery()query()
getOne()get_one()
isField()field_exists()
addField()field_add()
modifyField()field_modify()
removeField()field_remove()
isIndex()index_exists()
addIndex()index_add()
removeIndex()index_remove()
escapeString()
importSqlSqlImport()
getTableEngine()
isError()is_error()
getError()get_error()
setError()set_error()
getLastInsertId()
New Properties    Available AliasesDeprecated Properties
DbHandlegetDbHandle, db_handle
DbNamegetDbName, db_name
QueryCountgetQueryCount
TablePrefixgetTablePrefix
LastInsertIdgetLastInsertId

Changes in mysql():
Some methods are renamed or aliased now. For a short deprecated period the old names still exists as aliases.

Table contains changes only!
New Methods Available Aliases  Deprecated Methods
freeResult()
rewind()
seekRow()
New Properties    Available AliasesDeprecated Properties

to be continued ...
« Last Edit: November 12, 2013, 11:59:31 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf ihnen Hirn vom Himmel !

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 2978
  • Gender: Female
Class WbAdaptor() [from WB 2.8.4]
« Reply #5 on: November 24, 2013, 06:36:02 PM »
It has been announced for quite some time...
Now, with the 'WB-2.8.4' it becomes implemented  step by step.

From WB-2.8.4 all of the global constants will be set to status 'deprecated'. Except a small number of special declared ones.

But from WB-2.8.4 the new class WbAdaptor is activated now. It's a preliminary stage of the future 'Registry' and provide valid replacements for all constants which are deprecated now. In the first step there you can find all the systembased constants. In future all the others too.

You can import this class from everywhere using  $oReg = WbAdaptor::getInstance();
To access a value simply request it with $value = $oReg->AppUrl; by example.

deprecated old Constantnew KeyExample content
WB_URL => AppUrl => http://example.com/wb/
WB_REL => AppRel => /wb/ (based on $_SERVER['DOCUMENT_ROOT'])
WB_PATH => AppPath => /var/www/htdocs/wb/
( c:/daten/www/htdocs/wb/ )
ADMIN_DIRECTORY => AcpDir => admin/
ADMIN_URL => AcpUrl => http://example.com/wb/admin/
ADMIN_REL => AcpRel => /wb/admin/ (based on $_SERVER['DOCUMENT_ROOT'])
ADMIN_PATH => AcpPath => /var/www/htdocs/wb/admin/
( c:/daten/www/htdocs/wb/admin/ )
DEFAULT_THEME => DefaultTheme => myTheme/
THEME_URL => ThemeUrl => http://example.com/wb/templates/myTheme/
THEME_REL => ThemeRel => /wb/templates/myTheme/ (based on $_SERVER['DOCUMENT_ROOT'])
THEME_PATH => ThemePath => /var/www/htdocs/wb/templates/myTheme/
( c:/daten/www/htdocs/wb/templates/myTheme/ )
DEFAULT_TEMPLATE => DefaultTemplate => myTemplate/
PAGES_DIRECTORY => PagesDir => pages/
MEDIA_DIRECTORY => MediaDir => media/
TMP_PATH => TempPath => /var/www/htdocs/wb/temp/
( c:/daten/www/htdocs/wb/temp/ )
DOCUMENT_ROOT => DocumentRoot => /var/www/htdocs/
( c:/daten/www/htdocs/ )
OCTAL_FILE_MODE => OctalFileMode => 420 = 0644 = 110100100 = rw-r--r--
OCTAL_DIR_MODE => OctalDirMode => 493 = 0755 = 111101101 = rwxr-xr-x
WB_VERSION => AppVersion => 2.8.4
WB_REVISION => AppRevision => 2060
WB_SP => AppServicePack => SP1
--- => AppName => WebsiteBaker

[still writing on it to complete...]

In next step, values depending on the current page or the current user, you can find this in the corresponding object.
« Last Edit: December 03, 2014, 12:25:18 AM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf ihnen Hirn vom Himmel !