J3 Issue ?
avatar PhilETaylor
PhilETaylor
18 Oct 2018

Steps to reproduce the issue

Add a "reasonable amount" or rows to your action log
Export the action log to CSV

Expected result

A CSV is downloaded

Actual result

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /Users/phil/Sites/joomla-cms/libraries/vendor/joomla/uri/src/UriHelper.php on line 40

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /Users/phil/Sites/joomla-cms/libraries/src/Session/Session.php on line 386

or

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/phil/Sites/joomla-cms/libraries/vendor/joomla/registry/src/Registry.php on line 219

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/phil/Sites/joomla-cms/libraries/src/Session/Session.php on line 386

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/phil/Sites/joomla-cms/libraries/joomla/database/driver.php on line 1886

Warning: Unknown: Cannot call session save handler in a recursive manner in Unknown on line 0
avatar PhilETaylor PhilETaylor - open - 18 Oct 2018
avatar joomla-cms-bot joomla-cms-bot - change - 18 Oct 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Oct 2018
avatar PhilETaylor PhilETaylor - change - 18 Oct 2018
The description was changed
avatar PhilETaylor PhilETaylor - edited - 18 Oct 2018
avatar mbabker
mbabker - comment - 20 Oct 2018

#22750 should help here, purposefully not closing until we get some confirmation that "a reasonable amount" of logs are efficiently handled here.

avatar PhilETaylor
PhilETaylor - comment - 20 Oct 2018

One of my issues has a link to a large db for testing...

avatar PhilETaylor
PhilETaylor - comment - 20 Oct 2018

large db for testing...
http://screenshot.myjoom.la/3dd57411d692

username: admin password: admin (PLEASE CHANGE email address of "admin" user before mass spamming me ;-))

avatar mbabker
mbabker - comment - 20 Oct 2018

I can get that database to export on my system if I use a Generator (PHP 5.5+). Haven't stumbled on anything that's PHP 5.3 compatible yet though.

Just for reference so someone can come back to it later (this diff should be on top of #22750):

diff --git a/administrator/components/com_actionlogs/helpers/actionlogs.php b/administrator/components/com_actionlogs/helpers/actionlogs.php
index c384728914b..f6add337205 100644
--- a/administrator/components/com_actionlogs/helpers/actionlogs.php
+++ b/administrator/components/com_actionlogs/helpers/actionlogs.php
@@ -24,7 +24,7 @@ class ActionlogsHelper
 	 *
 	 * @param   array|Traversable  $data  The logs data objects to be exported
 	 *
-	 * @return  array
+	 * @return  Generator
 	 *
 	 * @since   3.9.0
 	 * @throws  InvalidArgumentException
@@ -42,27 +42,24 @@ class ActionlogsHelper
 			);
 		}
 
-		$rows = array();
-
 		// Header row
-		$rows[] = array('Id', 'Message', 'Date', 'Extension', 'User', 'Ip');
+		yield array('Id', 'Message', 'Date', 'Extension', 'User', 'Ip');
 
 		foreach ($data as $log)
 		{
 			$extension = strtok($log->extension, '.');
+
 			static::loadTranslationFiles($extension);
-			$row               = array();
-			$row['id']         = $log->id;
-			$row['message']    = strip_tags(static::getHumanReadableLogMessage($log));
-			$row['date']       = JHtml::_('date', $log->log_date, JText::_('DATE_FORMAT_LC6'));
-			$row['extension']  = JText::_($extension);
-			$row['name']       = $log->name;
-			$row['ip_address'] = JText::_($log->ip_address);
-
-			$rows[] = $row;
-		}
 
-		return $rows;
+			yield array(
+				'id'         => $log->id,
+				'message'    => strip_tags(static::getHumanReadableLogMessage($log)),
+				'date'       => (new JDate($log->log_date, new DateTimeZone('UTC')))->format('Y-m-d H:i:s T'),
+				'extension'  => JText::_($extension),
+				'name'       => $log->name,
+				'ip_address' => JText::_($log->ip_address),
+			);
+		}
 	}
 
 	/**
@@ -157,6 +154,8 @@ class ActionlogsHelper
 	 */
 	public static function getHumanReadableLogMessage($log)
 	{
+		static $links = array();
+
 		$message     = JText::_($log->message_language_key);
 		$messageData = json_decode($log->message, true);
 
@@ -174,7 +173,12 @@ class ActionlogsHelper
 			// Convert relative url to absolute url so that it is clickable in action logs notification email
 			if (StringHelper::strpos($value, 'index.php?') === 0)
 			{
-				$value = JRoute::link('administrator', $value, false, $linkMode);
+				if (!isset($links[$value]))
+				{
+					$links[$value] = JRoute::link('administrator', $value, false, $linkMode);
+				}
+
+				$value = $links[$value];
 			}
 
 			$message = str_replace('{' . $key . '}', JText::_($value), $message);
avatar PhilETaylor
PhilETaylor - comment - 24 Oct 2018

@mbabker So #22807 highlights that the export is generating links, but surely the CSV export is a plain text export? and so doesn't need links? Can we not just skip generating of the links when exporting?

avatar brianteeman brianteeman - change - 30 Oct 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 30 Oct 2018
avatar PhilETaylor PhilETaylor - change - 10 Feb 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-02-10 21:34:30
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 10 Feb 2019

Add a Comment

Login with GitHub to post a comment