Search
Other Components Anywhere questions
Forum

Components Anywhere Not Working After Server Move

Kevin's Avatar Kevin
Hi,

Hope all is well.

We have been using Components Anywhere for several years and love the product. And have had no issues
with it at all until recently when we moved our website to another server.

Here is the situation. We have a module that heftly relies on calling the joomla function $user = JFactory::getUser().
We use this in most of our compnents and use Components Anywhere to placecomponents on the website to control/restrict access to user data.

After days of troubleshooting we were able to narrow it dson to this:
If we call use componets anywhere then we are not able to get the user id/name et cetra when calling $user = JFactory::getUser().

At first we thought it was our code or other components that were flawed. However no matter what component we call, enven builtin Joomla
compnents we get the same problem.

Example: We tested a simple Joomla serach component; index.php?option=com_search&view=search.

If we add the following code to the component in this folder
/components/com_search/search.php . It works well if called
from a menu item and most imoportantly
it works on our other server environment.

$user = JFactory::getUser();
$comm_user= $user->name;
echo 'User name: ' . $user->username . '<br />';
echo 'Real name: ' . $user->name . '<br />';
echo 'User ID : ' . $user->id . '<br />';

Result:
-----------
User name: John Doe
Real name: John Doe
User ID : 107

Once we use it our new server environment, it works if we call the component directly from a menu item, but does not work if
we place it in a custom module uand use CA as follows:

{component index.php?option=com_search&view=search}

Result:
-----------
User name:
Real name:
User ID : 0

Just to recap :

Note 1 :
This applies to any component we try Joomla or otherwise. Actually the code we are using is for another extension but the
problem occurs everywhere. No matter which component. As long as we use CA it cannot retrieve the Joomla user detail.

Note 2:
This is and has been working on our other old decommissioned server without a glitch.

Note 3:
The only changes that we can identify between the 2 servers is that we had to comment out 2 lines in the .htaccess file.
## Can be commented out if causes errors, see notes above.
## Options +FollowSymlinks
## Options -Indexes

Sorry for the long details but we wanted to provide as much detail as possible.

BTW - We are using:
CA version 4.7.2 (we tried 4.7.3 as well )
Joomla version v3.9.4
PHP v.7.4.12

Both environments mentioned above are EXACTLY the same.

Thanks
Peter van Westen's Avatar Peter van Westen ADMIN
Try playing around with the Components Anywhere settings, like the Pass Cookies.
Also see if changing the system plugin ordering makes a difference.
See: www.regularlabs.com/guides/242-plugin-order-is-important
Please post a rating at the Joomla! Extensions Directory
Kevin's Avatar Kevin
Hi Peter,

We appreciate the quick response.

I forgot to mention that we indeed tried changing /toggling all or most of the settings under the system plugin before contacting support.
We still went ahead and tried both options in the Plugins >> System Advanced 'Pass On Cookies' option and this did not resolve the issue.

About the ordering of the plugin we did not think about this, since as mentioned previously, is an EXACT copy from our other website where everything is working.

Nevertheless we still went ahead and changed the order of the System - Regular Labs - Components Anywhere Plugin but to no avail.

Same problem still occurred.

Any more areas / suggestions?

thanks
Peter van Westen's Avatar Peter van Westen ADMIN
No, sorry, I wouldn't know.
There must be some difference in the setup. Maybe something down to the PHP version and/or settings.
See if cURL is enabled.

Or see if the error log gives any clues.

Otherwise, I would need to dig into the code (of Components Anywhere) and test things on your server to see why that is happening.
Please post a rating at the Joomla! Extensions Directory
Kevin's Avatar Kevin
Confidential information:
(hidden)
Kevin's Avatar Kevin
Hi Peter,

OK. We setup a brand new Joomla website on the server. With no extensions at all except Components Anywhere.
We wanted to make sure that there were no conflicts with other plugins et cetera.
I have provided login instructions and other details below:

If you login with the credentials provided you will notice that in the main menu we created a simple component menu option for the Joomla Search.

We went ahead to create a custom Joomla Menu option to view this component in the Beez3 positon-12.
Thus 2 components on the same page.


You will notice once you login in as user, at the top the component displays the user information from the JFactory::getUser() function.
Which we require for several of our components to restrict user information.

You will notice that the default component returns the values from the $user = JFactory::getUser() function.
But once we incorporate the link in the CA module the function it display blank values. Meaning it is not able to return the values from the function.

We decided to use the simple Joomla search module to recreate the problem. And to rule out any other coding issues or conflicts.

However our situation is more dire 🙁
We use this function in one of our extensions with CA extensively throughout the website and is a key requirement.
As mentioned earlier this has been working for 2-3 years before we moved to a new server.

Confidential information:
(hidden)



Please help
Thanks
Peter van Westen's Avatar Peter van Westen ADMIN
Yes, I would need the (s)ftp details too to see what is going on.

Your test location does not have a valid SSL certificate. This can also cause issues when trying to load other pages through PHP.
So make sure you fix that first.
Please post a rating at the Joomla! Extensions Directory
Kevin's Avatar Kevin
Hi Peter,

Please find the FTP details below:
Confidential information:
(hidden)


In regards to the SSL certificate, in our initial troubleshooting steps we thought that this could have been the cause prior to contacting Regular Labs. And having to go through our 3rd party to set it up.

However we quickly and eventually ruled this out because:

1. The same problem occurs in our production/live environment which has an SSL certificate.
2. In our other environment where the same scenario where the CA module works it does NOT have an SSL at all. And it works without a glitch.

Thus we did not setup SSL on this sandbox environment.

Thanks
Peter van Westen's Avatar Peter van Westen ADMIN
Please make sure the Joomla version is uptodate.
Also let me know on what URL I can see the issue. So where you have the {component} tag and what URL you are including through Components Anywhere (so the page using the JFactory::getUser()).
Please post a rating at the Joomla! Extensions Directory
Kevin's Avatar Kevin
The Joomla version was relatively current v.3.9.4.
Either way we went ahead to update the Joomla version from 3.9.4 to 3.9.24.
( The working environment is using v3.9.4?)

The URL is:
Confidential information:
(hidden)


To Recreate:

Click on Search Menu:
You will see the CA component on top - no user information.
Below the default Joomla Search Component - with user information.
(the same way it appears in our working environment using CA)

Just in case the file that we used to test is the default Joomla search component in the following folder.

/httpdocs/components/com_search

We have tried the same with about 5/6 other files to get it to work with CA. To no avail.
As a component it works fine. Thus at this juncture we ruled out an issue with file/component.


Thanks
Peter van Westen's Avatar Peter van Westen ADMIN
The Joomla version was relatively current v.3.9.4.
First off: that is not relatively current. v3.9.4 was from nearly 2 years ago!
And even if it was 3.9.22... you should simply make sure Joomla and your extensions are uptodate.

I cannot find a reason for this that I could solve.
Components Anywhere simply asks the server to render the URL you tell it (with some added URL queries to get a json response):
index.php/search-menu?lang=en-GB&tmpl=component&rendercomponent=1
Opening this URL in the browser (when already logged in) shows the correct user information in the HTML part.
But seemingly your server does uses different sessions or whatever when loading the url through php cURL.
So you should ask your host about this. It is in their control.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription