Skip to content
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

Fix for Undefined offset in Content History preview popup #12791

Merged
merged 10 commits into from
Nov 18, 2016
Merged

Fix for Undefined offset in Content History preview popup #12791

merged 10 commits into from
Nov 18, 2016

Conversation

PhilETaylor
Copy link
Contributor

@PhilETaylor PhilETaylor commented Nov 6, 2016

Set error reporting to E_ALL (Like it should be for development)

Article Manager -> Edit Getting Started -> Versions -> Select a version -> popup url is like:

http://example.com/administrator/index.php?option=com_contenthistory&view=preview&layout=preview&tmpl=component&b05a6963679e395c78f4b883e2c00b56=1&version_id=2

repeated errors on page of

Notice: Undefined offset: 0 in example.com/administrator/components/com_contenthistory/helpers/contenthistory.php on line 123

Summary of Changes

Better checking of the array before attempting to access its members

Testing Instructions

Do above - replicate Notices, apply patch, see they disappear...

Documentation Changes Required

None

EDIT

So like a prat I committed my next fix to this branch too... so this PR now contains that too.

The problem that solves is that if you fake a non-existing version ID in the popup with a url like:

http://127.0.0.1:8000/administrator/index.php?option=com_contenthistory&view=preview&layout=preview&tmpl=component&b05a6963679e395c78f4b883e2c00b56=1&version_id=212312

Then you get
screen shot 2016-11-06 at 17 04 17

This PR also fixes that now...

else
{
$valueText = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a clean line after the if?

What about removing the else completly?

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Contributor

Choose a reason for hiding this comment

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

how about:

$valueText = null;

if (is_array($optionFieldArray) && count($optionFieldArray))
{
  $valueText = trim((string) $optionFieldArray[0]);
}

This comment was marked as abuse.

Copy link
Contributor

Choose a reason for hiding this comment

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

The code sniffer doesn't detect all the style issues. There is supposed to be a line break after an if/else block.

if (false === $this->item)
{
$language = JFactory::getLanguage();
$language->load('com_content', JPATH_SITE, null, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remover the language var here?

This comment was marked as abuse.

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, we shouldn't be importing strings from com_content here (especially as history can be used with more than articles). But for some asinine reason there isn't a generic "Item not found" string in the global language files.

This comment was marked as abuse.

This comment was marked as abuse.

@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on 3a466a2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12791.

@zero-24
Copy link
Contributor

zero-24 commented Nov 18, 2016

I have tested this item ✅ successfully on 3a466a2

👍


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12791.

@zero-24 zero-24 added this to the Joomla 3.7.0 milestone Nov 18, 2016
@zero-24 zero-24 added the RTC This Pull Request is Ready To Commit label Nov 18, 2016
@zero-24
Copy link
Contributor

zero-24 commented Nov 18, 2016

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12791.

@rdeutz rdeutz merged commit acd91fd into joomla:staging Nov 18, 2016
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Nov 18, 2016
@photodude
Copy link
Contributor

@PhilETaylor

make travis happy, travis I hate you, tab/spaces hell

These are all reasons why I'm trying to get a PHPCS2 version of our code standards tested and verified so we have automatic fixers to correct most of the general code style issues.

roland-d added a commit to roland-d/joomla-cms that referenced this pull request Nov 25, 2016
* staging: (98 commits)
  Coding style. PHP constants true, false, and null MUST be in lower case. (joomla#13010)
  Removing duplicated AS in sql query (joomla#13006)
  Fixed typo in comment (joomla#12992)
  Correcting strings in TFA Google plugin (joomla#12980)
  code style changes (joomla#12986)
  Error in sr-YU installation ini file (joomla#12984)
  New DateTime picker (replaces calendar) (joomla#11138)
  Export of Banners Tracks Does Not Export the Banner Name
  fix rues get data (joomla#12763)
  Added Feature items filter to mod_articles_news (joomla#12547)
  fix them all (joomla#12943)
  a11y regression fix (joomla#12935)
  Set correct component id for system links (joomla#12938)
  Fix for Undefined offset in Content History preview popup (joomla#12791)
  remove tab on meta charset (joomla#12895)
  JSession patched to set session _state to 'inactive' when session is closed. (joomla#12928)
  [JHtmlNumber::bytes] Format number according to language (joomla#12929)
  Update edit.php (joomla#12818)
  Update default.xml (joomla#12917)
  Adding the ability to use the global value for character count in newsfeeds (joomla#12869)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants