VariableProductTitle
9 years ago
.gitkeep
10 years ago
WpaeInvalidPhpException.php
9 years ago
WpaeInvalidStringException.php
9 years ago
WpaeMethodNotFoundException.php
9 years ago
WpaePhpInterpreterErrorHandler.php
8 years ago
WpaeString.php
8 years ago
WpaeTooMuchRecursionException.php
9 years ago
WpaeXmlProcessor.php
7 years ago
XmlCsvExport.php
4 years ago
XmlExportComment.php
8 years ago
XmlExportCpt.php
4 years ago
XmlExportEngine.php
4 years ago
XmlExportFiltering.php
9 years ago
XmlExportMediaGallery.php
6 years ago
XmlExportTaxonomy.php
9 years ago
XmlGoogleMerchants.php
9 years ago
XmlSpec.php
9 years ago
WpaePhpInterpreterErrorHandler.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | class WpaePhpInterpreterErrorHandler |
| 4 | { |
| 5 | public function handle(){ |
| 6 | |
| 7 | $error = $this->getLastError(); |
| 8 | |
| 9 | if($error && strpos($error['file'], 'uploads/wpallexport/functions.php') !== false){ |
| 10 | $wp_uploads = $this->getUploadsDir(); |
| 11 | $functions = 'in '.$wp_uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_EXPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php:'.$error['line']; |
| 12 | $error['message'] = str_replace($functions, '', $error['message']); |
| 13 | $error['message'] = str_replace("\\n",'',$error['message']); |
| 14 | $errorParts = explode('Stack trace', $error['message']); |
| 15 | $error['message'] = $errorParts[0]; |
| 16 | $error['message'] .=' on line '.$error['line']; |
| 17 | $error['message'] = str_replace("\n",'',$error['message']); |
| 18 | $error['message'] = str_replace("Uncaught Error:", '', $error['message']); |
| 19 | $error['message'] = 'PHP Error: ' . $error['message']; |
| 20 | $error['message'] = str_replace(' ', ' ', $error['message']); |
| 21 | echo "[[ERROR]]"; |
| 22 | if($error['message'] == '') { |
| 23 | $error['message'] = __('An unknown error occured', 'wp_all_import_plugin'); |
| 24 | } |
| 25 | $this->terminate(json_encode(array('error' => '<span class="error">'.$error['message'].' of the Functions Editor'.'</span>', 'line' => $error['line'], 'title' => __('PHP Error','wp_all_import_plugin')))); |
| 26 | } else if(strpos($error['file'], 'XMLWriter.php') !== false ) { |
| 27 | if(strpos($error['message'],'syntax error, unexpected') !== false) { |
| 28 | echo "[[ERROR]]"; |
| 29 | $this->terminate(json_encode(array('error'=>__('You probably forgot to close a quote', 'wp_all_import_plugin'),'title' => __('PHP Error','wp_all_import_plugin')))); |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @return array |
| 36 | */ |
| 37 | protected function getLastError() |
| 38 | { |
| 39 | return error_get_last(); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @return mixed |
| 44 | */ |
| 45 | protected function getUploadsDir() |
| 46 | { |
| 47 | return wp_upload_dir(); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Hack to be able to test the class in isolation |
| 52 | * |
| 53 | * @param $message |
| 54 | */ |
| 55 | protected function terminate($message) |
| 56 | { |
| 57 | exit($message); |
| 58 | } |
| 59 | } |