Exist-DB: REST GET to stored XProc file (xpl extension) returns error - rest

In Exist 2.2, When I try to access any .xpl files with REST GET, I get the following error:
/db/beheer/pipe.xpl err:XPST0003
error found while loading module xproc: Error while loading module
http://xproc.net/xproc: unexpected token: ! (while expecting closing
tag for element constructor: null) [at line 1, column 2]
It seems to me that Exist is processing the *.xpl as if it was something it could execute (like a stored xquery) but then it cannot do so and returns an error.
Is there an easy way to let it return just the XML (the XProc as is instead of error message)?

Indeed, eXist consults its list of Internet Media Types when you do a HTTP GET using the REST Server and if it thinks that it is an XProc it will attempt to execute it as such.
You can change what eXist thinks is an XProc by editing $EXIST_HOME/mime-type.xml and then restarting eXist. You most likely want to move the .xpl extension from the mimetype application/xml+xproc to application/xml.

Related

mysqli_query($conn, $sql) On adding this, giving an error of 500 INTERNAL SERVER ERROR, No detailed error shown [duplicate]

In my local/development environment, the MySQLi query is performing OK. However, when I upload it on my web host environment, I get this error:
Fatal error: Call to a member function bind_param() on a non-object in...
Here is the code:
global $mysqli;
$stmt = $mysqli->prepare("SELECT id, description FROM tbl_page_answer_category WHERE cur_own_id = ?");
$stmt->bind_param('i', $cur_id);
$stmt->execute();
$stmt->bind_result($uid, $desc);
To check my query, I tried to execute the query via control panel phpMyAdmin and the result is OK.
TL;DR
Always have mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); in your mysqli connection code and always check the PHP errors.
Always replace every PHP variable in the SQL query with a question mark, and execute the query using prepared statement. It will help to avoid syntax errors of all sorts.
Explanation
Sometimes your MySQLi code produces an error like mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given..., Call to a member function bind_param()... or similar. Or even without any error, but the query doesn't work all the same. It means that your query failed to execute.
Every time a query fails, MySQL has an error message that explains the reason. In the older PHP versions such errors weren't transferred to PHP, and all you'd get is a cryptic error message mentioned above. Hence it is very important to configure PHP and MySQLi to report MySQL errors to you. And once you get the error message, fixing it will be a piece of cake.
How to get the error message in MySQLi
First of all, always have this line before MySQLi connect in all your environments:
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
After that, all MySQL errors will be transferred into PHP exceptions. An uncaught exception, in turn, makes a PHP fatal error. Thus, in case of a MySQL error, you'll get a conventional PHP error. That will instantly make you aware of the error cause. And the stack trace will lead you to the exact spot where the error occurred.
How to get the error message from PHP
Here is a gist of my article on PHP error reporting:
Reporting errors on a development and live servers must be different. On the development server it is convenient to have errors shown on-screen, but on a live server error messages must be logged instead, so you could find them in the error log later.
Therefore, you must set corresponding configuration options to the following values:
On a development server
error_reporting should be set to E_ALL value;
log_errors should be set to 1 (it is convenient to have logs on a development PC too)
display_errors should be set to 1
On a production server
error_reporting should be set to E_ALL value;
log_errors should be set to 1
display_errors should be set to 0
After that, when MySQL query fails, you will get a PHP error that explains the reason. On a live server, in order to get the error message, you'll have to check the error log.
In case of AJAX call, on a dev server open DevTools (F12), then Network tab. Then initiate the request which result you want to see, and it will appear in the Network tab. Click on it and then the Response tab. There you will see the exact output. On a live server check the error log.
How to actually use it
Just remove any code that checks for the error manually, all those or die(), if ($result), try..catch and such. Simply write your database interaction code right away:
$stmt = $this->con->prepare("INSERT INTO table(name, quantity) VALUES (?,?)");
$stmt->bind_param("si", $name, $quantity);
$stmt->execute();
Again, without any conditions around. If an error occurs, it will be treated like any other error in your code. For example, on a development PC it will just appear on-screen, while on a live site it will be logged for the programmer, whereas for the user's convenience you could use an error handler (but that's a different story which is off topic for MySQLi, but you may read about it in the article linked above).
What to do with the error message you get
First of all you have to locate the problem query. The error message contains the file name and the line number of the exact spot where the error occurred. For the simple code that's enough, but if your code is using functions or classes you may need to follow the stack trace to locate the problem query.
After getting the error message, you have to read and comprehend it. It sounds too obvious if not condescending, but learners often overlook the fact that the error message is not just an alarm signal, but it actually contains a detailed explanation of the problem. And all you need is to read the error message and fix the issue.
Say, if it says that a particular table doesn't exist, you have to check spelling, typos, and letter case. Also you have to make sure that your PHP script connects to a correct database
Or, if it says there is an error in the SQL syntax, then you have to examine your SQL. And the problem spot is right before the query part cited in the error message.
If you don't understand the error message, try to google it. And when browsing the results, stick to answers that explain the error rather than bluntly give the solution. A solution may not work in your particular case, but the explanation will help you to understand the problem and make you able to fix the issue by yourself.
You have to also trust the error message. If it says that number of tokens doesn't match the number of bound variables then it is so. The same goes for the absent tables or columns. Given the choice, whether it's your own mistake or the error message is wrong, always stick to the former. Again it sounds condescending, but hundreds of questions on this very site prove this advise extremely useful.
A list of things you should never ever do in regard of error reporting
Never use an error suppression operator (#)! It makes a programmer unable read the error message and therefore unable to fix the error
Do not use die() or echo or any other function to print the error message on the screen unconditionally. PHP can report errors by itself and do it the right way depends on the environment - so just leave it for PHP.
Do not add a condition to test the query result manually (like if($result)). With error exceptions enabled such condition will just be useless.
Do not use the try..catch operator for echoing the error message. This operator should be used to perform some error handling, like a transaction rollback. But never use it just to report errors - as we learned above, PHP can already do it, the right way.
P.S.
Sometimes there is no error, but no results either. Then it means, there is no data in the database to match your criteria. In this case you have to admit this fact, even if you can swear the data and the criteria are all right. They are not. You have to check them again.
I've got an article that can help in this matter, How to debug database interactions. Although it is written for PDO, the principle is the same. Just follow those instructions step by step and either have your problem solved or have an answerable question for Stack Overflow.

Magento Page Builder - 500 Internal Server error

I just wanted to add a Slider block in my Magento 2.4.4 build in Pagebuilder and I'm getting an 500 Internal Server error when I click on Edit. I have this problem also with the Image block.
I have this in my browser console:
https://example.com/admin/mui/index/render_handle/buttons/1/key/3d12a8a6a2372ed459fc9684018ea6fbb954bd41478fe44d9f2e969ed409a639/?namespace=pagebuilder_slide_form&handle=pagebuilder_slide_form&isAjax=true
[HTTP/1.1 500 Internal Server Error 887ms]
Do you know where I can start to search where this is comming from?
The debug.log and system.log says:
magento main.ERROR: The requested store cannot be found.
I found the solution folowing the steps from Silas Palmer found here: https://magento.stackexchange.com/questions/156176/magento-2-requested-store-is-not-found?newreg=9ac715264c1949e69c8b1a78c0100133
That makes the error code more clear.
In my case it says:
main.ERROR: The store ID (3) that was requested wasn't found. Verify the store and try again.
So I crated a new store view and it works now.
Here is what I did:
This generally happens whenever config.php and the database get out of sync. For example, whenever I import a database back to my local development environment.
Here were the steps I used to troubleshoot and fix this.
Make the error messages more helpful:
Change vendor/magento/module-store/Model/StoreRepository.php to this (on your local, temporarily)
// Around line 74
if ($store->getId() === null) {
// Add this to see a backtrace
// debug_print_backtrace();
// Add this to see the store code causing the issue: (code:{$code})
throw new NoSuchEntityException(
__("The store (code:{$code}) that was requested wasn't found. Verify the store and try again.")
);
}
// .......
// Around line 114, same kind of thing...
if ($store->getId() === null) {
// debug_print_backtrace();
throw new NoSuchEntityException(
__("The store ID ({$id}) that was requested wasn't found. Verify the store and try again.")
);
}
Run php bin/magento s:up and make a note of the store id and/or store codes that are causing the issues. If you have added the backtrace, that will spool variables forever and you might need to do something like this instead: php bin/magento s:up > output.txt (wait 3 minutes, press ctrl-d to kill it) less output.txt
Go through app/etc/config.php and make sure all the stores line up with whatever is in the store table in the database. Note the store id from step 1, that will give you clues where to look. If there are differences, change config.php and not the database.
Run this against the database:
Change scope_id value (99) to whatever store_id you got in step #1
DELETE FROM core_config_data WHERE scope_id = 99
Change like value ('%xx_en%') to whatever store code you got in step #1
DELETE from flag where flag_data like '%xx_en%'
Run php bin/magento s:up again, hopefully there are no errors this time. Otherwise you may have to repeat some steps.

How to use custom language highlight syntax in Gtk SourceView?

I'm trying to create my own language definition, and use it for highlighting the syntax in my app.
The issue I have is that, when trying to access the language definition from my app's data folder (/usr/share/myapp/), even using the c.lang file copied from /usr/share/gtksourceview-3.0/language-specs/, just to test, I get this error at runtime:
GtkSourceView-WARNING **: Failed to load '/usr/share/myapp/c.lang': could not find the RelaxNG schema file
So it's asking for some schema file? So I went forward and copied every file from the language-specs folder that isn't a lang file, which includes: language.dtd, language.rng and language2.rng.
Now, when I run again, I get these errors:
GtkSourceView-WARNING **: in file /usr/share/com.github.aleksandar-stefanovic.urmsimulator/c.lang: style 'def:comment' not defined
GtkSourceView-WARNING **: Failed to load '/usr/share/com.github.aleksandar-stefanovic.urmsimulator/c.lang': unable to resolve language 'def'
What does that even mean? Is that something namespace-related? It is very peculiar, because the exact same file is working perfectly when in gtksourceview folder.
Any clues? Do these "RelaxNG" files work only in their original directories? If so, how can I change that? I've looked into the files, but failed to find any reference to their original folder...
This is the source-code (in Vala) related to the issue:
var manager = Gtk.SourceLanguageManager.get_default ();
string search_paths[] = {"/usr/share/myapp", null};
manager.set_search_path (search_paths);
var buffer = new Gtk.SourceBuffer.with_language (manager.get_language ("c"));
The application does in fact find the language "c", I've checked by debugging.
You have to preserve the Gtk.SourceLanguageManager's original search path when you add your own. Append to it instead of replacing it.

Caché OREF Error - Getting More Information

I'm am trying to integrate with a Caché Web Service and I'm getting an error message similar to:
ERROR #5002: Cache error: <INVALID OREF>zMethodName+45^AA.wsClass.8
I do have have access to the code (albeit just a copy, so read-only), and I'm trying to decipher what the error could be pointing me to.
So does the number 45 and/or 8 mean anything? I've tried to see if it is pointing to a line number or offset from the method and I can't seem to pin point anything.
How might I be able to figure more out from this error?
This is a standard COS pointer. To locate it, just open routine AA.wsClass.8.INT, locate zMethodName and count 45 lines after it (or just write zMethodName+45 in Studio locator bar).
INVALID OREF means you try to use property or call method from null-valued pointer.

How do you debug problems with local storage? Trouble with "An error occurred while processing this request" in HandleBatchResponse

Cross-posted at MSDN.
I have a list of entity objects I'm trying to insert into a table in the local storage service. Using a data context class derived from the SampleClient TableStorageDataContext class, I create a new context object and add the entities with no issues. When I call context.SaveChanges(), an exception is ultimately thrown, but with sparingly little detail. I've run a profiler trace on SQL Server Express to see if the error originated there, and didn't find anything useful, which leads me to believe there's some issue in the local storage service, which I have no idea how to debug.
Here's the client code (F#):
let cxt0 = new WebRole.Models.TableDataContext()
entityList |> Seq.iter (fun n -> cxt0.AddObject("NutritionData", n))
let results = cxt0.SaveChanges()
I can set a breakpoint on the last of the above lines and stop execution and see that the cxt0 object contains all the entities to be added (>500K). After then continuing execution, the following exception is thrown:
System.Data.Services.Client.DataServiceRequestException:
"An error occurred while processing
this request."
at
System.Data.Services.Client.DataServiceContext.SaveAsyncResult.HandleBatchResponse()
at
System.Data.Services.Client.DataServiceContext.SaveAsyncResult.EndRequest()
at
System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions
options) at
System.Data.Services.Client.DataServiceContext.SaveChanges()
at
WorkerRole.SrDataProcessor.importSrData(FastFunc`2
pf, String blobName) in
C:\Users\Ben\Development\Projects\CloudProject\WorkerRole\SrDataProcessor.fs:line
76
The InnerException (pardon the brackets as I avoid the html tag scrubber):
System.Data.Services.Client.DataServiceClientException:
" [?xml version="1.0" encoding="utf-8"
standalone="yes"?] [error
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"]
[code][/code] [message
xml:lang="en-US"]An error occurred
while processing this
request.[/message] [/error] "
at
System.Data.Services.Client.DataServiceContext.SaveAsyncResult.d__1d.MoveNext()
In the HandleBatchResponse method, it appears that this error may be reported as it enumerates through the responses. Any ideas what might be calling this? The only thing left I've thought to check but haven't is to ensure that none of my entities have string properties that go past 1000 characters.
Update: Now I have, and it doesn't look like there are any. The following snippet produced an empty sequence:
let longEntities =
nutData |> Seq.choose (fun nd -> if HasLongStringProperties(nd)
then Some(nd) else None)
Also, more generally, how does one debug issues like this? Is there any way to get some introspection into the local storage service?
Update 2: I've since discovered that the "exception of origin", so to speak, is actually a System.WebException reporting an "Internal Server Error (500)", with no further detail. I've done everything I know to do to ensure that the data I'm trying to insert is compatible with the schema and data types in the tables in the SQL Server Express database backing the table service, and still I don't know what the issue is. The TableDataService just won't accept the object I'm inserting. See the MSDN thread for more details. I've also opened a bug on connect.
I was trying to do an extremely simple demo and I had the same problem but I was finally able to figure it out. By running against the development storage with logging turned on:
See:
http://blogs.msdn.com/b/partlycloudy/archive/2009/12/16/development-storage-logging.aspx
After starting the DevelopmentStorage, running my app, and then stopping the development storage and looking in the log folder I see:
9/17/2010 1:30:47 PM [Error] Caught exception during performing table operation and rethrow: System.Exception: c:\Users\Scott\AppData\Local\Temp\jvcl5gjz.0.cs(14,23) : error CS0542: 'Number': member names cannot be the same as their enclosing type
at Microsoft.Cis.Services.Nephos.Table.Service.Protocols.Rest.TableManager.EndPerformOperation(IAsyncResult ar) in x:\rd\rd_store_stable\services\xstore\XFE\table\service\Protocols\REST\src\TableManager.cs:line 184
at Microsoft.Cis.Services.Nephos.Table.Service.Protocols.Rest.TableProtocolHead.d__3e.MoveNext() in x:\rd\rd_store_stable\services\xstore\XFE\table\service\Protocols\REST\src\TableProtocolHead.cs:line 732
It turns out that my demo was too simple, because I had created a table called Number with a single column called Number...