From: <ja...@us...> - 2007-04-27 05:40:48
|
Revision: 16354 http://svn.sourceforge.net/gallery/?rev=16354&view=rev Author: jablko Date: 2007-04-26 22:40:46 -0700 (Thu, 26 Apr 2007) Log Message: ----------- Fix PHP warning on install. Review #218 Fix PHP warning by appending stack trace HTML to an array, rather than concatenating to a string. Check that $templateData is initialized as array() everywhere, for better style. Fix one instance. Modified Paths: -------------- trunk/gallery2/install/steps/DatabaseSetupStep.class trunk/gallery2/install/steps/InstallCoreModuleStep.class trunk/gallery2/install/steps/InstallOtherModulesStep.class trunk/gallery2/install/templates/DatabaseSetupRequest.html trunk/gallery2/install/templates/InstallCoreModuleError.html trunk/gallery2/install/templates/InstallOtherModulesRequest.html trunk/gallery2/install/templates/InstallOtherModulesSuccess.html Modified: trunk/gallery2/install/steps/DatabaseSetupStep.class =================================================================== --- trunk/gallery2/install/steps/DatabaseSetupStep.class 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/steps/DatabaseSetupStep.class 2007-04-27 05:40:46 UTC (rev 16354) @@ -19,10 +19,11 @@ */ /** - * Setup Database + * Setup Database. * @package Install */ class DatabaseSetupStep extends InstallStep { + function stepName() { return _('Database Setup'); } @@ -284,7 +285,7 @@ _('Could not execute the required API to drop the Gallery database tables' . '. Please clean the Gallery database manually.'); $templateData['databaseErrors'] = $gallery->getDebugBuffer(); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); $gallery->clearDebugBuffer(); } else { $dbCleaned = true; @@ -444,8 +445,7 @@ } /** - * Execute a series of SQL statements - * + * Execute a series of SQL statements. * @param string $buffer the SQL statements * @param string $tablePrefix prefix for table names * @return array(boolean success, string error message) @@ -515,8 +515,7 @@ } /** - * Get the state and the version of the Gallery database - * + * Get the state and the version of the Gallery database. * @param array $metaTables the meta tables info array from the database * @return string the db version */ Modified: trunk/gallery2/install/steps/InstallCoreModuleStep.class =================================================================== --- trunk/gallery2/install/steps/InstallCoreModuleStep.class 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/steps/InstallCoreModuleStep.class 2007-04-27 05:40:46 UTC (rev 16354) @@ -19,10 +19,11 @@ */ /** - * Install core module + * Install core module. * @package Install */ class InstallCoreModuleStep extends InstallStep { + function stepName() { return _('Install Gallery Core'); } @@ -37,6 +38,8 @@ $template->renderHeader(true); $template->renderStatusMessage(_('Installing the core module'), null, 0); + $templateData = array(); + /* We want to log all debug output in our install log */ global $gallery; $gallery->setDebug('logged'); @@ -55,7 +58,7 @@ $gallery->debug(sprintf('Error: Unable to initialize our Gallery data, this is the ' . 'error stack trace: %s', $ret->getAsText())); $templateData['errors'][] = _('Unable to initialize our Gallery data'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } $this->_addSystemInformationToDebugLog(); @@ -64,8 +67,8 @@ GalleryDataCache::setFileCachingEnabled(false); /* - * Delete anything in the cache, which can be left around if we're - * installing on top of an older install. + * Delete anything in the cache, which can be left around if we're installing on top of an + * older install */ $platform =& $gallery->getPlatform(); $gallery->debug('Clear the cache directory'); @@ -85,10 +88,9 @@ if (empty($templateData['errors'])) { $gallery->debug('Check if the persistent storage is installed'); /* - * Check to see if the database tables already exist. If they do then - * we should assume that they said that it was ok to reuse existing tables - * in the Database setup step, which means we don't have to perform an - * install now. + * Check to see if the database tables already exist. If they do then we should assume + * that they said that it was ok to reuse existing tables in the database setup step, + * which means we don't have to perform an install now. */ $storage =& $gallery->getStorage(); list ($ret, $isInstalled) = $storage->isInstalled(); @@ -96,7 +98,7 @@ $gallery->debug(sprintf('Error: Unable to communicate with the database, this ' . 'is the error stack trace; %s', $ret->getAsText())); $templateData['errors'][] = _('Unable to communicate with the database'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } } @@ -108,7 +110,7 @@ $gallery->debug(sprintf('Error: Unable to load the core module, this ' . 'is the error stack trace; %s', $ret->getAsText())); $templateData['errors'][] = _('Unable to load the core module'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } } @@ -118,7 +120,7 @@ $freshInstall = $galleryStub->getConfig('freshInstall'); if ($freshInstall) { $gallery->debug('Hand over admin user parameters'); - /* It's a fresh install. Hand over install config parameters */ + /* It's a fresh install. Hand over install config parameters. */ $gallery->setConfig('setup.admin.userName', $galleryStub->getConfig('setup.admin.userName')); $gallery->setConfig('setup.admin.email', @@ -136,7 +138,7 @@ $gallery->debug(sprintf('Error: Unable to install the core module, this ' . 'is the error stack trace; %s', $ret->getAsText())); $templateData['errors'][] = _('Unable to install the core module'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } else { $gallery->debug('Core module installed successfully'); } @@ -151,7 +153,7 @@ $gallery->debug(sprintf('Error: Unable to activate the core module, this ' . 'is the error stack trace; %s', $ret->getAsText())); $templateData['errors'][] = _('Unable to activate the core module'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } else { $gallery->debug('Core module activated successfully'); } @@ -165,7 +167,7 @@ $gallery->debug(sprintf('Error: Unable to commit database transaction, this ' . 'is the error stack trace; %s', $ret->getAsText())); $templateData['errors'][] = _('Unable to commit database transaction'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } else { $gallery->debug('Committed transaction successfully'); } @@ -173,14 +175,13 @@ $gallery->debug('NOT installing, rollback!'); $storage->rollbackTransaction(); /* Ignore any errors from this */ /* - * Don't allow this step to complete when only partially installed. - * Verify that versions.dat is up to date. + * Don't allow this step to complete when only partially installed. Verify that + * versions.dat is up to date. */ $versions = $core->getInstalledVersions(); if (empty($versions['core']) || $versions['core'] != $core->getVersion()) { $gallery->debug('Error: Core module is only partially installed'); $templateData['errors'][] = _('Core module is only partially installed.'); - $templateData['stackTrace'] = ''; } else { $gallery->debug('Core module version is ok'); } Modified: trunk/gallery2/install/steps/InstallOtherModulesStep.class =================================================================== --- trunk/gallery2/install/steps/InstallOtherModulesStep.class 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/steps/InstallOtherModulesStep.class 2007-04-27 05:40:46 UTC (rev 16354) @@ -19,10 +19,11 @@ */ /** - * Install plugins + * Install plugins. * @package Install */ class InstallOtherModulesStep extends InstallStep { + function stepName() { return _('Install Plugins'); } @@ -37,20 +38,19 @@ global $gallery; $currentModule = $totalModules = 0; - $templateData['stackTrace'] = ''; $template = new StatusTemplate(); $ret = $this->_selectAdminUser(); if ($ret) { $templateData['errors'][] = _('Unable to initialize our Gallery session'); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); unset($_REQUEST['module']); } if (isset($_REQUEST['module'])) { $storage =& $gallery->getStorage(); } - if ( !empty($_REQUEST['module']) && is_array($_REQUEST['module']) ) { + if (!empty($_REQUEST['module']) && is_array($_REQUEST['module'])) { uksort($_REQUEST['module'], array($this, '_sortModules')); $template->renderHeader(true); $totalModules = count($_REQUEST['module']); @@ -61,7 +61,7 @@ $this->resetL10Domain(); $templateData['errors'][] = sprintf(_('Unable to load the %s module'), $moduleId); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); continue; } $module->setName($module->translate($module->getName())); @@ -77,7 +77,7 @@ $this->resetL10Domain(); $templateData['errors'][] = sprintf(_('Unable to install the %s module'), $module->getName()); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); continue; } $moduleInstalled[$moduleId] = true; @@ -87,7 +87,7 @@ if ($ret) { $this->resetL10Domain(); $templateData['errors'][] = _('Unable to commit database transaction'); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } list ($ret, $success) = $module->autoConfigure(); @@ -95,7 +95,7 @@ $this->resetL10Domain(); $templateData['errors'][] = sprintf(_('Unable to activate the %s module'), $module->getName()); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); continue; } @@ -111,7 +111,7 @@ if ($ret) { $templateData['errors'][] = sprintf(_('Unable to activate the %s module'), $module->getName()); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); continue; } $templateData['activated'][$moduleId] = $module->getName(); @@ -126,7 +126,7 @@ $ret = $storage->commitTransaction(); if ($ret) { $templateData['errors'][] = _('Unable to commit database transaction'); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } } $templateData['bodyFile'] = 'InstallOtherModulesSuccess.html'; @@ -152,7 +152,7 @@ list ($ret, $moduleList) = GalleryCoreApi::fetchPluginStatus('module', true); if ($ret) { $templateData['errors'][] = _('Unable to get the module list'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } } @@ -163,7 +163,7 @@ $this->resetL10Domain(); $templateData['warnings'][] = sprintf(_('Unable to load the %s module'), $moduleId); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } else { $modulePlugin->setName($modulePlugin->translate($modulePlugin->getName())); $modulePlugin->setDescription( @@ -211,9 +211,9 @@ $cacheKey = 'Installer::installOtherModulesStepInitialized'; if (!GalleryDataCache::containsKey($cacheKey)) { /* - * Disable the data cache before initializing. If we don't do this - * *first* then some data (like factory registrations) will get cached - * now, and then the modules won't be able to update it later on. + * Disable the data cache before initializing. If we don't do this *first* then some + * data (like factory registrations) will get cached now, and then the modules won't be + * able to update it later on. */ GalleryDataCache::setFileCachingEnabled(false); @@ -222,17 +222,18 @@ } require_once(dirname(__FILE__) . '/../../bootstrap.inc'); require_once(dirname(__FILE__) . '/../../init.inc'); - $ret = GalleryInitFirstPass(array('debug' => 'buffered', 'noDatabase' => true, - 'activeLanguage' => $_SESSION['language'])); + $ret = GalleryInitFirstPass(array('debug' => 'buffered', + 'noDatabase' => true, + 'activeLanguage' => $_SESSION['language'])); if ($ret) { $templateData['errors'][] = _('Unable to initialize our Gallery data'); - $templateData['stackTrace'] = $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } if (empty($templateData['errors'])) { $ret = $this->_selectAdminUser(); if ($ret) { $templateData['errors'][] = _('Unable to initialize our Gallery session'); - $templateData['stackTrace'] .= $ret->getAsHtml(); + $templateData['stackTrace'][] = $ret->getAsHtml(); } } GalleryDataCache::put($cacheKey, true); @@ -248,7 +249,7 @@ } /** - * Find admin user and set as active user + * Find admin user and set as active user. * @return object GalleryStatus a status code */ function _selectAdminUser() { Modified: trunk/gallery2/install/templates/DatabaseSetupRequest.html =================================================================== --- trunk/gallery2/install/templates/DatabaseSetupRequest.html 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/templates/DatabaseSetupRequest.html 2007-04-27 05:40:46 UTC (rev 16354) @@ -116,7 +116,7 @@ <?php if (!empty($templateData['stackTrace'])): ?> <div class="stack_trace"> - <?php print $templateData['stackTrace'] ?> + <?php print implode('<br/>', $templateData['stackTrace']) ?> </div> <?php endif; ?> Modified: trunk/gallery2/install/templates/InstallCoreModuleError.html =================================================================== --- trunk/gallery2/install/templates/InstallCoreModuleError.html 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/templates/InstallCoreModuleError.html 2007-04-27 05:40:46 UTC (rev 16354) @@ -21,8 +21,10 @@ <h2> <?php print _("Stack Trace:") ?> </h2> + <?php if (!empty($templateData['stackTrace'])): ?> <div class="stack_trace"> - <?php print $templateData['stackTrace']; ?> + <?php print implode('</br>', $templateData['stackTrace']) ?> </div> + <?php endif ?> - <br /> + <br/> Modified: trunk/gallery2/install/templates/InstallOtherModulesRequest.html =================================================================== --- trunk/gallery2/install/templates/InstallOtherModulesRequest.html 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/templates/InstallOtherModulesRequest.html 2007-04-27 05:40:46 UTC (rev 16354) @@ -1,6 +1,6 @@ - <?php if (isset($templateData['stackTrace'])): ?> + <?php if (!empty($templateData['stackTrace'])): ?> <div class="stack_trace"> - <?php print $templateData['stackTrace']; ?> + <?php print implode('<br/>', $templateData['stackTrace']) ?> </div><br/> <?php endif; ?> Modified: trunk/gallery2/install/templates/InstallOtherModulesSuccess.html =================================================================== --- trunk/gallery2/install/templates/InstallOtherModulesSuccess.html 2007-04-27 05:28:35 UTC (rev 16353) +++ trunk/gallery2/install/templates/InstallOtherModulesSuccess.html 2007-04-27 05:40:46 UTC (rev 16354) @@ -1,6 +1,6 @@ <?php if (!empty($templateData['stackTrace'])): ?> <div class="stack_trace"> - <?php print $templateData['stackTrace']; ?> + <?php print implode('<br/>', $templateData['stackTrace']) ?> </div><br/> <?php endif; ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |