[TYPO3-core] RFC: update wizard

Sebastian Kurfuerst sebastian at garbage-group.de
Sun Nov 13 16:33:22 CET 2005


Hi,
an update wizard was already discussed multiple times on this list, and
to me it seemed that we really need it for bigger changes, that's why I
implemented one.

The attached patch creates an update wizard for TYPO3, it adds it to the
install tool - section database analyser.

Functionality:

Every update consists of some simple steps:
     1. is update necessary?
     2. is some alternative information from the user needed?
     3. perform update


With the new API, it is very easy to create such an update, an example
follows below.

As an example, I implemented Michael's doktype "not in menu" conversion,
which uses only step (1) and (3), but step 2 is implemented in the API
as well.

all updates are added to
$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update'], so in our
example, the correct line for the doctype conversion is:
$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['notInMenu_doctype_conversion'] = 'tx_coreupdates_notinmenu';

The function called at first is "checkForUpdate", which returns 1 if an
update is needed and 0 if not. The description contains a description of
the update and is a pointer.

checkForUpdate($version, description)	 {
	$description = 'Removes the doctype "not in menu" which is deprecated and sets instead the flag "not in menu".';
	if($version >= 400)	{
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid','pages','doktype=5');
			if($GLOBALS['TYPO3_DB']->sql_num_rows($res))	{
				return 1;
			}
		}
		return 0;
	}
}

The update itself is defined like this:


	function performUpdate($version, $userInput, $dbQueries, $customMessages)	{
		if($version >= 400)	{
			$updateArray = array(
				'doktype' => 1,
				'nav_hide' => 1
			);

			$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'doktype=5', $updateArray);
			$dbQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
			if ($GLOBALS['TYPO3_DB']->sql_affected_rows($res))	{
				return 1;
			}
			return 0;	// zero rows affected, maybe error
		}
	}

This should be pretty self-explanatory. $dbQueries is a pointer which
needs to contain all DB queries made by the update function, and
$customMessages is a pointer through which custom messages can be set.




I am very curious to hear your thoughts about this!
Greets, Sebastian



-- 
Sebastian Kurfuerst
http://garbage-group.de/kontakt.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: updateWizard_v2.patch
Type: text/x-patch
Size: 8192 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20051113/d246e515/attachment.bin 


More information about the TYPO3-team-core mailing list