User tests: Successful: Unsuccessful:
Pull Request for Issue # .
…edirect function.
if ($url[0] == '/')... generates an error
PHP Notice: Uninitialized string offset: 0 in .../libraries/joomla/application/web.php on line 509
adding a check for empty $url fixes that.
not sure if this is correct way to add it.
Category | ⇒ | Libraries |
Status | New | ⇒ | Information Required |
@fanno Please can you respond to the question from @bertmert or this will be closed in a few weeks
sorry i have been busy.
Could you please provide some testing instructions.
i am not sure what you mean by testing instructions ?
redirect("") would do it.
Where can I trigger the notice in Joomla core?
I am still trying to trace the actual cause on my setup, and i am still unable to locate where it is happening. i cant figure out if it is comming from my code or from code in some other 3rd party code that we use.
Wouldn't it be better if extensions check the URL before they send it to redirect()?
yes that would ofcause be better, tho not everyone know what they are doing., i only created this to prevent "unforseen" erros. i like to think i know just a little bit about what i am doing. i am no pro ofcause,
P.S. this wont "FIX" my issue as such. but it will fix potentual issue with redirect. again i am just reporting it because an error can happen.
if no "fixing" the url and just redirct to index. then pehaps "throw" and exception with invalid parameter or something like that.
Testing instructions
You always must provide some error producing code and describe where to insert it for testing or describe a way (e.g. settings in the back-end (error reporting: maximum) and so on) to reproduce the error/issue you described. So anybody can test the behavior before and after applying your PR. (Most people use Joomla Patchtester Component to test PRs and lots of them need a detailed instruction how to test the differences.)
Wouldn't it be better if extensions check the URL before they send it to redirect()?
I prefer to see Notices, Warnings, Errors while programming ;-) It helps to make my code better and find my bugs faster. I prefer a smaller Joomla core code than too many "if this variable is not correct please silently help, Joomla" ;-)
But: It was just a question. Just a private opinion. Nothing I have to decide here.
ya no problem, just thought i would bring it up as i founed it.
Status | Information Required | ⇒ | Pending |
I do not understand your question =( ?
you wrote "redirect("") would do it" > in which file to write redirect("")
?
Testing instructions:
Put a call to JFactory::getApplication()->redirect('');
anywhere. Based on the original report, pre patch this will emit a PHP notice and should not post-patch.
for Example in configuration.php
No, because framework must be initialized first. I think index.php
of template is a "good" place.
There's a difference if you test (without patch) with
no argument
JFactory::getApplication()->redirect();
==> I get a Joomla error page ("Too few arguments to function JApplicationCms::redirect(), 0 passed...")
or empty string
JFactory::getApplication()->redirect('');
==> I get an "endless redirection error" from the browser.
Current staging. PHP 7.1. FF. Protostar. Error Reporting: System Default.
@bertmert looks like JFactory::getApplication()->redirect();
is on wrong Place (Test without PR).
/**
* @package Joomla.Site
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Define the application's minimum supported PHP version as a constant so it can be referenced within the application.
*/
JFactory::getApplication()->redirect();
define('JOOMLA_MINIMUM_PHP', '5.3.10');
PHP Fatal error: Uncaught Error: Class 'JFactory' not found in /Applications/MAMP/htdocs/J3/index.php:12
Stack trace:
#0 {main}
thrown in /Applications/MAMP/htdocs/J3/index.php on line 12
I think index.php of template is a "good" place.
Not in index.php in JoomlaRoot but template, e.g. protostar's index.php
/**
* @package Joomla.Site
* @subpackage Templates.protostar
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JFactory::getApplication()->redirect();
/** @var JDocumentHtml $this */
Uninitialized string offset: 0 in /Applications/MAMP/htdocs/J3/libraries/joomla/application/web.php on line 520
I have tested this item
I installed a fresh copy from github. (Joomla! 3.8.0-beta3-dev)
If I try to apply the patch I got the following error:
"The file marked for modification does not exist: libraries/joomla/application/web.php"
In "/protostar.index.php" I tested:
"JFactory::getApplication()->redirect('');"
>> Redirecting to the root of the site. (e.g. http://localhost/)
"JFactory::getApplication()->redirect();"
>> Error: "Array to string conversion in C:\xampp\htdocs\wpw\templates\protostar\error.php on line 118 Array"
But I think redirecting to an empty url doesn't make sense.
So the error is justified.
I have tested this item
I have applied the patch and tested it for both cases JFactory::getApplication()->redirect(''); and JFactory::getApplication()->redirect(); in Firefox, Chrome and Safari. I put it into the protostar/index.php but in both cases i got the error exactly like when i disabled the patch.
I have tested this item
I have tested this as well and the fix works for half of the cases. First of all, this PR needs to be updated with the current codebase as the change needs to be in the new file located at libraries/src/Application/WebApplication.php on line 575.
Testing with JFactory::getApplication()->redirect('');
will throw the undefined notice and this patch fixes this as it no longer throws the notice.
Testing with JFactory::getApplication()->redirect();
throws another notice PHP Notice: Array to string conversion. This patch doesn't fix this. It will be good if this can be included in this fix as well.
If this Issue get no Response, it will be closed at 22th September 2018.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-09-23 05:16:35 |
Closed_By | ⇒ | franz-wohlkoenig |
Status | Closed | ⇒ | Pending |
Status | Pending | ⇒ | Closed |
Closed_Date | 2018-09-23 05:16:35 | ⇒ | 2018-09-23 05:16:36 |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/11151
This has been closed due to lack of response to the requests above – it can always be reopened.
@fanno
Could you please provide some testing instructions.
Where can I trigger the notice in Joomla core?
Wouldn't it be better if extensions check the URL before they send it to redirect()?