I am trying to setup a zf1 + doctrine mongo odm 1.0.0BETA4-DEV project. I am using https://github.com/Bittarman/zf-d2-odm branch but when I update doctrine version from 1.0.0BETA3 to 1.0.0BETA4-DEV, I get the following error:
SCREAM: Error suppression ignored for
( ! ) Fatal error: Call to undefined method Doctrine\Common\Annotations\AnnotationReader::setDefaultAnnotationNamespace() in C:\htdocs\zf-d2-odm\library\Lupi\Resource\Odm.php on line 34
Call Stack
# Time Memory Function Location
1 0.0007 139368 {main}( ) ..\index.php:0
2 0.0217 659008 Zend_Application->bootstrap( ) ..\index.php:25
3 0.0217 659104 Zend_Application_Bootstrap_BootstrapAbstract->bootstrap( ) ..\Application.php:355
4 0.0217 659120 Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap( ) ..\BootstrapAbstract.php:586
5 0.0314 1127240 Zend_Application_Bootstrap_BootstrapAbstract->_executeResource( ) ..\BootstrapAbstract.php:626
6 0.0314 1127368 Lupi_Resource_Odm->init( ) ..\BootstrapAbstract.php:683
I found new method usage in the lastest raw documentation
https://github.com/doctrine/mongodb-odm-documentation
First you should call AnnotationDriver::registerAnnotationClasses() which registers annotation classes to the common registry.
AnnotationDriver::registerAnnotationClasses();
Then configure normally all paths and set meta data driver with factory method for the annotation driver AnnotationDriver::create()
$config = new Configuration();
$config->setProxyDir('/path/to/generate/proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir('/path/to/generate/hydrators');
$config->setHydratorNamespace('Hydrators');
$config->setMetadataDriverImpl(AnnotationDriver::create('/path/to/document/classes'));
$dm = DocumentManager::create(new Connection(), $config);
That method doesnt exist anymore. Youll need to modify Lupi_Resource_Odm::init() with updated API calls.
Related
I setted below properties cause MySQL bug(https://www.atomikos.com/Documentation/KnownProblems#MySQL_XA_bug)
com.atomikos.icatch.serial_jta_transactions=false
pinGlobalTxToPhysicalConnection="true"
but when i test it with multiple request after upper properties set, it shows below error
XA resource 'shard0': suspend for XID '3139322E3136382E3231392E3131382E746D313634343537333034393734363030303031:3139322E3136382E3231392E3131382E746D31' raised -5: invalid arguments were given for the XA operation java.sql.SQLException: XAER_INVAL: Invalid arguments (or unsupported command)
at com.atomikos.datasource.xa.XAResourceTransaction.xaSuspend(XAResourceTransaction.java:700) [7 skipped]
at com.atomikos.datasource.xa.session.BranchEnlistedStateHandler.transactionSuspended(BranchEnlistedStateHandler.java:94)
at com.atomikos.datasource.xa.session.TransactionContext.transactionSuspended(TransactionContext.java:94)
at com.atomikos.datasource.xa.session.SessionHandleState.notifyBeforeUse(SessionHandleState.java:165)
at com.atomikos.jdbc.AtomikosConnectionProxy.enlist(AtomikosConnectionProxy.java:207)
... 140 common frames omitted
I wonder why my application throws 'UnexpectedTransactionContextException' from below code even i setted all properties.
//BranchEnlistedStateHandler.java(Atomikos)
TransactionContextStateHandler checkEnlistBeforeUse ( CompositeTransaction currentTx)
throws InvalidSessionHandleStateException, UnexpectedTransactionContextException
{
if ( currentTx == null || !currentTx.isSameTransaction ( ct ) ) {
//OOPS! we are being used a different tx context than the one expected...
//TODO check: what if subtransaction? Possible solution: ignore if serial_jta mode, error otherwise.
String msg = "The connection/session object is already enlisted in a (different) transaction.";
if ( LOGGER.isTraceEnabled() ) LOGGER.logTrace ( msg );
throw new UnexpectedTransactionContextException();
}
//tx context is still the same -> no change in state required
return null;
}java
It is too late but this might help someone:
Spring Boot 2.6.7
mysql-connector-java 8.0.29
According to the atomikos problems MySQL_XA_bug try to add following properties to spring boot.
spring.jta.atomikos.properties.serial-jta-transactions = false
spring.datasource.xa.properties.pinGlobalTxToPhysicalConnection = true
I am trying to run the following code.
CALL gds.graph.create.cypher(
'my-cypher-graph',
'MATCH (n:Person) RETURN id(n) AS id',
'MATCH (a:Person)-[:LIKES]->(b:Person) RETURN id(a) AS source, id(b) AS target'
)
YIELD graphName, nodeCount, relationshipCount, createMillis;
But I got this error: Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure gds.graph.create.cypher: Caused by: java.lang.IllegalArgumentException: Node-Query returned no nodes
I am running Neo4J 4.1.0
Can you please help?
This was happening because the db had 0 nodes. The gds.graph.create.cypher function actually does not CREATE the nodes.
So this question is answered. Thanks.
#Check for appropriate version for neo4j and GDS library from that git file
https://github.com/neo4j/graph-data-science
# first create a node and relationship
create (:Person{name:"Oliver Stone"})-[:LIKE]->(:Person{name:"Karan Kajrolkar"})
#Then try to create native projection
CALL gds.graph.create(
'my-native-graph',
'Person',
'LIKE'
)
YIELD graphName, nodeCount, relationshipCount, createMillis;
#O/P
graphName|nodeCount|relationshipCount|createMillis|
"my-native-graph"|2 |1|51|
Error: package or namespace load failed for ‘tidytext’ in library.dynam(lib, package, package.lib): shared object ‘stringi.so’ not found
6.
stop(msg, call. = FALSE, domain = NA)
5.
value[3L]
4.
tryCatchOne(expr, names, parentenv, handlers[[1L]])
3.
tryCatchList(expr, classes, parentenv, handlers)
2.
tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps) ...
1.
library(tidytext)
upon running
tidyverse:::tidyverse_attach()
tidyverse:::tidyverse_conflicts()
> tidyverse:::tidyverse_attach()
Error in library.dynam(lib, package, package.lib) :
shared object ‘stringi.so’ not found
> tidyverse:::tidyverse_conflicts()
Error in library.dynam(lib, package, package.lib) :
shared object ‘stringi.so’ not found
Try running install.packages('stringi')
See this issue thread for more details: https://github.com/bvieth/powsimR/issues/20
I personally found that when my OS updates R, all of my downloaded packages get broken in some weird way. I've yet to find a fix for it.
I'm trying to mock the Cache::put() facade. But it gives me an error. I have tried different ways but couldn't figure it out.
public function testGetAllFromDatabase()
{
$industry = new Industry();
Cache::shouldReceive('has')
->once()
->with('industries.all')
->andReturn(false);
Cache::shouldReceive('put')
->with('industries.all', '', 0)
->andReturn(true);
$this->industryMock
->shouldReceive('all')
->once()
->andReturn(array_reverse($this->industries));
$this->app->instance(Industry::class, $this->industryMock);
$industryRepository = new IndustryRepository();
$all = $industryRepository->all();
dd($all);
$this->assertContains( $this->industries[2], $all);
}
But when I execute it the following error is occurring.
$ vendor/bin/phpunit
PHPUnit 7.2.7 by Sebastian Bergmann and contributors.
...E 4 / 4 (100%)
Time: 3.76 seconds, Memory: 12.00MB
There was 1 error:
1) Tests\Unit\RepositoriesTests\IndustryRepositoryTest::testGetAllFromDatabase
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_1_Illuminate_Cache_CacheManager::put('industries.all', object(Illuminate\Database\Eloquent\Collection), '1440'). Either the method was unexpected or its arguments matched no expected argument list for this method
Objects: ( array (
'Illuminate\\Database\\Eloquent\\Collection' =>
array (
'class' => 'Illuminate\\Database\\Eloquent\\Collection',
'properties' =>
array (
),
),
))
F:\development\consulting.local\src\vendor\mockery\mockery\library\Mockery\ExpectationDirector.php:92
F:\development\consulting.local\src\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:223
F:\development\consulting.local\src\app\Repositories\IndustryRepository.php:30
F:\development\consulting.local\src\tests\Unit\RepositoriesTests\IndustryRepositoryTest.php:81
I have tried many ways but couldn't get it to fix. Thank you.
Since it may help others, Laravel's facade includes helper functions that allow swapping then with a Mockery test double
This means that when you use a shouldReceive you can chain it with any Mockery expectation for example in this case if you don't care about some parameters you can use:
Cache::shouldReceive('put')
->with('industries.all', \Mockery::any(), \Mockery::any())
->andReturn(true);
In case it helps others, it's good to point out that you may not want to mock Cache, but instead actually use the real Cache.
That's because it's a Cache for testing only:
When running tests via vendor/bin/phpunit, Laravel [....] automatically configures the session and cache to the array driver while testing, meaning no session or cache data will be persisted while testing.
https://laravel.com/docs/8.x/testing#environment
Note that unlike the OP's test, you may need to follow Laravel's guidance about your test class extending their TestCase to get the behavior, e.g.
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
i want to save the output pdf file to public folder my method is
public function qrSVG()
{
$qrCodes = ['4659284fff','465928447','465928447','613271980','484016586','aaaaabbbbbccccc'];
$id = ['201596400-1','201596400-2','201596400-3','831070646','493130428','aaaaabbbb'];
PDF::SetTitle('qrcodes\test');
$i=0;
foreach(array_chunk($qrCodes, 2) as $qrCodee)
{
PDF::AddPage();
$m = 55;
$n = 30;
foreach($qrCodee as $qr)
{
QrCode::size(400);
QrCode::margin(3);
QrCode::errorCorrection('H');
QrCode::encoding('UTF-8');
QrCode::backgroundColor(255,255,255);
QrCode::color(0,0,0);
QrCode::imageTitle($id[$i]);
$svg = QrCode::generate($qr);
PDF::ImageSVG('#'.$svg, $x=$m, $y=$n, $w='100', $h='100', $link='', $align='', $palign='', $border=1, $fitonpage=false);
$i++;
$n = 150;
}
}
ob_clean();
PDF::Output('qrcodes\test.pdf');}
this code generate and open the file put don't save it when i replace the last line in my code with PDF::Output('qrcodes\test.pdf', 'F');
when i put any option with PDF::Output there is an error with F and D options the error when use F is
ErrorException in tcpdf_static.php line 2440:
fopen(): remote host file access not supported, file://qrcodes\test.pdf
and when i replace the last line with
PDF::Output($_SERVER['DOCUMENT_ROOT'] . 'qrcodes\test.pdf', 'F');
the error is
ErrorException in tcpdf.php line 2793:
Undefined property: Elibyy\TCPDF\Pdf::$h
The main reason you're getting the error about remote host file access not supported is because you need to provide the full path in the file name that you provide to the Output() method. Yeah, it's a bit annoying and it catches me out all the time!
I can't comment on the second error you're getting because I cannot get your code to run (missing methods in QrCode class). What version are you using? Also, why are you trying to create an SVG for the QR code and then adding that to the PDF? Instead of taking that approach, I would highly recommend following the approach illustrated in this example:
https://github.com/tecnickcom/TCPDF/blob/master/examples/example_050.php
As you will see in the example, you should create an instance of the TCPDF class and then work with that instance, rather than calling the static methods.