I am using GTranslate for Joomla in my Joomla websites. It was working fine. Last day I have observed it stop working, and shows 400 errors in the console (Failed to load resource: the server responded with a status of 400 ()).
I found in the console,
"https://translate.googleapis.com/translate_a/l?[object Map Iterator]=[object Map Iterator]"
Joomla version is, 3.10.1, GTranlator version 3.7.6
The problem is in this file "media/system/js/mootools-core.js".
Specifically in this part of the code:
Array.from = function(a) {
return null == a ? [] : f.isEnumerable(a) && "string" != typeof a ? "array" == b(a) ? a : e.call(a) : [a]
}
Replace with this:
old_array_from = Array.from;
Array.from=function(a){
return null==a
?[]
:f.isEnumerable(a)&&"string"!=typeof a
?"array"==b(a)
?a
:e.call(a)
:("object" == b(a))
?old_array_from(a)
:[a];
};
Explaining:
Mootools version 1.4.5 overrides the native 'from' Array method. This causes a conflict with whoever uses Array.from() passing an object as a parameter.
Recently Google's API started to use Array.from passing an object as a parameter. Note that Google Api does not get the expected result in this part of the query string formation: "?[object Map Iterator]=[object Map Iterator]". The formation of the query string was supposed to be something like '...supportedLanguages?client=te&display_language=pt-BR&key=AIzaSyBwiZMn...'
The hack passed above uses javascript's native Array.from when passing an object as a parameter
There is lot of discussion on this. Some blame Joomla 3.10. I have been in touch with Gtranslate and then they say go to the paid version. I have escalated with them to find a solution, been pursuing this for 6 weeks now. Mootools / Jaquery is the issue i understand.
Related
I am doing HTTP testing in Codeigniter 4 and am getting the following error:
CodeIgniter\Exceptions\PageNotFoundException: Controller method is not found
The reason for this is I am trying to call a get() method on a route that only has a post (switching it to add results in a different response). That is correct. I am trying to make sure that the page returns 404 if someone tries to hack it. The problem is Codeigniter doesn't assert Status is 404 it simply falls over. Here is my code triggering:
$r = $this->withSession($session)->get($url);
$r->assertStatus(404);
Note the assert never runs! Instead I get the original error message. Surely I should be able to check for 404 routes (I've tried '404' instead of int) ?? Yes I could set a custom route that allowed Get but I want to test it as-is rather than what it isn't.
How do I get CI4 to accept my incorrect route as a 404?
My solution is to define a constant (IN_TESTING) for when I am testing and then edit system/Codeigniter run() function. This is of course amending the core system which some people won't like but until there is a fix (I am using 4.1.2) then this will suffice.
catch (PageNotFoundException $e)
{
if (!defined('IN_TESTING') || IN_TESTING == false){
$this->display404errors($e);
} else {
$this->router = Services::router($routes, $this->request);
$path = $this->determinePath();
$controller = $this->router->handle($path);
$method = $this->router->methodName();
echo $path."\n".$controller."\n".$method;
exit;
$this->response->setStatusCode(404);
return $this->response;
}
}
Key tip if you do make changes to system files, track them! If you then need to run an upgrade you'll know what changes you've made.
Several years ago I made a private Thunderbird plugin for automatically processing paypal emails about subscriptions. The user has to put the paypal emails in a certain folder "PaypalMsgs", and the plugin reads them one by one, finds out if it is a payment, a cancellation etc. and then updates the "Other" field of the person in the address book.
The plugin got broken with the recent update of Thunderbird to 45.1.0 because it cannot find the folder PaypalMsgs any more.
This is the code for finding the folder:
// determine the local root folder
var localRootFolder = Components
.classes["#mozilla.org/messenger/account-manager;1"]
.getService(Components.interfaces.nsIMsgAccountManager)
.localFoldersServer
.rootFolder;
// start with root folder to find folder with given name
this.ppPaypalFldr = this.findFldrDeep(localRootFolder, "PaypalMsgs");
// recursive function to find a folder fldr with the name fldrName
findFldrDeep: function(fldr, fldrName) {
if(fldr.name == fldrName) {
return fldr;
} else {
if(fldr.hasSubFolders) {
var fldrEnum = fldr.subFolders;
while(fldrEnum.hasMoreElements()) {
var sfldr = fldrEnum.getNext();
var result = this.findFldrDeep(sfldr, fldrName);
if(result) {
return result;
}
}
} else {
return null;
}
}
},
When executed nothing happens and TB's error console shows:
Error: TypeError: this.ppPaypalFldr undefined
at the first location where this.ppPaypalFldr is used
It might be an easy thing, like the definition of the services of nsIMsgAccountManager might have changed or the folder type suddenly has different functions, but I have a really hard time to find reliable documentation or even the source for TB 45.
Thank you for any hints and support!
After more seach, debugging and thinking (sic!) I found the problem:
At the line
var sfldr = fldrEnum.getNext();
The interface is missing and it looks like in TB45 something has changed so the interface is not automatically retrieved from somewhere (the software worked without this interface since about 4 or 5 years).
So the correct line is:
var sfldr = fldrEnum.getNext().QueryInterface(Components.interfaces.nsIMsgFolder);
I also checked all of the plugin and added all interfaces - now it works like a charm.
Writing the problem here alone has helped me a lot to find the solution ;-)
How can I show a validation error for a form field outside of a field constructor in Play framework 2? Here is what I tried:
#eventForm.("name").error.message
And I get this error:
value message is not a member of Option[play.api.data.FormError]
I'm confused because in the api docs it says message is a member of FormError. Also this works fine for global errors:
#eventForm.globalError.message
You can get a better grasp of it checking Form's sourcecode here
Form defines an apply method:
def apply(key: String): Field = Field(
this,
key,
constraints.get(key).getOrElse(Nil),
formats.get(key),
errors.collect { case e if e.key == key => e },
data.get(key))
That, as said in the doc, returns any field, even if it doesn't exist. And a Field has an errors member which returns a Seq[FormError]:
So, you could do something like that (for the Seq[FormError]):
eventForm("name").errors.foreach { error =>
<div>#error.message</div>
}
Or (for the Option[FormError])
eventForm("name").error.map { error =>
<div>#error.message</div>
}
Or, you could use Form errors:
def errors(key: String): Seq[FormError] = errors.filter(_.key == key)
And get all errors of a given key. Like this (for the Seq[FormError]):
eventForm.errors("name").foreach { error =>
<div>#error.message</div>
}
Or (for the Option[FormError])
eventForm.error("name").map { error =>
<div>#error.message</div>
}
If you want more details, check the source code. It's well written and well commented.
Cheers!
EDIT:
As biesior commented: to show human readable pretty messages with different languages you have to check how play works I18N out here
To be thorough you're probably going to have to deal with I18N. It's not hard at all to get it all working.
After reading the documentation you may still find yourself a bit consufed. I'll give you a little push. Add a messages file to your conf folder and you can copy its content from here. That way you'll have more control over the default messages. Now, in your view, you should be able to do something like that:
eventForm.errors("name").foreach { error =>
<div>#Messages(error.message, error.args: _*)</div>
}
For instance, if error.message were error.invalid it would show the message previously defined in the conf/messages file Invalid value. args define some arguments that your error message may handle. For instance, if you were handling an error.min, an arg could be the minimum value required. In your message you just have to follow the {n} pattern, where n is the order of your argument.
Of course, you're able to define your own messages like that:
error.futureBirthday=Are you sure you're born in the future? Oowww hay, we got ourselves a time traveler!
And in your controller you could check your form like that (just one line of code to show you the feeling of it)
"year" -> number.verifying("error.furtureBirthday", number <= 2012) // 2012 being the current year
If you want to play around with languages, just follow the documentation.
Cheers, again!
As you said yourself, message is a member of FormError, but you have an Option[FormError]. You could use
eventForm("name").error.map(_.message).getOrElse("")
That gives you the message, if there is an error, and "" if there isn't.
In ExtJS 4.1.3 we have a filter setup on a text field to run 'onchange' of the text field. This is the function onchange:
var store = this.getStore();
value = field.getValue();
if (value.length > 0) {
// Param name is ignored here since we use custom encoding in the proxy.
// id is used by the Store to replace any previous filter
store.filter({
id: 'query',
property: 'query',
value: 'LegalName|#|#|' + value
});
} else {
store.clearFilter();
}
Now, we are running into an issue where when I type something in the text field too fast I am getting errors and am getting stuck on a load screen. When I type in the same thing slowly it works. Considering typing it in slowly makes it work, but fast makes it fail and the data coming back from the server is the same in both instances, I'm assuming it's an issue with ExtJS. Has anyone seen an issue like this? What are potential problems and fixes. I can't figure out why it's breaking. Here is the trail I get:
Uncaught TypeError: Cannot convert null to object ext-all-debug.js:51752
Ext.define.cancelAllPrefetches ext-all-debug.js:51752
Ext.util.Event.Ext.extend.fire ext-all-debug.js:8638
Ext.define.continueFireEvent ext-all-debug.js:25117
Ext.define.fireEvent ext-all-debug.js:25095
Ext.define.clear ext-all-debug.js:44718
Base.implement.callParent ext-all-debug.js:3735
Ext.define.clear ext-all-debug.js:47485
Base.implement.callParent ext-all-debug.js:3735
PageMap.Ext.Class.clear ext-all-debug.js:52358
Ext.define.filter ext-all-debug.js:51377
Ext.define.onTextfieldChange /TEST/app/view/ContractGrid.js?_dc=1354553533935:447
Ext.util.Event.Ext.extend.fire ext-all-debug.js:8638
Ext.define.continueFireEvent ext-all-debug.js:25117
Ext.define.fireEvent ext-all-debug.js:25095
Ext.override.fireEvent ext-all-debug.js:58382
Ext.define.checkChange ext-all-debug.js:30310
call ext-all-debug.js:8426
Any thoughts?
I was able to fix the issue by changing the buffer setting on the store. Looks like I had set 'buffered' to true in the store and once I removed it, the issue went away.
This is a sort of followup to my other MongoDB question about the torrent indexer.
I'm making an open source torrent indexer (like a mini TPB, in essence), and offer both SQLite and MongoDB for backend, currently.
However, I'm having trouble with the MongoDB part of it. In Sinatra, I get when trying to upload a torrent, or search for one.
In uploading, one needs to tag the torrent — and it fails here. The code for adding tags is as follows:
def add_tag(tag)
if $sqlite
unless tag_exists? tag
$db.execute("insert into #{$tag_table} values ( ? )", tag)
end
id = $db.execute("select oid from #{$tag_table} where tag = ?", tag)
return id[0]
elsif $mongo
unless tag_exists? tag
$tag.insert({:tag => tag})
end
return $tag.find({:tag => tag})[:_id] #this is the line it presumably crashes on
end
end
It reaches line 105 (noted above), and then fails. What's going on? Also, as an FYI this might turn into a few other questions as solutions come in.
Thanks!
EDIT
So instead of returning the tag result with [:_id], I changed the block inside the elsif to:
id = $tag.find({:tag => tag})
puts id.inspect
return id
and still get an error. You can see a demo at http://torrent.hypeno.de and the source at http://github.com/tekknolagi/indexer/
Given that you are doing an insert(), the easiest way to get the id is:
id = $tag.insert({:tag => tag})
id will be a BSON::ObjectId, so you can use appropriate methods depending on the return value you want:
return id # BSON::ObjectId('5017cace1d5710170b000001')
return id.to_s # "5017cace1d5710170b000001"
In your original question you are trying to use the Collection.find() method. This returns a Mongo::Cursor, but you are trying to reference the cursor as a document. You need to iterate over the cursor using each or next, eg:
cursor = $tag.find_one({:tag => tag})
return cursor.next['_id'];
If you want a single document, you should be using Collection.find_one().
For example, you can find and return the _id using:
return $tag.find_one({:tag => tag})['_id']
I think the problem here is [:_id]. I dont know much about Mongo but `$tag.find({:tag => tag}) is probably retutning an array and passing a symbol to the [] array operator is not defined.