Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4e60231
maxvars first commit
brianteeman Jul 17, 2015
a48d9a0
Update maxvars.php
zero-24 Jul 17, 2015
763a9c2
Update maxvars.php
zero-24 Jul 17, 2015
2714699
Merge pull request #6 from zero-24/patch-4
brianteeman Jul 17, 2015
a81db14
add warning test
brianteeman Jul 17, 2015
7898b95
language files and notice
brianteeman Jul 17, 2015
95b8a9f
print value
brianteeman Jul 17, 2015
d178674
correct variable
brianteeman Jul 17, 2015
6830aac
fix
brianteeman Jul 17, 2015
0ed6ec9
fix the count
brianteeman Jul 17, 2015
8395644
Update maxvars.php
zero-24 Jul 17, 2015
aca21fa
Update maxvars.php
zero-24 Jul 17, 2015
e6a1ff8
Update maxvars.xml
zero-24 Jul 17, 2015
d6115d9
Update maxvars.php
zero-24 Jul 17, 2015
6d7ea81
Update script.php
zero-24 Jul 17, 2015
f8a9e40
Create 3.5.0-2015-07-17.sql
zero-24 Jul 17, 2015
f36b8f0
Create 3.5.0-2015-07-17.sql
zero-24 Jul 17, 2015
24b2d1d
Create 3.5.0-2015-07-17.sql
zero-24 Jul 17, 2015
3892041
Merge pull request #8 from zero-24/patch-5
brianteeman Jul 17, 2015
942b499
Update language
brianteeman Jul 17, 2015
1630590
Update language
brianteeman Jul 17, 2015
c3232e9
correct update scripts
brianteeman Jul 17, 2015
aec570c
Add new install scripts
brianteeman Jul 17, 2015
18164b1
correct XML
brianteeman Jul 17, 2015
9c2dd00
codestyle
brianteeman Jul 17, 2015
65206a4
code style
brianteeman Jul 17, 2015
3b40ffd
codestyle again
brianteeman Jul 17, 2015
4460f71
correct the maths
brianteeman Jul 17, 2015
7bcf8cd
codestlye
brianteeman Jul 18, 2015
d30e510
codestyle
brianteeman Jul 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ protected function updateManifestCaches()
array('plugin', 'tags', 'finder', 0),
array('plugin', 'totp', 'twofactorauth', 0),
array('plugin', 'yubikey', 'twofactorauth', 0),
array('plugin', 'maxvars', 'quickicon', 0),

// Templates
array('template', 'beez3', '', 0),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(453, 'plg_quickicon_maxvars', 'plugin', 'maxvars', 'quickicon', 1, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
(453, 'plg_quickicon_maxvars', 'plugin', 'maxvars', 'quickicon', 1, 1, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state])
SELECT 453, 'plg_quickicon_maxvars', 'plugin', 'maxvars', 'quickicon', 1, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0;
7 changes: 7 additions & 0 deletions administrator/language/en-GB/en-GB.plg_quickicon_maxvars.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_QUICKICON_MAXVARS_WARN="Your PHP configuration has an input limit of %s variables and your website is using approximately <strong>%s</strong>. This <strong>may</strong> create issues making changes to your website.</strong> <br />Please contact your hosting provider and ask them to increase the limit of the PHP setting <strong>max_input_vars</strong>."
PLG_QUICKICON_MAXVARS_FAIL="Your PHP configuration has an input limit of %s variables and your website has reached that limit and is using approximately <strong>%s</strong>. <strong> <br />This will create issues making changes to your website.</strong> <br />Please contact your hosting provider and ask them to increase the limit of the PHP setting <strong>max_input_vars</strong>."
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_QUICKICON_MAXVARS="Quick Icon - Joomla! php max_input_vars check"
PLG_QUICKICON_MAXVARS_XML_DESCRIPTION="Checks the setting of php max_input_vars and notifies you when you visit the Control Panel page if you have reached the server limit."
1 change: 1 addition & 0 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`
(449, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(450, 'plg_twofactorauth_yubikey', 'plugin', 'yubikey', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(453, 'plg_quickicon_maxvars', 'plugin', 'maxvars', 'quickicon', 1, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0);
(503, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(504, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(506, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
Expand Down
1 change: 1 addition & 0 deletions installation/sql/postgresql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder"
(449, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(450, 'plg_twofactorauth_yubikey', 'plugin', 'yubikey', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '1970-01-01 00:00:00', 0, 0);
(453, 'plg_quickicon_maxvars', 'plugin', 'maxvars', 'quickicon', 1, 1, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0);

-- Templates
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
Expand Down
3 changes: 2 additions & 1 deletion installation/sql/sqlazure/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,8 @@ UNION ALL
SELECT 450, 'plg_twofactorauth_yubikey', 'plugin', 'yubikey', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0
UNION ALL
SELECT 451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '1900-01-01 00:00:00', 0, 0;

UNION ALL
SELECT 453, 'plg_quickicon_maxvars', 'plugin', 'maxvars', 'quickicon', 1, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0;

INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state])
SELECT 503, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '1900-01-01 00:00:00', 0, 0
Expand Down
85 changes: 85 additions & 0 deletions plugins/quickicon/maxvars/maxvars.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Quickicon.Joomla
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* Joomla! php max vars Plugin
*
* @since 3.5
*/
class PlgQuickiconMaxvars extends JPlugin
{
/**
* Constructor
*
* @param object &$subject The object to observe
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'group', 'params', 'language'
* (this list is not meant to be comprehensive).
*
* @since 3.5
*/
public function __construct(&$subject, $config = array())
{
parent::__construct($subject, $config);

$this->loadLanguage();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brianteeman can I propose a quick bail out for the front end

if ( JFactory::getApplication()->isSite() )
{
    return;
}

Also maybe is possible to extend this even further so it runs only when com_panel is the component? (I am guessing the message is displayed there…)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole quickicon group is only loaded on the cpanel view (from the quickicon module). So it isn't really needed to bail out otherwise.

/**
* This method is called when the Quick Icons module is constructing its set
* of icons. You can return an array which defines a single icon and it will
* be rendered right after the stock Quick Icons.
*
* @param string $context The calling context
*
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 3.5
*/
public function onGetIcons($context)
{
$maxinputvars = @ini_get('max_input_vars');
$varcount = 0;

$tables = array(
'#__categories',
'#__menu',
'#__modules',
'#__usergroups',
);

// Get a db connection.
$db = JFactory::getDbo();
$query = $db->getQuery(true);

foreach ($tables as $tableToCheck)
{
$query->clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would either use

$db    = JFactory::getDbo();

foreach ($tables as $tableToCheck)
{
    $query = $db->getQuery(true);
    $query->select('count(*)');
    $query->from($db->quoteName($tableToCheck));
...

or

$db    = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(*)');

foreach ($tables as $tableToCheck)
{
    $query->clear('from');
    $query->from($db->quoteName($tableToCheck));
...

But it's only a minor thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zero-24 wrote that part (converted my query from pure sql to joomla $query) which was later updated and modified by @rdeutz

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could see it as personal preference anyway. Shouldn't make a performance difference.


$query->select('count(*)');
$query->from($db->quoteName($tableToCheck));

$db->setQuery($query);
$varcount = $varcount + (int) $db->loadResult();
}

if ($varcount >= $maxinputvars)
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_QUICKICON_MAXVARS_FAIL', $maxinputvars, $varcount), 'error');
}

if (($varcount / $maxinputvars) > 0.8) > 80)
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_QUICKICON_MAXVARS_WARN', $maxinputvars, $varcount), 'warning');
}
}
}
19 changes: 19 additions & 0 deletions plugins/quickicon/maxvars/maxvars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.5" type="plugin" group="quickicon">
<name>PLG_QUICKICON_MAXVARS</name>
<author>Joomla! Project</author>
<creationDate>July 2015</creationDate>
<copyright>Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.5.0</version>
<description>PLG_QUICKICON_MAXVARS_XML_DESCRIPTION</description>
<files>
<filename plugin="maxvars">maxvars.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_quickicon_maxvars.ini</language>
<language tag="en-GB">en-GB.plg_quickicon_maxvars.sys.ini</language>
</languages>
</extension>