Enabling Views custom module causes an Ajax HTTP error on Drupal 7 - ajax

I'm working on a custom module that will describe an external table to the Views module. Inside my module folder I have the required mymodule.views.inc file. However, whenever this file is present and my custom module is enabled Drupal constantly gives Ajax HTTP Error pop ups when I use a site feature that has Ajax (any of the spinning daisies trigger this). The pop up always contains the module code in mymodule.views.inc after it says Ajax Error. The weird thing is every time I load the front page the PHP code in mymodule.views.inc is always displayed on the top of the front page.
I've seen this problem on SO and other sites a lot, but most of the time it can be traced back to an updated jquery.js file or a php.ini setting that will give scripts more time to run. So far neither of those fixes have worked. The only way I can make it go away for now is to either disable my custom module, or rename mymodule.views.inc to something else.
Here's an example of what the message looks like (not verbatim copy, since I can't copy from these alert messages in Chrome).
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /?q=admin/structure/views/view/viewiamtryingtocreate/preview/page/ajax
StatusText: parseerror
ResponseText: /*
* header file to my mymodule.views.inc
* file I wrote
*/
//more php code follows
//lots of unicode characters intermittently show up in my source code
\u003C\/div\u003E\n...
//source code continues with lots of unicode characters, not sure what's at the bottom because the alert box is bigger than my screen and I can't scroll on it
Does anyone else know what could be going on?

This error is caused by drupalforfirebug, disabling drupal for firebug should help. or else this patch should work.

Found it. Syntax error hiding at the top of mymodule.views.inc. There was some weird formatting before the opening PHP tag. Not sure why php --syntax-check mymodule.php didn't catch it (I copied mymodule.views.inc to mymodule.php so that I could run the syntax checker on it).

Related

Failed to load resource: net::ERR_CONTENT_DECODING_FAILED error while loading laravel css file

While executing a web page after loading HTML, CSS file is not loading & not applying the UI changes.
In browser console it is showing the following error Failed to load resource: net::ERR_CONTENT_DECODING_FAILED
One more issue is "that error is occuring only for the first time", If I reload the page the error will be gone & will load the CSS properly.
One solution I found after browsing is to enable gzip encoded, That is already in place.
Console error message
Welcome to stackoverflow.
This is a bit of an annoying error. But ill do my best Lacking what information I have on your error exactly.
What is this error?
This can happen when an HTTP request's headers say that the content is gzip encoded, but it isn't. It doesn't always happen, as you've discovered. But happens occasionally.
What can you do?
Check to see if Route::get('/') pointing to the correct
controller/code?
check to see if output_compression is added to your php.ini
Add this code: zlib.output_compression = On
try going to /config/config.php(this may not be right in your case) and set the following to false $config['compress_output'] = FALSE;
Further reading
(more about what the error actually is)
https://superuser.com/questions/172951/chrome-error-330-neterr-content-decoding-failed
https://www.solvusoft.com/en/errors/runtime-errors/google-inc/google-chrome/330-chrome-error-330/
As I referred about this cause of error, I think adding zlib.output_compression = On to php.ini will help you.
You can find this php.ini file in your php installed folder. In that find zlib.output_compression and initially it will be in OFF stage. Change it to zlib.output_compression = On.
For more information you can refer https://stefantsov.com/fixing-err_content_decoding_failed-in-apachephp/
If you are using Cloudflare make sure Brotli is enabled.
To enable Brotli, follow these steps.
Log in to your Cloudflare account.
Choose the appropriate domain.
Click the Speed app.
Click the Optimization tab.
Toggle the Brotli switch to On.
https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress-
For me the problem was this:
throw new CHttpException(Yii::t('general', 'This category has no product.'));
Becose I use Framework Yii 1.1, I changed that with this:
Yii::app()->user->setFlash('notification', "This category has no product.");
And in front-end I display the message like this:
if (Yii::app()->user->hasFlash('notification')) {
echo '<div>' . Yii::app()->user->getFlash('notification') . "</div>\n";
}

How Can I Fix Firefox Breaking My Site With Content-Security-Policy Warnings?

The site works fine on Chrome/iOS/Safari/Android (you should be able to select and image and proceed to write a message on the next step). Firefox refuses to run my project's main script (you can't select an image or go forward), and gives the following error in the console:
> Content Security Policy: Directive ‘frame-src’ has been deprecated.
> Please use directive ‘child-src’ instead. (3) Unknown
It's very cryptic. I've tried the following:
1) Adding a meta tag for the CSP in the header.
Result: Creates more errors if restrictive, same amount of errors if
left to wildcards on all parameters.
2) Locally serving all scripts.
Result: I still get three unknown CSP errors. It also loads a lot
slower since the dependencies are not being loaded from a CDN.
3) Removing specific scripts.
Result: It reduces the errors by up to one, but it seems all scripts
are equally responsible. Very strange behavior.
Is this a bug in Firefox that is unsolvable? I'm tearing my hair out over this.
I needed to put listeners in $(document).ready as Firefox loads things differently as pointed out to me by Matt Gibson.
Content Security Policy did not cause the script to fail. However, it is a weird error message that gives you no information to where the error is originating, and can potentially break the site, but that is not what happened here.

Custom error handling

I am developing a component in joomla 2.5, my component sends a request to some url and gets the response object. If i pass wrong url, joomla takes me to the default page of Error : 500 - No response code found . I want that if user install my component and mistakenly they put wrong url , it should show some custom error message/page which should more meaningful to non-programming person rather than taking user to default error page. Is there some way to add this type of functionality in Joomla without editing template/error.php file in core.
You should have an error.php file in your template, if you don't add one and make it look the way you want. also remember that when you turn debugging off you won't get the stack trace etc.
However error 500 indicates something different than that the url does not exist ("wrong URL"), which would be a 404. 500 is an internal server error and you need to check your logs to figure out what is causing it.

My Joomla component not displaying anything

I have build my own component. I know very well about these stuff but all of sudden I wonder that the joomla request to my custom component is not displaying anything. Its displaying blank page.
See this:
http://designsoft.bestplacestestserver.com/index.php?option=com_marketplacemanager
Here is the very initial code of 'marketplacemanager.php' file of component where the request is not arriving. Don't know why.
Code - marketplacemanager.php
defined('_JEXEC') or die;
jimport('joomla.application.component.helper');
echo 'aa'; exit; // should have something displayed as here
Go to global configuration. On the server tab turn error reporting to development. Reload the page. Most likely you will now see the error.
Try this, replace the first line of your code with:
defined('_JEXEC') or die('why is blank?');
If still does not show anything it means displaying errors on your server is locked, so checking the error log would be the only option.
The problem has been resolved. Actually MVC naming pattern or something else was wrong. I didn't properly renamed my existing component that I was reusing.

Magento - blank lines being added to wsdl file

I am trying to call the API but I keep getting a soap error that can't load the file. I found that the reason is there are about 3 blank lines at the top of the XML file that is returned. I found this by doing wget url.
This use to work just fine, when I debug through the API controller the response or xml looks fine all the way through, I don't see any spaces at all. I have no idea what might be causing this. I don't think there is anything we modified that would do this.
UPDATE:: I have found that it appears to be because of an observer class I made for the controller_action_predispatch event. It appears I have some spaces above the
I'm not completely sure of what I am talking about as far as I've never used the API, but you should try to look at the end of the file which generates your XML for a closing '?>'. If there is this closing PHP marker, remove it and try again you API call...
In Magento, PHP file should never be ended by a closing php marker '?>'.
edit: as said in comments, also look at spaces before the opening tag '<?php'.
First thing need to check is api.php file in root folder, most of api blank space issues will come if any empty lines added in api.php file before starting

Resources