We're using APCu as a data cache for PHP on a number of different installations - workstations, development and production servers. Unfortunately, the APCu API appears to be a moving target, and there is little to no official documentation (that I could find). At the moment, we're getting quite different return values for apcu_cache_info()...
With APCu 4.0.1, an entry looks like this:
[
'key' => 'the_entry_key',
'atime' => 1450646021,
'ctime' => 1450646021,
'mtime' => 1450650861,
'dtime' => 0,
// ...
]
With APCu 4.0.7, it looks like this:
[
'info' => 'the_entry_key',
'access_time' => 1450650861,
'creation_time' => 1450646021,
'modification_time' => 1450646021,
'deletion_time' => 0,
// ...
]
According to the source on GitHub, it now looks like this:
[
'info' => 'the_entry_key',
'access_time' => 1450650861,
'creation_time' => 1450646021,
'mtime' => 1450646021,
'deletion_time' => 0,
// ...
]
We've seen other sudden API changes in the past, like when apcu_sma_info() and apcu_cache_info() had to be called with the string "user" as the first parameter - until they didn't. I understand that these changes are related in some way with keeping or dropping compatibility with the old APC extension, but it's getting a little hard to guess how to interact with APCu.
Are these changes documented somewhere, with a version number we can check against? Are there going to be any more changes to this in the near future? How can I get notified about them, other than seeing my application break?
The documentation on php.net has nothing to say about this, and neither does the project's CHANGELOG file. The PHP change log doesn't mention this as a backwards incompatible change either (probably because APCu isn't bundled with PHP by default).
Related
On my new server, I have to use a proxy to make the different API calls to other services.
I'm using Mailjet, and making the calls with the official PHP Wrapper (with no composer : https://github.com/mailjet/mailjet-apiv3-php-no-composer ).
I try to configure the proxy like that :
$mj = new \Mailjet\Client(
APIKEY,
APIKEY2,
true,
[
'version' => 'v3.1',
'connect_timeout' => 4,
'proxy' => [
'http' => someurl,
'https' => someurl
]
]
);
As you can see I'm also trying to edit the "CONNECT_TIMEOUT" variable. (I tried to set the variables in uppercase too, same result)
Unfortunaly, through all my tests I could have observe that only version and url variables are considered and set as asked. Any other variable, random or supposed to be taken care of, are not setted and stay with their default value.
I guess I'm not configuring as I should, perhaps those options should be elsewhere in the call, but even the Mailjet Support couldn't have inform me...
In the mean time I edited the /Mailjet/src/Mailjet/Client.php file from
private $requestOptions = [
self::TIMEOUT => 15,
self::CONNECT_TIMEOUT => 2,
];
to
private $requestOptions = [
self::TIMEOUT => 15,
self::CONNECT_TIMEOUT => 4,
self::PROXY => someurl
];
It works, but I prefer not having to edit this file and pass the variables as I should.
That class has a public method called setConnectionTimeout which you can use in your Client instance (e.g $mj->setConnectionTimeout(4))
I am using the Lithium framework version 1.1.1 in PHP 5.6 with MongoDB. I have updated MongoDB from 3.4 to 3.6 and this ended up requiring the PHP ini variable mongo.long_as_object be set to true for the aggregateCursor() methods to work properly in the legacy MongoDB driver for PHP. This version of Lithium does not yet support the newer MongoDB PHP module. This causes a problem with the way NumberLong values are handled in Lithium since they are converted to a MongoInt64 in PHP.
For example: When calling $results->data() on a DocumentSet, a BSON result such as { viewers: NumberLong(12345) } will decode to [ 'viewers' => [ 'value' => '12345' ] ]. Instead I need the PHP array to be [ 'viewers' => 12345 ].
If I add an appropriate handler directly in the lithium\data\entity\Document::_init method then everything works as I expect. For example:
$this->_handlers += [
'MongoId' => function($value) { return (string) $value; },
'MongoDate' => function($value) { return $value->sec; },
'MongoInt64' => function($value) { return (int) $value->value; }
];
However, directly editing the Lithium library is likely not the best approach especially when upgrading the library to newer version as they are released. Is there a proper way to add this handler elsewhere? Such as in the Connections::add(...) method in the connections.php bootstrap file?
Unfortunately, handlers aren't directly configurable, however, they're not too hard to override. You can pass a classes key to Connections:add(), which allows you to extend one of the two classes where handlers are specified, i.e.:
Connections::add([
/* ... */,
'classes' => [
'entity' => 'my\data\Document'
// -- or --
'schema' => 'my\data\Schema'
]
]);
From there, you can implement your custom class that extends the appropriate core class, adding extra handlers as appropriate. Also, a PR to add MongoInt64 support to Li3 core would be gratefully accepted. :-)
I need migrate 3400 rows from phpMyAdmin export to a custom content type over Drupal 8.
I tried to do with migration modules but, for example Migrate Plus and Migrate Tools are not compatible with my version of Drupal (8.1.1)
I wanted to import records using a PHP script.
I have tried many things but in many cases I said "undefined function" (by using, for example, entity_create) and more evidence I've done.
Example 1:
$new_page_values = array();
$new_page_values['type'] = 'my_content_type';
$new_page_values['title'] = "Titulo";
$new_page_values['path'] = "Path";
$new_page = entity_create('node', $new_page_values);
$new_page->save();
Example 2
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$node = \Drupal\node\Entity\Node::create(array(
'type' => 'article',
'title' => 'The title',
'langcode' => $language,
'uid' => 1,
'status' => 1,
'body' => array('The body text'),
'field_date' => array("2000-01-30"),
//'field_fields' => array('Custom values'), // Add your custon field values like this
));
$node->save();
Example 3:
db_insert('example_entity')
->fields(array(
'type' => $entity->getEntityTypeId(),
'id' => $entity->id(),
'created' => REQUEST_TIME,
'updated' => REQUEST_TIME,
))
->execute();
I'm trying to run a .php file from the server console (php updateData.php)
Thanks and regards.
Javier, the migration in D8 is still a WIP.
My advise:
install the latest Drupal 8.1,
install the latest modules for migrate_tools, migrate_plus, migrate_source_csv and migrate_source_json. Preferably the latest beta-versions.
change your phpAdmin output to a csv-file.
Perhaps you need to create your custom entity. Migrate_tools has 2 examples for the migration. It also contains a csv example. The migration-process should seamlessly import your stuff.
Tips: YAML-files are extremely sensitive for grammatics such as spaces. And you shouldn't have to identify an external/migration database. But remember, what ever worked yesterday, today may be different. I am working on my migration for the last 6 months.
Migration process is a completely different story then the D7 one.
Edited: install Drush 8. Use Composer for the easy way. Drush is needed to run the migration script from commandline, manifest is obsolete.
Edited 2: IMO the best explanation for and why using the D8 migration.
Look at this site https://blog.liip.ch/archive/2016/05/04/using-the-new-drupal-8-migration-api-module.html. Your wish to use your own PHP seems mainly because you can't seem to use D8's migration?
I am migrating a website from Pimcore 3 to 4 (RC1) and I am struggling with the class mappings. Before this was done with a file website/var/config/classmap.xml in the new version there is a file in website/config/classmap.php (different directory and type). I followed the example, and cleared the cache several times (used to be required for Pimcore 3) but it has no effect, the class mappings are not applied. I cannot find any documentation on how to do it in Pimcore 4. The XML used to have a link to documentation in it, that is no longer the case.
This is my classmap.php:
return [
"Object\\Tag" => "Website\\Model\\Tag",
"Object\\Tag\\List" => "Website\\Model\\Tag\\Listing",
"Object\\News" => "Website\\Model\\News",
"Object\\News\\List" => "Website\\Model\\News\\Listing",
"Object\\Column" => "Website\\Model\\Column",
"Object\\Column\\List" => "Website\\Model\\Column\\Listing",
"Object\\Project" => "Website\\Model\\Project",
"Object\\Project\\List" => "Website\\Model\\Project\\Listing",
"Object\\Employee" => "Website\\Model\\Employee",
"Object\\Employee\\List" => "Website\\Model\\Employee\\Listing",
];
I tried digging around the code in pimcore/config/startup.php I found this:
// register class map loader => speed
$autoloaderClassMapFiles = array(
PIMCORE_CONFIGURATION_DIRECTORY . "/autoload-classmap.php",
PIMCORE_PATH . "/config/autoload-classmap.php"
);
I tried renaming the files to autoload-classmap.php but that did not work either.
How do I get this working?
I've been using the filesystem adapter for cacheing data.
E.g..
$cache = StorageFactory::factory(array(
'adapter' => array(
'name' => 'filesystem'
'options' => array('ttl' => 1800, 'cache_dir' => './data/cache'),
),
));
But when using the getItem() function AFTER the TTL clocks over it returns false on success etc, which it should... However, I've noticed that the file remains on the system. Is there a way of forcing the use of the cached file?
Scenario being.. My cache is outdated, when it runs some expensive functions they return nothing or it times out.. So I'd like to use the cache instead!
Just wondering if thats possible?
Thanks!
Here is a useful link to the official ZF2 documentation for the specific StorageAdapter that you are using (filesystem).