Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

To avoid Fatal error with JEditor::getButtons (for issue #660) #1093

Closed
wants to merge 11 commits into from

6 participants

Buddhima Wijeweera Michael Babker Christophe Demko elinw Rouven Weßling Louis Landry
Buddhima Wijeweera

File: joomla-platform / libraries / joomla / html / editor.php
Method: getButtons()

Issue: If the $className would not exists (due to plugin class is missing) , assigning to $temp variable becomes unsafe

Solution: Put the assiging inside a try catch block, so that not existance of plugin class would not disturb the flow of foreach loop

Signed-off-by: Buddhima Wijeweera

Buddhima Wijeweera Buddhima for issue #660
To avoid unsafe operation

Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
532ca47
Michael Babker
Owner

You need to fix your code style first - http://developer.joomla.org/pulls/pulls/1093.html

Also, instead of echoing the message, you should be returning an error. Instead of the try/catch method you've proposed, maybe the current if statement would work fine, but add an else so that an Exception is thrown and the caller can handle the error.

libraries/joomla/html/editor.php
((5 lines not shown))
// Try to authenticate
- if ($temp = $plugin->onDisplay($editor, $this->asset, $this->author))
- {
- $result[] = $temp;
- }
+ // Unsafe opearation, might cause an exception if $className not exists
elinw
elinw added a note

operation

Buddhima Wijeweera
Buddhima added a note

:D a mistake. Thanks for pointing out
Corrected !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Buddhima added some commits
Buddhima Wijeweera Buddhima commit 2 after applying coding standards. Thanks mbabker!
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
af7d4c3
Buddhima Wijeweera Buddhima corrected "operation" spellings
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
deb68e1
Buddhima Wijeweera Buddhima Throwing Exception instead of try-catch block
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
a89332b
Buddhima Wijeweera Buddhima changed Exception to InvalidArgumentException, added @throws in docblock
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
0bd1796
Buddhima Wijeweera Buddhima used single quotes and tabs instead of spaces
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
74b3027
Buddhima Wijeweera Buddhima changed quotes and added tabs
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
b66f8c6
Buddhima Wijeweera Buddhima removed spaces and replaced with tabs in latter section
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
24ed611
Buddhima Wijeweera Buddhima Corrected error in
libraries/joomla/html/editor.php:470

Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
434f00e
libraries/joomla/html/editor.php
@@ -426,6 +426,8 @@ public function setContent($editor, $html)
*
* @return array
*
+ * @throws InvalidArgumentException If plugin required does not exists
+ *
Christophe Demko
chdemko added a note

Please indent correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
libraries/joomla/html/editor.php
((8 lines not shown))
// Try to authenticate
if ($temp = $plugin->onDisplay($editor, $this->asset, $this->author))
{
$result[] = $temp;
}
+
Christophe Demko
chdemko added a note

superfluous line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Buddhima added some commits
Buddhima Wijeweera Buddhima Indent settled correctly and remove superfluous line
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
dc37ef8
Buddhima Wijeweera Buddhima Indent settled correctly
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
dfc11f3
Christophe Demko

The pull request cannot be merged

Buddhima Wijeweera

Hi, can you tell me why it is failing?

Christophe Demko

you have to merge with the current trunk

elinw

The issue is not that the pull request can't be merged (that would be shown on the pull tester report with red) All of the pull requests with ?? in them have the same failure. I'm not sure if it is because they all have a dependency on JHtml or not, but that is possible. Those test reports were generated on May 5 and have not been updated since.
All of them show this as the failing line
https://github.com/joomla/joomla-platform/blob/staging/tests/suites/unit/joomla/html/JHtmlTest.php#L896

Buddhima Wijeweera

Thanks Elin for pointing to the correct place :)

elinw

Okay now you need to update your branch, since the pulltester has rerun and it says it is not able to merge cleanly.

Rouven Weßling
Collaborator

This still doesn't merge cleanly. Also I'm wondering under what circumstances this would be triggered.

elinw

@realityking if the plugin is missing but you put the button in the field definition, I believe.

@Buddhima will you please rebase this or close it until you get it rebased?

Louis Landry

@Buddhima the library in question has been removed from the platform and added to the CMS tree. I'd suggest you submitting this to the CMS repository since it is a very smart and correct change in behavior. I'm closing this since it is no longer relevant for the platform. Apologies for not getting to it sooner.

Louis Landry LouisLandry closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 1, 2012
  1. Buddhima Wijeweera

    for issue #660

    Buddhima authored
    To avoid unsafe operation
    
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  2. Buddhima Wijeweera

    commit 2 after applying coding standards. Thanks mbabker!

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  3. Buddhima Wijeweera

    corrected "operation" spellings

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  4. Buddhima Wijeweera

    Throwing Exception instead of try-catch block

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  5. Buddhima Wijeweera

    changed Exception to InvalidArgumentException, added @throws in docblock

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  6. Buddhima Wijeweera

    used single quotes and tabs instead of spaces

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  7. Buddhima Wijeweera

    changed quotes and added tabs

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  8. Buddhima Wijeweera

    removed spaces and replaced with tabs in latter section

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
Commits on Apr 6, 2012
  1. Buddhima Wijeweera

    Corrected error in

    Buddhima authored
    libraries/joomla/html/editor.php:470
    
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
Commits on Apr 14, 2012
  1. Buddhima Wijeweera

    Indent settled correctly and remove superfluous line

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
  2. Buddhima Wijeweera

    Indent settled correctly

    Buddhima authored
    Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 0 deletions.
  1. +6 −0 libraries/joomla/html/editor.php
6 libraries/joomla/html/editor.php
View
@@ -426,6 +426,8 @@ public function setContent($editor, $html)
*
* @return array
*
+ * @throws InvalidArgumentException If plugin required does not exists
+ *
* @since 11.1
*/
public function getButtons($editor, $buttons = true)
@@ -454,6 +456,10 @@ public function getButtons($editor, $buttons = true)
{
$plugin = new $className($this, (array) $plugin);
}
+ else
+ {
+ throw new InvalidArgumentException('Class does not exists: ' . $className);
+ }
// Try to authenticate
if ($temp = $plugin->onDisplay($editor, $this->asset, $this->author))
Something went wrong with that request. Please try again.