I've searched the web for days but can't find a solution. I upgraded Magento from 1.5 to 1.9 and everything works fine. Except the checkout. On the last step it gets stuck every single time on "submitting order information".
System log says the following (but a minute before the error occurs. In the stuck position I don't get any error)
2016-08-07T22:23:16+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /var/www/html/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /var/www/html/lib/Zend/Controller/Response/Abstract.php:768
[2] /var/www/html/app/code/core/Mage/Core/Controller/Response/Http.php:84
[3] /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php:184
[4] /var/www/html/app/code/core/Mage/Core/Model/App.php:365
[5] /var/www/html/app/Mage.php:684
[6] /var/www/html/index.php:83</pre>
Console on the checkout site:
VK. Startup (background is ready)
prototype.js:5557 Uncaught TypeError: Cannot read property 'get' of undefined_createResponder # prototype.js:5557observe # prototype.js:5636(anonymous function) # (index):896
prototype.js:5557 Uncaught TypeError: Cannot read property 'get' of undefined_createResponder # prototype.js:5557observe # prototype.js:5636(anonymous function) # (index):1033
(index):1 Mixed Content: The page at 'https://www.owndomain.com/checkout/onepage/' was loaded over HTTPS, but requested an insecure script 'http://www.googleadservices.com/pagead/conversion.js'. This request has been blocked; the content must be served over HTTPS.
content.js:37 UA. Wait for background...
Does anybody have an additional idea? I have edited all template files with the formkey tag.
Edit:
The code of the found file:
if (empty ($_POST)) {
header("Location: " . $_SESSION['back_url']);
$this->_redirect(str_replace(Mage::getBaseUrl(), '', $_SESSION['back_url']));
}
$formData = $this->getRequest()->getPost('super_attribute');
$product_id = $this->getRequest()->getPost('pro_id');
$options = $this->getRequest()->getPost('options');
$params = $this->getRequest()->getParams();
//mage::log($params);
$url = $this->getRequest()->getPost('url');
$qty = $this->getRequest()->getPost('qty');
$type = $this->getRequest()->getPost('type');
if (!isset($qty))
$qty = 1;
if (isset($product_id)) {
try {
$request = Mage::app()->getRequest();
$product = Mage::getModel('catalog/product')->load($product_id);
$session = Mage::getSingleton('core/session', array('name' => 'frontend'));
$cart = Mage::helper('checkout/cart')->getCart();
/*
if (isset($formData)){
$arr = array(
'qty' => $qty,
'super_attribute' => $formData,
'options' => $options
);
$cart->addProduct($product, $arr);}
else
$cart->addProduct($product, $qty);
*/
$cart->addProduct($product, $params);
$session->setLastAddedProductId($product->getId());
$session->setCartWasUpdated(true);
$cart->save();
$_cart = Mage::helper('checkout/cart')->getCart();
$_cartcount = 0;
$_cartsubtotal = 0;
$items = $_cart->getItems();
$_SESSION['back_url'] = $url;
$result = $this->getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('ajaxcart/cart/sidebar.phtml')
->addItemRender('simple', 'checkout/cart_item_renderer', 'checkout/cart/sidebar/default.phtml')
->addItemRender('configurable', 'checkout/cart_item_renderer_configurable', 'checkout/cart/sidebar/default.phtml')
->addItemRender('grouped', 'checkout/cart_item_renderer_grouped', 'checkout/cart/sidebar/default.phtml')
->toHtml();
echo $result;
} catch (Exception $e) {
echo 1;
}
} else {
echo 0;
Best,
IT0055
Related
The issue:
Because of issues with the JavaScript code loading I am trying to integrate sentry with the tunnel option. This would prevent the blocking, if a user has an ad-blocker enabled.
https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option
Now they provide an example code for this tunnel in their documentation:
<?php
// Change $host appropriately if you run your own Sentry instance.
$host = "sentry.io";
// Set $known_project_ids to an array with your Sentry project IDs which you
// want to accept through this proxy.
$known_project_ids = array( );
$envelope = stream_get_contents(STDIN);
$pieces = explode("\n", $envelope, 2);
$header = json_decode($pieces[0], true);
if (isset($header["dsn"])) {
$dsn = parse_url($header["dsn"]);
$project_id = intval(trim($dsn["path"], "/"));
if (in_array($project_id, $known_project_ids)) {
$options = array(
'http' => array(
'header' => "Content-type: application/x-sentry-envelope\r\n",
'method' => 'POST',
'content' => $envelope
)
);
echo file_get_contents(
"https://$host/api/$project_id/envelope/",
false,
stream_context_create($options));
}
}
In the app.php, the layout file of my project, I am calling the JavaScript Sentry like this:
<script src="{{ asset('/assets/js/app.js') }}" crossorigin="anonymous"></script>
My question:
What I don't understand is how to integrate this into the web.php as a route. So it gets called everytime an JavaScript error occured.
You should be able to define a route like this:
Route::post('/sentry-tunnel', function (Request $request) {
// Change $host appropriately if you run your own Sentry instance.
$host = "sentry.io";
// Set $known_project_ids to an array with your Sentry project IDs which you
// want to accept through this proxy.
$known_project_ids = [];
$envelope = $request->getContent();
$pieces = explode("\n", $envelope, 2);
$header = json_decode($pieces[0], true);
if (isset($header['dsn'])) {
$dsn = parse_url($header['dsn']);
$project_id = intval(trim($dsn['path'], '/'));
if (in_array($project_id, $known_project_ids)) {
return Http::withBody($envelope, "application/x-sentry-envelope")
->post("https://$host/api/$project_id/envelope/");
}
}
});
And then call the URL '/sentry-tunnel' from your JavaScript. Don't forget to add your project ID and credentials if necessary.
exactly the same problem than on this post
follow carefully the documentation (official)
https://docs.sencha.com/extjs/6.5.3/guides/backend_connectors/direct/mysql_php.html
did not understand how to solve it
edit
here is a screenshot of firefox console
api.php (the file where the error is)
(took from ext js documentation and sdk examples)
<?php
require('config.php');
header('Content-Type: text/javascript');
$API = get_extdirect_api('api');
# convert API config to Ext Direct spec
$actions = array();
foreach($API as $aname=>&$a){
$methods = array();
foreach($a['methods'] as $mname=>&$m){
if (isset($m['len'])) {
$md = array(
'name'=>$mname,
'len'=>$m['len']
);
} else {
$md = array(
'name'=>$mname,
'params'=>$m['params']
);
}
if(isset($m['formHandler']) && $m['formHandler']){
$md['formHandler'] = true;
}
if (isset($m['metadata'])) {
$md['metadata'] = $m['metadata'];
}
$methods[] = $md;
}
$actions[$aname] = $methods;
}
$cfg = array(
'url'=>'data/direct/router.php',
'type'=>'remoting',
'actions'=>$actions
);
echo 'var Ext = Ext || {}; Ext.REMOTING_API = ';
echo json_encode($cfg);
echo ';';
?>
app.json edited part as asked in the tutorial i linked
"js": [
{
"path": "${framework.dir}/build/ext-all-rtl-debug.js"
},
{
"path": "php/api.php",
"remote": true
},
{
"path": "app.js",
"bundle": true
}
],
application.js
/**
* The main application class. An instance of this class is created by app.js when it
* calls Ext.application(). This is the ideal place to handle application launch and
* initialization details.
*/
Ext.define('DirectApp.Application', {
extend: 'Ext.app.Application',
name: 'DirectApp',
quickTips: false,
platformConfig: {
desktop: {
quickTips: true
}
},
launch: function () {
Ext.direct.Manager.addProvider(Ext.REMOTING_API);
},
onAppUpdate: function () {
Ext.Msg.confirm('Application Update', 'This application has an update, reload?',
function (choice) {
if (choice === 'yes') {
window.location.reload();
}
}
);
}
});
index.html
<!DOCTYPE HTML>
<html manifest="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">
<title>DirectApp</title>
<!-- The line below must be kept intact for Sencha Cmd to build your application -->
<script id="microloader" data-app="70f32dd6-f700-4939-bc96-3af4f1c9798b" type="text/javascript" src="bootstrap.js"></script>
</head>
<body></body>
</html>
here is the router took from sdk examples as i say you can do it in the tutorial
<?php
require('config.php');
class BogusAction {
public $action;
public $method;
public $data;
public $tid;
}
$isForm = false;
$isUpload = false;
if(isset($HTTP_RAW_POST_DATA)){
header('Content-Type: text/javascript');
$data = json_decode($HTTP_RAW_POST_DATA);
}else if(isset($_POST['extAction'])) { // form post
$isForm = true;
$isUpload = $_POST['extUpload'] == 'true';
$data = new BogusAction();
$data->action = $_POST['extAction'];
$data->method = $_POST['extMethod'];
$data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null; // not set for upload
$data->data = array($_POST, $_FILES);
}else if (($data = file_get_contents('php://input')) !== '') {
$data = json_decode($data);
}else{
die('Invalid request.');
}
function doRpc($cdata){
$API = get_extdirect_api('router');
try {
if(!isset($API[$cdata->action])){
throw new Exception('Call to undefined action: ' . $cdata->action);
}
$action = $cdata->action;
$a = $API[$action];
doAroundCalls($a['before'], $cdata);
$method = $cdata->method;
$mdef = $a['methods'][$method];
if(!$mdef){
throw new Exception("Call to undefined method: $method on action $action");
}
doAroundCalls($mdef['before'], $cdata);
$r = array(
'type'=>'rpc',
'tid'=>$cdata->tid,
'action'=>$action,
'method'=>$method
);
require_once("classes/$action.php");
$o = new $action();
if (isset($mdef['len'])) {
$params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array();
} else {
$params = array($cdata->data);
}
array_push($params, $cdata->metadata);
$r['result'] = call_user_func_array(array($o, $method), $params);
doAroundCalls($mdef['after'], $cdata, $r);
doAroundCalls($a['after'], $cdata, $r);
}
catch(Exception $e){
$r['type'] = 'exception';
$r['message'] = $e->getMessage();
$r['where'] = $e->getTraceAsString();
}
return $r;
}
function doAroundCalls(&$fns, &$cdata, &$returnData=null){
if(!$fns){
return;
}
if(is_array($fns)){
foreach($fns as $f){
$f($cdata, $returnData);
}
}else{
$fns($cdata, $returnData);
}
}
$response = null;
if(is_array($data)){
$response = array();
foreach($data as $d){
$response[] = doRpc($d);
}
}else{
$response = doRpc($data);
}
if($isForm && $isUpload){
echo '<html><body><textarea>';
echo json_encode($response);
echo '</textarea></body></html>';
}else{
echo json_encode($response);
}
?>
QueryDatabase.php (sql request php file)
<?php
class QueryDatabase {
private $_db;
protected $_result;
public $results;
public function __construct() {
$this->_db = new mysqli(MY CREDENTIALS);
$_db = $this->_db;
if ($_db->connect_error) {
die('Connection Error: ' . $_db->connect_error);
}
return $_db;
}
public function getResults($params) {
$_db = $this->_db;
$_result = $_db->query("SELECT name,email,phone FROM heroes") or
die('Connection Error: ' . $_db->connect_error);
$results = array();
while ($row = $_result->fetch_assoc()) {
array_push($results, $row);
}
$this->_db->close();
return $results;
}
}
and finally config.php file
<?php
function get_extdirect_api() {
$API = array(
'QueryDatabase' => array(
'methods' => array(
'getResults' => array(
'len' => 1
)
)
)
);
return $API;
}
edit2
here is full network tab from firefox screenshots
edit 3
here is api.php details from network tab
answer
headers
stack trace
here is the configuration file sencha.cfg which is configuration of the minimal web server provided my sencha CMD
# sencha.cfg
#
# This is the main configuration file for Sencha Cmd. The properties defined in
# this file are used to initialize Sencha Cmd and should be edited with some
# caution.
#
# On previous versions, this file provided a way to specify the cmd.jvm.* properties
# to control the execution of the JVM. To accommodate all possible execution scenarios
# support for these properties has been removed in favor of using the _JAVA_OPTIONS
# environment variable.
#
#------------------------------------------------------------------------------
# This indicates the platform that Cmd is installed on. This is used for
# platform specific package management.
#
# Possible values: windows, osx, linux, linux-x64
#
# cmd.platform=
#------------------------------------------------------------------------------
# This is the Sencha Cmd version.
#
# THIS PROPERTY SHOULD NOT BE MODIFIED.
cmd.version=6.5.3.6
#------------------------------------------------------------------------------
# This indicates the level of backwards compatibility provided. That is to say,
# apps requiring versions between cmd.minver and cmd.version (inclusive) should
# be able to use this version.
#
# THIS PROPERTY SHOULD NOT BE MODIFIED.
cmd.minver=3.0.0.0
#------------------------------------------------------------------------------
# The folder for the local package repository. By default, this folder is shared
# by all versions of Sencha Cmd. In other words, upgrading Sencha Cmd does not
# affect the local repository.
repo.local.dir=${cmd.dir}/../repo
#------------------------------------------------------------------------------
# This is the default port to use for the Sencha Cmd Web Server.
cmd.web.port=1841
#------------------------------------------------------------------------------
# Java System Properties
#
# By setting any "system.*" properties you can set Java System Properties. For
# general information on these, see:
#
# http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
#
#------------------------------------------------------------------------------
# Proxy Settings
#
# The primary reason to set Java System Properties is to handle HTTP Proxies.
# By default, Java uses "http.proxy*" properties to configure HTTP proxies, but
# the "java.net.useSystemProxies" option can be enabled to improve the use of
# system-configured proxy settings based on your platform. If this setting does
# not work for your proxy server setup, try disabling this setting by commenting
# it out and enabling the other settings. See also this information on proxy
# setup:
#
# http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
#
# NOTE: If you find that you need to adjust these settings, you may want to do
# so in a "sencha.cfg" file one folder above this folder. The settings in that
# file override these settings, so be sure to only copy the settings you need
# to that location. The advantage to putting these settings in that location is
# that they will not be "lost" as you upgrade Cmd.
system.java.net.useSystemProxies=true
# These are the legacy options that come in to play when the above is commented
# out:
#system.http.proxyHost=proxy.mycompany.com
#system.http.proxyPort=80
#system.http.proxyUser=username
#system.http.proxyPassword=password
#------------------------------------------------------------------------------
# Merge Tool Settings
#
# To enable use of a visual merge tool to resolve merge conflicts, set the
# following property to the desired merge tool path:
#
# cmd.merge.tool=p4merge
#
# Next, to configure the arguments for the merge tool, set this property:
#
# cmd.merge.tool.args={base} {user} {generated} {out}
#
# Alternatively, the arguments for several merge tools are defined below and can
# be used in your configuration for simplicity/clarity like so:
#
# cmd.merge.tool.args=${cmd.merge.tool.args.sourcegear}
#
# NOTE: the cmd.merge.tool.args property is split on spaces *then* the tokens
# are replaced by actual files names. This avoids the need to quote arguments to
# handle spaces in paths.
#
# NOTE: Some merge tools (like SmartSynchronize) do not accept the output file
# separately so there is no way to know if the merge was completed. In this case,
# the base file is where the result is written so Cmd just copies the content of
# that file back as the result.
#
# You can add the appropriate lines to customize your Cmd configuration. See
# below for details.
# The arguments for p4merge, see below for download:
# http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools
cmd.merge.tool.args.p4merge={base} {user} {generated} {out}
# SourceGear (http://www.sourcegear.com/diffmerge/index.html)
cmd.merge.tool.args.sourcegear=--merge --result={out} {user} {base} {generated}
# kdiff3 (http://sourceforge.net/projects/kdiff3/files/kdiff3/)
cmd.merge.tool.args.kdiff3={base} {user} {generated} -o {out}
# Syntevo SmartSynchronize 3 (http://www.syntevo.com/smartsynchronize/index.html).
cmd.merge.tool.args.smartsync={user} {generated} {base}
# TortoiseMerge (part of TortoiseSVN - see http://tortoisesvn.net).
cmd.merge.tool.args.tortoise=-base:{base} -theirs:{generated} -mine:{user} -merged:{out}
# AraxisMerge (see http://www.araxis.com/merge-overview.html):
cmd.merge.tool.args.araxis=-wait -merge -3 -a1 {base} {user} {generated} {out}
# The address where Sencha Inspector is located
inspector.address=http://localhost:1839/
# this variable references a json file containing unicode code points to be
# printed in escaped form during code generation.
cmd.unicode.escapes=${cmd.dir}/unicode-escapes.json
#------------------------------------------------------------------------------
# Customizing Configuration
#
# Customization can be handled any of these ways:
#
# 1. Place customizations in this file (ideally at the bottom) and they will
# configure this instance of Sencha Cmd.
#
# 2. Create a "sencha.cfg" file in the folder above this instance of Sencha Cmd
# to be shared by all installed versions.
#
# 3. Create a "~/.sencha/cmd/sencha.cfg" file. On Windows, the "~" maps to your
# %HOMEDRIVE%%HOMEPATH% folder (e.g., "C:\Users\Me").
#
# Your personal settings take priority over common settings (item #2) which both
# take priority of instance settings (this file).
thank you
I guess you are also following the guide and using the sencha app watch and getting the php code returning back to you. I found this answer on a Sencha forum that the web server that the sencha cmd provides doesn't support php is just a basic HTTP web server.
I was looking at the exact same thing today and came across the post....
For anyone else looking for the problem this is how i fixed it. Basically you have to get the posted data in a slightly different manner... looks at the first comment in the code below
<?php
require('config.php');
class BogusAction {
public $action;
public $method;
public $data;
public $tid;
}
$isForm = false;
$isUpload = false;
// different way to get the data that is posted to the URL
$postData = file_get_contents('php://input');
if (isset($postData)) {
header('Content-Type: text/javascript');
$data = json_decode($postData);
}
else if (isset($HTTP_RAW_POST_DATA)) {
header('Content-Type: text/javascript');
$data = json_decode($HTTP_RAW_POST_DATA);
}
else if(isset($_POST['extAction'])){ // form post
$isForm = true;
$isUpload = $_POST['extUpload'] == 'true';
$data = new BogusAction();
$data->action = $_POST['extAction'];
$data->method = $_POST['extMethod'];
$data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null;
$data->data = array($_POST, $_FILES);
}
else {
die('Invalid request min .');
}
function doRpc($cdata){
$API = get_extdirect_api('router');
try {
if (!isset($API[$cdata->action])) {
throw new Exception('Call to undefined action: ' . $cdata->action);
}
$action = $cdata->action;
$a = $API[$action];
$method = $cdata->method;
$mdef = $a['methods'][$method];
if (!$mdef){
throw new Exception("Call to undefined method: $method " .
"in action $action");
}
$r = array(
'type'=>'rpc',
'tid'=>$cdata->tid,
'action'=>$action,
'method'=>$method
);
require_once("classes/$action.php");
$o = new $action();
if (isset($mdef['len'])) {
$params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array();
}
else {
$params = array($cdata->data);
}
$r['result'] = call_user_func_array(array($o, $method), $params);
}
catch(Exception $e){
$r['type'] = 'exception';
$r['message'] = $e->getMessage();
$r['where'] = $e->getTraceAsString();
}
return $r;
}
$response = null;
if (is_array($data)) {
$response = array();
foreach($data as $d){
$response[] = doRpc($d);
}
}
else{
$response = doRpc($data);
}
if ($isForm && $isUpload){
echo '<html><body><textarea>';
echo json_encode($response);
echo '</textarea></body></html>';
}
else{
echo json_encode($response);
}
?>
I'm using a Genesis LifeStyle Pro child theme.
URL: https://www.test.rainerklar.de/blog-fuer-verjuengung-und-gesundheit/
On my Blog-page that is showing all posts with an excerpt I see an Error-notice on top of the header:
Notice: Array to string conversion in /home/jungvita/public_html/test/wp-content/plugins/content-aware-sidebars/lib/wp-content-aware-engine/core.php on line 312
If I use the sidebar-plugin or not for this page this error is visible and needs a fix. The page should have the standard primary sidebar. I tried to work without the plugin for this page, and with the plugin by setting "posts" for the page-type, without anything else for definition.
Here is the code of line 312 and 313:
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".implode("','",$data) ."'))";
}
EDIT: With a debug-plugin I got this notice:
NOTICE: wp-content/plugins/content-aware-sidebars/lib/wp-content-aware- engine/core.php:312 - Array to string conversion
require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/lifestyle-pro/home.php'), genesis, get_header, locate_template, load_template, require_once('/themes/lifestyle-pro/header.php'), do_action('genesis_meta'), WP_Hook->do_action,WP_Hook->apply_filters, blog_page_genesis_meta, is_active_sidebar, wp_get_sidebars_widgets, apply_filters('sidebars_widgets'), WP_Hook->apply_filters, CAS_Sidebar_Manager->replace_sidebar, WPCACore::get_posts, WPCACore::get_conditions, implode
Maybe it helps?!
EDIT2: Here is the complete code of the section
// Return cache if present
of "core.php" (plugin):
// Return cache if present
if(isset(self::$condition_cache[$post_type])) {
return self::$condition_cache[$post_type];
}
$excluded = array();
$where = array();
$join = array();
$cache = array(
$post_type
);
$modules = self::$type_manager->get($post_type)->get_all();
foreach (self::$type_manager->get_all() as $key => $type) {
if($key == $post_type) {
continue;
}
if($type->get_all() === $modules) {
$cache[] = $key;
}
}
foreach ($modules as $module) {
$id = $module->get_id();
if(apply_filters("wpca/module/{$id}/in-context", $module->in_context())) {
$join[$id] = apply_filters("wpca/module/{$id}/db-join", $module->db_join());
$data = $module->get_context_data();
if(is_array($data)) {
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".implode("','",$data) ."'))";
}
$where[$id] = apply_filters("wpca/module/{$id}/db-where", $data);
} else {
$excluded[] = $module;
}
}
There are no line-numbers, so look for
if(is_array($data)) {
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".implode("','",$data) ."'))";
}
These lines are 311 to 313.
In this thread I found a solution:
Mit einem # kannst du normalerweise die Fehlermeldungen ausschalten
I did so putting the # just before 'implode':
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".#implode("','",$data) ."'))";
}
Now the notice is gone.
Hello I am using spout to run some excel reports. I have a user interface where they input date, model, and other information then I do a GET to send it to a php script where I run a query and then put all the results into an excel file like this:
ini_set('max_execution_time', 600); //300 seconds = 5 minutes
require_once 'spout-2.7.2/src/Spout/Autoloader/autoload.php'; // don't forget to change the path!
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Common\Type;
$reportDate=date("Ymd_hhmmss");
$filename="combined_report".$reportDate.".xlsx";
include ("../log/connectionToDb.php");
$conn = connectionSQL();
//provide error if connection fails
if (!$conn) {
echo "An error occurred.\n";
exit;
}
//connected successfully to db. Do not echo anything otherwise it will not show up on dropdown.
else {
//echo "connected";
}
//From date and to date static in case not provided by user
$fromDate = $_GET['convertedFrom'];
$toDate = $_GET['convertedTo'];
$line= $_GET['selectedLine'];
$model_num=$_GET['modelNumber'];
$writer = WriterFactory::create(Type::XLSX);
ob_start();
$writer->openToBrowser($filename);
$sheet = $writer->getCurrentSheet();
$sheet->setName('Production Data');
$rowCount = 2;
$flag=false;
$production = "query";
//echo memory_get_usage() ;
$result1 = sqlsrv_query($conn, $production);
if($result1 === FALSE){
die(print_r(sqlsrv_errors(), TRUE));
}
do{
if(!$flag) {
$headerRow = ['line', 'Work order','Model number', 'Revision','Serial number','Lpn','Date created','Date completed'];
$writer->addRow($headerRow);
$flag = true;
}
else{
$reportRow = [$row['line'], $row['work_order'], $row['model_num'], $row['revision'],$row['serial_num'],$row['LPN'],$row['date_created'],$row['date_completed']];
$writer->addRow($reportRow);
$rowCount++;
}
}
while ($row = sqlsrv_fetch_array($result1));
$writer->close();
$xlsData = ob_get_contents();
ob_clean();
$response = array(
'op' => 'ok',
'file' => "data:application/vnd.ms-excel;base64,".base64_encode($xlsData)
);
}
die(json_encode($response));
Then on the AJAX call I have the following:
$.ajax({
url: 'modelData/excel-export.php',
method: "GET",
data: {'modelNumber':modelNumber,'convertedFrom':converted_from_UTC,'convertedTo':converted_to_UTC,'selectedLine':selectedLine},
dataType:'json',
success: function(fileCreated){
}
}).done(function(data){
console.log(local);
var $a = $("<a>");
$a.attr("href",data.file);
$("body").append($a);
$a.attr("download","combined_report_"+local+".xlsx");
$a[0].click();
$a.remove();
});
now if I run this in Firefox everything works I am able to download up to 4 months of data which is >60,000 records this has no problem. If I run this in google chrome I cannot download more than 1 week about 20,000 records and U get a "download failed -network error" I was using PHPExcel but then found out it didn't support too many records so I switched to spout but I find the same issue only in google chrome but I don't understand where this limitation is coming from. I have read multiple posts and I have tried setting headers, lengths etc but nothing has worked also I chatted with a spout forum and they said none of the headers were necessary but they were still unable to help me.
I think this question Download failed - network error in google chrome but working in firefox may be going close to the same direction as my issue.
Also I have tried running incognito mode chrome I have tried disabling all extensions
As a side note...The firefox download appears to work fine but we don't "support" firefox so it would be hard for customers to go to multiple browsers specially when they're not tech savy
Any help will be greatly appreciated! :)
I was able to solve this issue by doing the following:
JS
window.open("modelData/excel-export.php?modelNumber="+modelNumber+"&convertedFrom="+converted_from_UTC+"&convertedTo="+converted_to_UTC+"&selectedLine="+selectedLine,
'_blank'// <- This is what makes it open in a new window.
);
then on the PHP side:
ini_set('max_execution_time', 600); //300 seconds = 5 minutes
require_once 'spout-2.7.2/src/Spout/Autoloader/autoload.php'; // don't forget to change the path!
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Common\Type;
$reportDate=date("Ymd_hhmmss");
$filename="combined_report".$reportDate.".xlsx";
include ("../log/connectionToDb.php");
$conn = connectionSQL();
//provide error if connection fails
if (!$conn) {
echo "An error occurred.\n";
exit;
}
//connected successfully to db. Do not echo anything otherwise it will not show up on dropdown.
else {
//echo "connected";
}
//From date and to date static in case not provided by user
$fromDate = $_GET['convertedFrom'];
$toDate = $_GET['convertedTo'];
$line= $_GET['selectedLine'];
$model_num=$_GET['modelNumber'];
$writer = WriterFactory::create(Type::XLSX);
$writer->openToBrowser($filename);
$sheet = $writer->getCurrentSheet();
$sheet->setName('Production Data');
$rowCount = 2;
$flag=false;
$production = "query";
//echo memory_get_usage() ;
$result1 = sqlsrv_query($conn, $production);
if($result1 === FALSE){
die(print_r(sqlsrv_errors(), TRUE));
}
do{
if(!$flag) {
$headerRow = ['line', 'Work order','Model number', 'Revision','Serial number','Lpn','Date created','Date completed'];
$writer->addRow($headerRow);
$flag = true;
}
else{
$reportRow = [$row['line'], $row['work_order'], $row['model_num'], $row['revision'],$row['serial_num'],$row['LPN'],$row['date_created'],$row['date_completed']];
$writer->addRow($reportRow);
$rowCount++;
}
}
while ($row = sqlsrv_fetch_array($result1));
$writer->close();
The library I am using just doesn't work very well with AJAX so this approach solved my issue. Thanks for all the help :)
I used Blob Javascript for the same problem.
this link maybe help someone :
Blob
I found this Love Calculator app online , It is open source and free to use, I setted it up on my test server, I added all the app Id's and secrets and did all the setting but I am getting this permissions issue when I or Someone else try to use it , There are 3 Important files in this script,
Config.php (i setted it up , it has only 4 fields for the app id,secret,canvas url,app domain)
Index.php
Facebook.php (this is the sdk I figure)
Config.php is loaded in Index.php with the following code
include_once ('lib/facebook.php'); // Facebook client library
include_once ('config.php'); // Config file
// Constants are located in config.php file
$facebook = new Facebook(
array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET_KEY,
'cookie' => true,
'domain' => FACEBOOK_DOMAIN
)
);
Now , When I tried to figure out the problem , I found this code in index.php for obtaining permissions
$session = $facebook->getSession();
if (!$session) {
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'publish_stream'
));
echo "<script type='text/javascript'>top.location.href = '$url';</script>";
} else {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$updated = date("l, F j, Y", strtotime($me['updated_time']));
} catch (FacebookApiException $e) {
echo "<script type='text/javascript'>top.location.href = '$url';</script>";
exit;
}
}
The canvas app url is https://apps.facebook.com/fb-love-calculator-f
The domain url is https://apps.mjobz.com/love/
You are using and out dated version of facebook sdk, Facebook sdk has updated a couple of times after this one