Drupal 7 - Automatic Webform Export Results failed - drupal-7

I'm trying to export webform results through hook_cron() in drupal 7.
$webform_node = node_load($wid);
if (is_object($webform_node)){
module_load_include('inc', 'webform', 'includes/webform.report');
$export_info = webform_results_export($webform_node);
webform_results_download($webform_node, $export_info );
}
The problem is on the line webform_results_download(). It creates an error in XDebug saying:
"Fatal error: Call to a member function set_headers() on a non-object"
When trying to debug the code, I remark the error was caused by
$export_info['exporter']->set_headers($export_name);
This variable $export_info['exporter'] is not existing. How can i set it manually, or what is the best alternative if i want to just get webform results by cron. Need help. Thanks.

Related

Using DomPDF in Cakephp Delivers an error Cannot redeclare class Dompdf\View\PdfView

I have a problem printing a PDF using CakePHP and DomPDF as soon I want to fetch some data from the Database before printing the pdf. Without fetching the Data, it works like a charme. My function is the following:
public function tourpdf($tourid = null){
$contain = ['Deliveries','Deliveries.Articletransactions','Deliveries.Orders','Deliveries.Orders.Customers',
'Deliveries.Articletransactions.Orderarticles','Deliveries.Articletransactions.Orderarticles.Articles'];
$tour = $this->Tours->get($tourid)
->contain($contain);
$this->viewBuilder()
->className('Dompdf.Pdf')
->layout('Dompdf.default')
->options(['config' => [
'filename' => $filename,
'render' => 'browser',
'size' => 'A4',
'orientation' => 'landscape'
]]);
$this->set('Test', 'Hallo');
$this->set('Tour',$tour);
}
As soon as I set the Data from the last line, that I fetched above, I get the error Message "Fatal error: Cannot redeclare class Dompdf\View\PdfView in .../src/View/PdfView.php on line 66".
However commenting the last line out, the first set with Test is working and the PDF is generated. How can I set data retrieving from a query to the pdf file?
I got a similar error, but with Zend Framework 2. All of a sudden DOMPDF would give an error "Cannot redeclare (previously declared in ...)".
I had PHP functions in some templates and when I removed them I was getting another error "No block-level parent found. Not good.". I noticed this started happening when I upgraded libxml2 from 2.9.4 to 2.9.5 or later.
The solution to both of the problems was to instantiate DOMPDF class like this:
use Dompdf\Options;
$options = new Options();
$options->set('enable_html5_parser', true);
$dompdf = new Dompdf($options);
With enable_html5_parser all the problems went away. Here is some more information on this issue.
Amazing!
Had this issue on Mac 10.12.6
PHP Version 5.6.30
libxml Version 2.9.4
Using the regex to remove whitespace between the tags fixed the issue.
$html = preg_replace('/>\s+</', '><', $html);

Deploying from a development org to a new unrelated org without a package

I've been struggling with the deployment of our force.com application code that has, up to now, been developed in a single development org I'll call DevOrg.
What I want to do is transfer the DevOrg objects, code, pages, etc from DevOrg to a sandbox in a new org (NewOrg) that I have created. NewOrg and its sandbox are devoid of any code/objects related to the application. I've used the migration tool to retrieve the code from DevOrg and have fashioned the package.xml in various ways to get the code to deploy the NewOrg sandbox, but I keep getting tons of errors, for example:
[sf:deploy] SomeClass: line 1014, column 95: Dependent class is invalid and needs recompilation:
[sf:deploy] SomceClass2: line 475, column 37: Dependent class is invalid and needs recompilation:
I went into the Eclipse IDE and checked out the project from DevOrg, exported the project and imported it to a project pointed to NewOrg's sandbox. I thought perhaps this would give me hints about a working package.xml since I can work in the DevOrg project in the Eclipse IDE without any problems/errors.
But instead I found the same errors in the NewOrg sandbox project when loaded within the IDE. So I tried making adding a space to the dependent class and saving it to the NewOrg sandbox and I received an sObject error like this:
Save error:
sObject type 'SomeClass__c' is not supported.
If you are attempting to use a custom object, be sure to append the '__c' after the entity name.
Please reference your WSDL or the describe call for the appropriate names.
Thinking this must be because the objects haven't been deployed to NewOrg's sandbox, I attempted to the deploy only the objects in the project. That too failed. This time with errors like this:
Save error:
Appointment_Type_Form__c.Form__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Appointment_Type_Form__c.object
Save error:
Form__c : Cannot set ControlledByParent on a CustomObject without a
MasterDetail relationship field Form__c.object
Save error:
Form__c.All : In field: columns - no CustomField named
Form__c.Form_Template__c found Form__c.object
Save error:
Form__c.Form_Template__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Form__c.object
Save error:
Form_Template__c : formoverride does not exist or is not
a valid override for action Edit. Form_Template__c.object
Save error:
GWAPI_Log__c : log_detail does not exist or is not
a valid override for action View. GWAPI_Log__c.object
Save error:
Idea.Ideas_Last_7_Days : Could not resolve list
view column: IDEA.IDEA_THEME Idea.object
Save error:
Message__c.Form_in_Question__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Message__c.object
Save error:
News__c : customarticle does not exist or is not a valid override
for action Edit. News__c.object
Save error:
Question__c : Cannot set ControlledByParent on a CustomObject without
a MasterDetail relationship field Question__c.object
Save error:
Question__c.All : In field: columns - no CustomField named
Question__c.Form_Template__c found Question__c.object
Save error:
Question__c.Form_Template__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Question__c.object
Save error:
Section__c : Cannot set ControlledByParent on a CustomObject without
a MasterDetail relationship field Section__c.object
Save error:
Section__c.Form_Template__c : referenceTo value of 'Form_Template__c'
does not resolve to a valid sObject type Section__c.object
Save error:
Security_Question_Answer__c.Question_Text__c : Field Is_Patient__c
does not exist. Check spelling. Security_Question_Answer__c.object
Save error:
sObject type 'Portal_Session__c' is not supported. If you are
attempting to use a custom object, be sure to append the '__c'
after the entity name. Please reference your WSDL or the describe call for the appropriate names.
And so I have to have any luck with the new deployment in either the IDE or via the Migration Tool (MT).
I'm looking for advice on how to approach these issues when deploying to a brand new org using either IDE or MT. The errors imply, I think, something about the ordering of the deployment but as I understand from the Migration Tool Guide, Development Lifecycle Guide, etc the dependencies and ordering can be determined by the platform when deploying.
Have others run into similar issues and found that the solution was strictly in the package.xml? I'm curious because in one instance the package.xml works fine (when deploying to the original org) but in the other case (a new org) it doesn't seem sufficient.
The troubles with a virgin sandboxes is that usually you can't deploy it without a few iterations.
I used the following workflow:
deploy the custom objects which are on relationships with standard objects
deploy standard sObjects
deploy the rest of sObjects
deploy triggers and apex code
deploy VF pages/VF email templates
deploy the rest of metadata
after that I used only migration tool for deployment.
I'd like to suggest you perform deployment of sObjects by one at a time for most significant objects. Also before the deployment please check that all settings of standard objects conform to DevOrg's settings
Also you can try to change API version of metadata.

CakePHP Cakemenu plugin fails after global error due to incorrect string encoding

I am using CakePHP 2.1.2 with PHP 5.3.5 and a plugin called 'Cakemenu' which normally works fine. The plugin stores menus in a db table with the menu link stored as text like
array('plugin'=>null,'controller'=>'assets','action'=>'index');
The helper in the plugin gets those values, then executes this code to convert that text to an array:
//Try to evaluate the link (if starts with array)
if (eregi('^array', $value['Menu']['link'])) {
$code = "\$parse = " . $value['Menu']['link'] . ";";
$result = eval($code);
if (is_array($parse)) {
$value['Menu']['link'] = $parse;
}
}
Everything works fine unless CakePHP is handling an error. For example if I mistype the name of a controller in the browser I should get a menu and then the missing controller message. Instead I get a page full "Parse error: syntax error, unexpected $end in..." messages pointing to the line with the eval statement. If I printout the variable that is getting eval'ed I see that it has been (incorrectly) encoded with Html entities when it normally does not.
Good string to be eval'ed:
$parse = array('plugin'=>null,'controller'=>'assets','action'=>'index');
Bad string to be eval'ed:
$parse = array('plugin'=>null,'controller'=>'Parts','action'=>'add');
To temporarily fix the problem I added two statements to just replace the offending characters
$value['Menu']['link'] = str_replace( ''','\'',$value['Menu']['link']);
$value['Menu']['link'] = str_replace( '>','>',$value['Menu']['link']);
and everything works great again. Some other pieces of information that might be helpful is that the array of data used to generate the menu is read during the beforeFilter of the app and saved in a view variable and then the menu is generated as an element in the view.
I'm thinking that the error causes CakePHP (or PHP) to skip some loading or configuration process and that causes the string to be mishandled. Any help would be appreciated, thanks
Your beforeFilter() method won't be executed on error pages. You'll have to handle your errors yourself and manually call beforeFilter(). I wrote a blog post on how to use custom error pages - pay close attention to the Controller Callbacks section.

missing file in building corona sdk?

I am developing a project that uses mp3 and .lrc file for my game in corona sdk.
when i try to build it on android and run it on the android device, i got this error..
Director ERROR: Failed to execute new(params) function on 'gameLoad'.
so i wonder that there is missing file in my game.
it is possible that the mp3 and .lrc files didn't build together with the game code?
can anyone can give idea about my case? thanks in advance ...
Which version of director are you using? The latest version of director class (1.4 I think) prints THE ACTUAL ERROR that causes the problem.
The error which you have mentioned is just the error in director class which you have no control over. You will get something like this.
-----------------------
Director ERROR: Failed to execute new( params ) function on 'mainscreen'.
-----------------------
e:\corona\satheesh\doodle2\mainscreen.lua:35: attempt to perform arithmetic on global 'screen' (a nil value)
Runtime error
EDIT
If you need these messages to be show on device, do the following changes to director.lua
1.set
showDebug = true
2.Change
local alert = native.showAlert( "Director Class - ERROR", message, { "OK" }, onComplete )
to
local alert = native.showAlert( "Director Class - ERROR",debugMessage, { "OK" }, onComplete )

CakePHP tags behavior header already sent error

Hi folks I'm trying to set up tagging in my CakePHP application. I've been using an article I found here: http://bakery.cakephp.org/articles/view/simple-tagging-behavior
The problem I'm having is when I add the line
var $actsAs = array('Tag'=>array('table_label'=>'tags', 'tags_label'=>'tag', 'separator'=>','));
to my project model.
I get the error:
Warning (2): Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/app/models/behaviors/tag.php:2) [CORE/cake/libs/controller/controller.php, line 746]
Is it a stupid syntax error I'm getting?
Jonesy
there was white space above my open php tag in the behavoir model, removed it and the error is gone. It WAS a stupid mistake!

Resources