Cannot create new opportunity in Vtiger? incorrect integer value - vtiger

Could you please give me a hand to correct the error when I created new opportunity in Vtiger CRM.
The cause is "incorrect integer value '' when system insert '' into int field.
There is solution to solve it by set sql mode. But I'm using shared hosting. Provider cannot to do this one.

In vtiger by default it use mysqli as DB type which will be defined in config.inc.php file
$dbconfig['db_type'] = 'mysqli';
I would suggest you to set SQL mode runtime by defining this line in Library file which vtiger using for DB connection
\vtiger\libraries\adodb\drivers\adodb-mysqli.inc.php
Add on line code at line no 126
Previous code
if ($ok) {
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
} else {
if ($this->debug)
ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
$this->_connectionID = null;
return false;
}
Latest Code
if ($ok) {
mysqli_query($this->_connectionID, "SET SESSION sql_mode = 'TRADITIONAL'");
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
} else {
if ($this->debug)
ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
$this->_connectionID = null;
return false;
}
Hope this helps you

Related

Error 'unknown MongoDB operation 'aggregate'' when using aggregate in WSo2 Integration Studio?

I am working Wso2 Integration Studio 8.1 version. I want to using aggregate query. But Wso2 Integration Studip giving error as DS Fault Message: Error in MongoQuery.runQuery: DS Fault Message: Unknown MongoDB operation 'aggregate'
I'm afraid it seems the Micro Integrator doesn't support it at the moment. This is from the code which supports the following operations.
private DBConstants.MongoDB.MongoOperation convertToMongoOp(String operation) throws DataServiceFault {
if (DBConstants.MongoDB.MongoOperationLabels.COUNT.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.COUNT;
} else if (DBConstants.MongoDB.MongoOperationLabels.DROP.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.DROP;
} else if (DBConstants.MongoDB.MongoOperationLabels.FIND.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.FIND;
} else if (DBConstants.MongoDB.MongoOperationLabels.FIND_ONE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.FIND_ONE;
} else if (DBConstants.MongoDB.MongoOperationLabels.INSERT.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.INSERT;
} else if (DBConstants.MongoDB.MongoOperationLabels.REMOVE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.REMOVE;
} else if (DBConstants.MongoDB.MongoOperationLabels.UPDATE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.UPDATE;
} else if (DBConstants.MongoDB.MongoOperationLabels.EXISTS.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.EXISTS;
} else if (DBConstants.MongoDB.MongoOperationLabels.CREATE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.CREATE;
} else {
throw new DataServiceFault("Unknown MongoDB operation '" + operation + "'");
}
}
Even the MongoDB connector doesn't support Aggregate operation, hence your best option is to write a Custom mediator to get this done or try to improve the existing connector.

Magento 2.3.3 dashboard keeps loading

I have installed latest version of magento in my localhost.
After login to admin panel dashboard keeps loading.
Here is the image-
Please help to solve this error.
First Go to magento root directory then :
vendor/magento/framework/view/element/tempalate/file/validator.php (dont exactly copy this url just follow this path)
open this file using any editor and change this line
$realPath = $this->fileDriver->getRealPath($path); //you can comment this out
with this one
$realPath = str_replace('\\','/',$this->fileDriver->getRealPath($path));
then goto to
app/etc/di.xml
and search for view_preprocessed
you will find a whole line like this :
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
and change the Symlink with Copy
Magento 2.3
go to \lib\internal\Magento\Framework\View\Element\Template\File
go to the function isPathInDirectories and replace the function with following
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
//$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\','/',$this->fileDriver->getRealPath($path));
foreach ($directories as $directory) {
//$realDirectory = $this->fileDriver->getRealPath($directory);
$realDirectory = str_replace('\\','/',$this->fileDriver->getRealPath($directory));
if ($realDirectory && 0 === strpos($realPath, $realDirectory)) {
return true;
}
}
return false;
}
go to app/etc/di.xml then search for view_preprocessed
you will find a whole line like this :
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink and change to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
#1. go to vendor/magento/framework/View/Element/Template/File/Validator.php#
#2. go to the function isPathInDirectories and replace the function with following:#
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
//$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\','/',$this->fileDriver->getRealPath($path));
foreach ($directories as $directory) {
//$realDirectory = $this->fileDriver->getRealPath($directory);
$realDirectory = str_replace('\\','/',$this->fileDriver->getRealPath($directory));
if ($realDirectory && 0 === strpos($realPath, $realDirectory)) {
return true;
}
}
return false;
}
#3. go to app/etc/di.xml then search for view_preprocessed
you will find a whole line like this :
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink and change to
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy #

Google Application Credentials set and not found

I have an Amazon EC2 with Linux Instance set up and running for my Java Web Application to consume REST requests. The problem is that I am trying to use Google Cloud Vision in this application to recognize violence/nudity in users pictures.
Accessing the EC2 in my Terminal, I set the GOOGLE_APPLICATION_CREDENTIALS by the following command, which I found in the documentation:
export GOOGLE_APPLICATION_CREDENTIALS=<my_json_path.json>
Here comes my first problem: When I restart my server, and ran 'echo $GOOGLE_APPLICATION_CREDENTIALS' the variable is gone. Ok, I set it to the bash_profile and bashrc and now it is ok.
But, when I ran my application, consuming the above code, to get the adult and violence status of my picture, I got the following error:
java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
My code is the following:
Controller:
if(SafeSearchDetection.isSafe(user.getId())) {
if(UserDB.updateUserProfile(user)==false){
throw new SQLException("Failed to Update");
}
} else {
throw new IOException("Explicit Content");
}
SafeSearchDetection.isSafe(int idUser):
String path = IMAGES_PATH + idUser + ".jpg";
try {
mAdultMedicalViolence = detectSafeSearch(path);
if(mAdultMedicalViolence.get(0) > 3)
return false;
else if(mAdultMedicalViolence.get(1) > 3)
return false;
else if(mAdultMedicalViolence.get(2) > 3)
return false;
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return true;
detectSafeSearch(String path):
List<AnnotateImageRequest> requests = new ArrayList<AnnotateImageRequest>();
ArrayList<Integer> adultMedicalViolence = new ArrayList<Integer>();
ByteString imgBytes = ByteString.readFrom(new FileInputStream(path));
Image img = Image.newBuilder().setContent(imgBytes).build();
Feature feat = Feature.newBuilder().setType(Type.SAFE_SEARCH_DETECTION).build();
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
requests.add(request);
ImageAnnotatorClient client = ImageAnnotatorClient.create();
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
System.out.println("Error: "+res.getError().getMessage()+"\n");
return null;
}
SafeSearchAnnotation annotation = res.getSafeSearchAnnotation();
adultMedicalViolence.add(annotation.getAdultValue());
adultMedicalViolence.add(annotation.getMedicalValue());
adultMedicalViolence.add(annotation.getViolenceValue());
}
for(int content : adultMedicalViolence)
System.out.println(content + "\n");
return adultMedicalViolence;
My REST application was built above a Tomcat8. After no success running the command:
System.getenv("GOOGLE_APPLICATION_CREDENTIALS")
I realize that my problem was in the Environment Variables to Tomcat installation. To correct this, I just created a new file setenv.sh in my /bin with the content:
GOOGLE_APPLICATION_CREDENTIALS=<my_json_path.json>
And it worked!

C++ Legacy Driver mongoDB Replicaset in Class of a DLL

I have built a dll which includes a class implementing the mongoDB replicaset operations. Here is a summary of the class.
#include "mongo/client/dbclient.h"
mongoimp::mongoimp() {
mongo::client::initialize();
}
mongoimp::~mongoimp() {
mongo::client::shutdown();
}
int mongoimp::queryTRecords() {
string errmsg;
vector<mongo::HostAndPort> hosts = { mongo::HostAndPort("xx-a0.yyyy.com:xxxxx"), mongo::HostAndPort("xx-a1.yyyy.com:xxxxx") };
static mongo::DBClientReplicaSet con("xx", hosts, 0);
con.connect();
con.auth("dbname", "username", "password", errmsg);
auto_ptr<DBClientCursor> cursor = con.query("dbname.t", BSONObj());
BSONObj response;
con.logout("xx", response);
if (cursor->more()) {
BSONObj recordnm = cursor->nextSafe();
return(recordnm.getIntField("lastid"));
} else return(-1);
}
The above code is working. But here are my questions:
1) With the above setting, I can do normal mongoDB operations with the dll but since my application needs to constantly update mongoDB data (close to real-time, up to hundreds a second), I am getting error (No valid replicaset instance servers found) when updating data.
2) Only the server needs to talk to the mongoDB database. So basically I just need one connection to the database. So I want to declare the mongo::DBClientReplicaSet con as a static global variable and connect to it in the class construct function. But it seemed I cannot do it. My application cannot run at all. With that, I constantly get the following error.
Assertion failed: px != 0, file C:\Boost\include\boost-1_62\boost/smart_ptr/scoped_ptr.hpp, line 105
Does anybody know how to solve the problem?
Below is the code I tried:
static mongo::DBClientReplicaSet con("xx", { mongo::HostAndPort("xx-a0.yyyy.com:xxxxx"), mongo::HostAndPort("xx-a1.yyyy.com:xxxxx") }, 0);
mongoimp::mongoimp() {
mongo::client::initialize();
string errmsg;
con.connect();
con.auth("dbname", "username", "password", errmsg);
}
mongoimp::~mongoimp() {
BSONObj response;
con.logout("xx", response);
mongo::client::shutdown();
}
int mongoimp::queryTRecords() {
auto_ptr<DBClientCursor> cursor = con.query("dbname.t", BSONObj());
if (cursor->more()) {
BSONObj recordnm = cursor->nextSafe();
return(recordnm.getIntField("lastid"));
} else return(-1);
}
3) Last question, I noticed there is mongo/client/dbclient_rs.h" file for replicaset. But it seemed I cannot use it. With that, I am getting error for initialize() and auto_ptr cursor. How can I use the file and take full advantage of replicaset features? How can I initialize the relica set if I can use "dbclient_rs.h"? How do I do query and fetch data in that case?
Thanks a lot in advance!
For question No. 2, I remembered the reason for the error:
You need to call mongo::client::initialize before you construct any driver objects, or BSON for that matter.
But how to make that global definition possible, I still need a solution.

c++ MySql Connector Query always returns true even if errored

I am using MySql C++ Connector latest build in a c++ app
But every query i make to any table it returns true
E.x. code :
string MyQueryTest(){
string returnValue;
try{
stmt->execute("UPDATE testtbl SET Name = 'Test' WHERE id = '2'");
}
catch(SQLException e){
returnValue = "false";
}
returnValue = "true";
return returnValue;
}
string MyValue = MyQueryTest();
The above code return true though in my testtbl there is no id = 2 data, i have only one data entered which is id = 1 Name = MyTests
Does anyone knows any solutions around this ?
I have tried to place the returnValue = "true" inside the try statement,
also i used exit(1) function inside catch error function
None got me the desired returnValue to false which is the correct return of the above code
It's not an exceptional case when there is no data to be updated. SQLException will be thrown if you have problems with connection to Database or SQL query syntax is incorrect.
Statement class has executeUpdate() method that returns number of affected rows, you can use it to achieve your aim.