-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
PHP max_input_vars test plugin #7456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4e60231
a48d9a0
763a9c2
2714699
a81db14
7898b95
95b8a9f
d178674
6830aac
0ed6ec9
8395644
aca21fa
e6a1ff8
d6115d9
6d7ea81
f8a9e40
f36b8f0
24b2d1d
3892041
942b499
1630590
c3232e9
aec570c
18164b1
9c2dd00
65206a4
3b40ffd
4460f71
7bcf8cd
d30e510
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; |
| 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." |
| 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(); | ||
| } | ||
|
|
||
| /** | ||
| * 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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would either use or But it's only a minor thing.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'); | ||
| } | ||
| } | ||
| } | ||
| 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> |
There was a problem hiding this comment.
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
Also maybe is possible to extend this even further so it runs only when
com_panelis the component? (I am guessing the message is displayed there…)There was a problem hiding this comment.
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.