From d73cf2c198a5a76430d9953a93446b50ef5216a1 Mon Sep 17 00:00:00 2001
From: Tobias Liebig <mail@etobi.de>
Date: Fri, 30 Apr 2010 16:52:28 +0000
Subject: [PATCH] Fixed bug #3800: Improve warning about empty reference index
 table

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7469 709f56b5-9817-0410-a4d7-c38de5d9e867
---
 ChangeLog                                              |  1 +
 t3lib/class.t3lib_befunc.php                           |  7 +++++--
 t3lib/class.t3lib_refindex.php                         |  5 +++++
 typo3/sysext/lang/locallang_core.xml                   |  2 +-
 ...s.tx_reports_reports_status_configurationstatus.php | 10 ++++++----
 5 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 24c314eb96e8..eb7db80f7afb 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-04-30  Tobias Liebig  <mail_typo3@etobi.de>
 
 	* Fixed bug #11587: set proper default timezone (fixes PHP 5.3 warnings concerning missing timezone settings)
+	* Fixed bug #3800: Improve warning about empty reference index table (thanks to Michael Knabe)
 
 2010-04-30  Jeff Segars  <jeff@webempoweredchurch.org>
 
diff --git a/t3lib/class.t3lib_befunc.php b/t3lib/class.t3lib_befunc.php
index e4a8021f68ff..9f5979ea5e08 100644
--- a/t3lib/class.t3lib_befunc.php
+++ b/t3lib/class.t3lib_befunc.php
@@ -4231,12 +4231,15 @@ final class t3lib_BEfunc {
 
 				// Check if sys_refindex is empty
 			$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex');
-			if (!$count) {
+			$registry = t3lib_div::makeInstance('t3lib_Registry');
+			$lastRefIndexUpdate = $registry->get('core', 'sys_refindex_lastUpdate');
+			if (!$count && $lastRefIndexUpdate) {
 				$url = 'sysext/lowlevel/dbint/index.php?&id=0&SET[function]=refindex';
 				$warnings["backend_reference"] = sprintf(
 					$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.backend_reference'),
 					'<a href="'.$url.'">',
-					'</a>');
+					'</a>',
+					t3lib_BEfunc::dateTime($lastRefIndexUpdate));
 			}
 
 			// Check for memcached if configured
diff --git a/t3lib/class.t3lib_refindex.php b/t3lib/class.t3lib_refindex.php
index ade48c08169c..15ed193c9601 100644
--- a/t3lib/class.t3lib_refindex.php
+++ b/t3lib/class.t3lib_refindex.php
@@ -1059,6 +1059,11 @@ class t3lib_refindex {
 		$bodyContent = $testedHowMuch.(count($errors)?implode(LF,$errors):'Index Integrity was perfect!');
 		if ($cli_echo) echo $testedHowMuch.(count($errors)?'Updates: '.count($errors):'Index Integrity was perfect!').LF;
 
+		if(!$testOnly) {
+			$registry = t3lib_div::makeInstance('t3lib_Registry');
+			$registry->set('core', 'sys_refindex_lastUpdate', $GLOBALS['EXEC_TIME']);
+		}
+
 		return array($headerContent,$bodyContent,count($errors));
 	}
 }
diff --git a/typo3/sysext/lang/locallang_core.xml b/typo3/sysext/lang/locallang_core.xml
index 9ebe04fac32e..6f4eac0e2edd 100755
--- a/typo3/sysext/lang/locallang_core.xml
+++ b/typo3/sysext/lang/locallang_core.xml
@@ -252,7 +252,7 @@ Would you like to save now in order to refresh the display?</label>
 			<label index="warning.install_encryption">The encryption key is not set. Set it in the %sBasic Configuration section%s of the Install Tool.</label>
 			<label index="warning.install_update">This installation is not configured for the TYPO3 version it is running. If you did so intentionally, this message can be safely ignored. If you are unsure, visit the %sUpdate Wizard%s section of the Install Tool to see how TYPO3 would change.</label>
 			<label index="warning.header">Important Notice!</label>
-			<label index="warning.backend_reference">The Reference Index table is empty which is likely the result of a recent TYPO3 upgrade. Please go to %sTools&gt;DB Check%s and update the reference index.</label>
+			<label index="warning.backend_reference">The Reference Index table is empty which is likely the result of a recent TYPO3 upgrade. The Reference Index was last updated on %3$s. Please go to %sTools&gt;DB Check%s and update the reference index.</label>
 			<label index="warning.memcache_not_usable">Memcache is configured, but connection to memcached failed with these configuration(s):</label>
 			<label index="warning.file_missing">File is missing!</label>
 			<label index="warning.file_missing_text">This content element references a file which seems to not exist:</label>
diff --git a/typo3/sysext/reports/reports/status/class.tx_reports_reports_status_configurationstatus.php b/typo3/sysext/reports/reports/status/class.tx_reports_reports_status_configurationstatus.php
index d32e2c887e11..0754886c25e2 100644
--- a/typo3/sysext/reports/reports/status/class.tx_reports_reports_status_configurationstatus.php
+++ b/typo3/sysext/reports/reports/status/class.tx_reports_reports_status_configurationstatus.php
@@ -63,8 +63,10 @@ class tx_reports_reports_status_ConfigurationStatus implements tx_reports_Status
 		$severity = tx_reports_reports_status_Status::OK;
 
 		$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex');
+		$registry = t3lib_div::makeInstance('t3lib_Registry');
+		$lastRefIndexUpdate = $registry->get('core', 'sys_refindex_lastUpdate'); 
 
-		if (!$count) {
+		if (!$count && $lastRefIndexUpdate) {
 			$value    = $GLOBALS['LANG']->getLL('status_empty');
 			$severity = tx_reports_reports_status_Status::WARNING;
 
@@ -72,10 +74,10 @@ class tx_reports_reports_status_ConfigurationStatus implements tx_reports_Status
 			$message  = sprintf(
 				$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.backend_reference'),
 				'<a href="' . $url . '">',
-				'</a>'
+				'</a>',
+				t3lib_BeFunc::dateTime($lastRefIndexUpdate)
 			);
 		}
-
 		return t3lib_div::makeInstance('tx_reports_reports_status_Status',
 			$GLOBALS['LANG']->getLL('status_referenceIndex'), $value, $message, $severity
 		);
@@ -184,4 +186,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/reports
 	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/reports/reports/status/class.tx_reports_reports_status_installtoolstatus.php']);
 }
 
-?>
\ No newline at end of file
+?>
-- 
GitLab