deprecated warnings when using sonata admin bundle - php

I am using symfony2.7 with sonata admin doctrine orm bundle, I followed the official install instructions, works fine except one thing. At every request I get the following debrecated warnings, and I dont know how to eliminate it.
Date: 2016-10-18 08:58:28
Fatal: array(
['type'] => 16384,
['message'] => 'This class is deprecated since 3.2 and will be removed with the 4.0 release.Use Sonata\BlockBundle\Block\Block\Service\AbstractBlockService instead.',
['file'] => '/www/managedoc/branch/hoffereka/app/cache/superadmin_dev/classes.php',
['line'] => 8575,
)
edit: I attached a stack trace
1 in classes.php line 9354
2 at require_once() in ClassCollectionLoader.php line 96
3 at ClassCollectionLoader::load(array('Symfony\Bundle\FrameworkBundle\EventListener\SessionListener', 'Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage', 'Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage', 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler', 'Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy', 'Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', 'Symfony\Component\HttpFoundation\Session\Session', 'Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables', 'Symfony\Bundle\FrameworkBundle\Templating\TemplateReference', 'Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser', 'Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator', 'Symfony\Component\Routing\Generator\UrlGenerator', 'Symfony\Component\Routing\RequestContext', 'Symfony\Component\Routing\Router', 'Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher', 'Symfony\Bundle\FrameworkBundle\Routing\Router', 'Symfony\Component\Config\FileLocator', 'Symfony\Component\Debug\ErrorHandler', 'Symfony\Component\EventDispatcher\Event', 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher', 'Symfony\Component\HttpKernel\EventListener\ResponseListener', 'Symfony\Component\HttpKernel\EventListener\RouterListener', 'Symfony\Component\HttpKernel\Controller\ControllerResolver', 'Symfony\Component\HttpKernel\Event\KernelEvent', 'Symfony\Component\HttpKernel\Event\FilterControllerEvent', 'Symfony\Component\HttpKernel\Event\FilterResponseEvent', 'Symfony\Component\HttpKernel\Event\GetResponseEvent', 'Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent', 'Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent', 'Symfony\Component\HttpKernel\KernelEvents', 'Symfony\Component\HttpKernel\Config\FileLocator', 'Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser', 'Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver', 'Symfony\Component\Security\Http\AccessMap', 'Symfony\Component\Security\Http\Firewall', 'Symfony\Component\Security\Core\User\UserProviderInterface', 'Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager', 'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage', 'Symfony\Component\Security\Core\Authorization\AccessDecisionManager', 'Symfony\Component\Security\Core\Authorization\AuthorizationChecker', 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface', 'Symfony\Bundle\SecurityBundle\Security\FirewallMap', 'Symfony\Bundle\SecurityBundle\Security\FirewallContext', 'Symfony\Component\HttpFoundation\RequestMatcher', 'Twig_Environment', 'Twig_Extension', 'Twig_Extension_Core', 'Twig_Extension_Escaper', 'Twig_Extension_Optimizer', 'Twig_LoaderInterface', 'Twig_Markup', 'Twig_Template', 'Monolog\Formatter\FormatterInterface', 'Monolog\Formatter\LineFormatter', 'Monolog\Handler\HandlerInterface', 'Monolog\Handler\AbstractHandler', 'Monolog\Handler\AbstractProcessingHandler', 'Monolog\Handler\StreamHandler', 'Monolog\Handler\FingersCrossedHandler', 'Monolog\Handler\FilterHandler', 'Monolog\Handler\TestHandler', 'Monolog\Logger', 'Symfony\Bridge\Monolog\Logger', 'Symfony\Bridge\Monolog\Handler\DebugHandler', 'Monolog\Handler\FingersCrossed\ActivationStrategyInterface', 'Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy', 'Symfony\Bundle\AsseticBundle\DefaultValueSupplier', 'Symfony\Bundle\AsseticBundle\Factory\AssetFactory', 'Doctrine\Common\Annotations\DocLexer', 'Doctrine\Common\Annotations\FileCacheReader', 'Doctrine\Common\Annotations\PhpParser', 'Doctrine\Common\Annotations\Reader', 'Doctrine\Common\Lexer', 'Doctrine\Common\Persistence\ConnectionRegistry', 'Doctrine\Common\Persistence\Proxy', 'Doctrine\Common\Util\ClassUtils', 'Doctrine\Bundle\DoctrineBundle\Registry', 'Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener', 'Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener', 'Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DateTimeParamConverter', 'Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter', 'Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface', 'Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager', 'Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener', 'Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener', 'Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener', 'Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation', 'Sonata\CoreBundle\Form\Type\BooleanType', 'Sonata\CoreBundle\Form\Type\CollectionType', 'Sonata\CoreBundle\Form\Type\DateRangeType', 'Sonata\CoreBundle\Form\Type\DateTimeRangeType', 'Sonata\CoreBundle\Form\Type\EqualType', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', 'Sonata\CoreBundle\Form\Type\TranslatableChoiceType', 'Sonata\BlockBundle\Block\BaseBlockService', 'Sonata\BlockBundle\Block\BlockLoaderChain', 'Sonata\BlockBundle\Block\BlockLoaderInterface', 'Sonata\BlockBundle\Block\BlockRenderer', 'Sonata\BlockBundle\Block\BlockRendererInterface', 'Sonata\BlockBundle\Block\BlockServiceInterface', 'Sonata\BlockBundle\Block\BlockServiceManager', 'Sonata\BlockBundle\Block\BlockServiceManagerInterface', 'Sonata\BlockBundle\Block\Loader\ServiceLoader', 'Sonata\BlockBundle\Block\Service\EmptyBlockService', 'Sonata\BlockBundle\Block\Service\RssBlockService', 'Sonata\BlockBundle\Block\Service\MenuBlockService', 'Sonata\BlockBundle\Block\Service\TextBlockService', 'Sonata\BlockBundle\Exception\BlockExceptionInterface', 'Sonata\BlockBundle\Exception\BlockNotFoundException', 'Sonata\BlockBundle\Exception\Filter\DebugOnlyFilter', 'Sonata\BlockBundle\Exception\Filter\FilterInterface', 'Sonata\BlockBundle\Exception\Filter\IgnoreClassFilter', 'Sonata\BlockBundle\Exception\Filter\KeepAllFilter', 'Sonata\BlockBundle\Exception\Filter\KeepNoneFilter', 'Sonata\BlockBundle\Exception\Renderer\InlineDebugRenderer', 'Sonata\BlockBundle\Exception\Renderer\InlineRenderer', 'Sonata\BlockBundle\Exception\Renderer\MonkeyThrowRenderer', 'Sonata\BlockBundle\Exception\Renderer\RendererInterface', 'Sonata\BlockBundle\Exception\Strategy\StrategyManager', 'Sonata\BlockBundle\Exception\Strategy\StrategyManagerInterface', 'Sonata\BlockBundle\Form\Type\ServiceListType', 'Sonata\BlockBundle\Model\BaseBlock', 'Sonata\BlockBundle\Model\Block', 'Sonata\BlockBundle\Model\BlockInterface', 'Sonata\BlockBundle\Model\BlockManagerInterface', 'Sonata\BlockBundle\Model\EmptyBlock', 'Sonata\BlockBundle\Twig\Extension\BlockExtension', 'Sonata\BlockBundle\Twig\GlobalVariables', 'Sonata\AdminBundle\Admin\AbstractAdmin', 'Sonata\AdminBundle\Admin\AbstractAdminExtension', 'Sonata\AdminBundle\Admin\AdminExtensionInterface', 'Sonata\AdminBundle\Admin\AdminHelper', 'Sonata\AdminBundle\Admin\AdminInterface', 'Sonata\AdminBundle\Admin\BaseFieldDescription', 'Sonata\AdminBundle\Admin\FieldDescriptionCollection', 'Sonata\AdminBundle\Admin\FieldDescriptionInterface', 'Sonata\AdminBundle\Admin\Pool', 'Sonata\AdminBundle\Block\AdminListBlockService', 'Sonata\AdminBundle\Builder\DatagridBuilderInterface', 'Sonata\AdminBundle\Builder\FormContractorInterface', 'Sonata\AdminBundle\Builder\ListBuilderInterface', 'Sonata\AdminBundle\Builder\RouteBuilderInterface', 'Sonata\AdminBundle\Builder\ShowBuilderInterface', 'Sonata\AdminBundle\Datagrid\Datagrid', 'Sonata\AdminBundle\Datagrid\DatagridInterface', 'Sonata\AdminBundle\Datagrid\DatagridMapper', 'Sonata\AdminBundle\Datagrid\ListMapper', 'Sonata\AdminBundle\Datagrid\Pager', 'Sonata\AdminBundle\Datagrid\PagerInterface', 'Sonata\AdminBundle\Datagrid\ProxyQueryInterface', 'Sonata\AdminBundle\Exception\ModelManagerException', 'Sonata\AdminBundle\Exception\NoValueException', 'Sonata\AdminBundle\Filter\Filter', 'Sonata\AdminBundle\Filter\FilterFactory', 'Sonata\AdminBundle\Filter\FilterFactoryInterface', 'Sonata\AdminBundle\Filter\FilterInterface', 'Sonata\AdminBundle\Form\DataTransformer\ArrayToModelTransformer', 'Sonata\AdminBundle\Form\DataTransformer\ModelsToArrayTransformer', 'Sonata\AdminBundle\Form\DataTransformer\ModelToIdTransformer', 'Sonata\AdminBundle\Form\EventListener\MergeCollectionListener', 'Sonata\AdminBundle\Form\Extension\Field\Type\FormTypeFieldExtension', 'Sonata\AdminBundle\Form\FormMapper', 'Sonata\AdminBundle\Form\Type\AdminType', 'Sonata\AdminBundle\Form\Type\Filter\ChoiceType', 'Sonata\AdminBundle\Form\Type\Filter\DateRangeType', 'Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType', 'Sonata\AdminBundle\Form\Type\Filter\DateTimeType', 'Sonata\AdminBundle\Form\Type\Filter\DateType', 'Sonata\AdminBundle\Form\Type\Filter\DefaultType', 'Sonata\AdminBundle\Form\Type\Filter\NumberType', 'Sonata\AdminBundle\Form\Type\ModelReferenceType', 'Sonata\AdminBundle\Form\Type\ModelType', 'Sonata\AdminBundle\Form\Type\ModelListType', 'Sonata\AdminBundle\Guesser\TypeGuesserChain', 'Sonata\AdminBundle\Guesser\TypeGuesserInterface', 'Sonata\AdminBundle\Model\AuditManager', 'Sonata\AdminBundle\Model\AuditManagerInterface', 'Sonata\AdminBundle\Model\AuditReaderInterface', 'Sonata\AdminBundle\Model\ModelManagerInterface', 'Sonata\AdminBundle\Route\AdminPoolLoader', 'Sonata\AdminBundle\Route\DefaultRouteGenerator', 'Sonata\AdminBundle\Route\PathInfoBuilder', 'Sonata\AdminBundle\Route\QueryStringBuilder', 'Sonata\AdminBundle\Route\RouteCollection', 'Sonata\AdminBundle\Route\RouteGeneratorInterface', 'Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap', 'Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder', 'Sonata\AdminBundle\Security\Handler\AclSecurityHandler', 'Sonata\AdminBundle\Security\Handler\AclSecurityHandlerInterface', 'Sonata\AdminBundle\Security\Handler\NoopSecurityHandler', 'Sonata\AdminBundle\Security\Handler\RoleSecurityHandler', 'Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface', 'Sonata\AdminBundle\Show\ShowMapper', 'Sonata\AdminBundle\Translator\BCLabelTranslatorStrategy', 'Sonata\AdminBundle\Translator\FormLabelTranslatorStrategy', 'Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface', 'Sonata\AdminBundle\Translator\NativeLabelTranslatorStrategy', 'Sonata\AdminBundle\Translator\NoopLabelTranslatorStrategy', 'Sonata\AdminBundle\Translator\UnderscoreLabelTranslatorStrategy', 'Sonata\AdminBundle\Twig\Extension\SonataAdminExtension', 'Sonata\AdminBundle\Util\AdminAclManipulator', 'Sonata\AdminBundle\Util\AdminAclManipulatorInterface', 'Sonata\AdminBundle\Util\FormBuilderIterator', 'Sonata\AdminBundle\Util\FormViewIterator', 'Sonata\AdminBundle\Util\ObjectAclManipulator', 'Sonata\AdminBundle\Util\ObjectAclManipulatorInterface'), '/www/managedoc/branch/hoffereka/app/cache/superadmin_dev', 'classes', true, false, '.php') in bootstrap.php.cache line 2609
4 at Kernel->doLoadClassCache('classes', '.php') in bootstrap.php.cache line 2444
5 at Kernel->boot() in bootstrap.php.cache line 2478
6 at Kernel->handle(object(Request)) in app_dev.php line 34
7 at require_once('/www/managedoc/branch/hoffereka/web/app_dev.php') in app_superadmin_dev.php line 3

What happens is not necessarily your fault. As you can see here, the problem comes from a deprecation in the block bundle. Maybe the admin bundle (or some other bundle) is using it for some purpose and hasn't yet followed the deprecation recommendation.
Let's first fix the errors in the deprecation messages and make them more precise.
Digging more, you can see that 3.9.0 is supposed to fix this problem.
Can you run composer info to show us what version of the admin bundle you use?

Related

The $MetaTags(false) variable breaks the page (SilverStripe 3.7.1)

(First of all I'm still trying to figure my way around in SilverStripe so please be gentle)
I'm having a problem with one of the pages on a site where the error is:
[User Error] Uncaught Error: Call to a member function RelativeLink() on null
This is happening in Line 522 in SiteTree.php which has not been altered in any way.
516 if($this->ParentID && self::config()->nested_urls) {
517 $parent = $this->Parent();
518 // If page is removed select parent from version history (for archive page view)
519 if((!$parent || !$parent->exists()) && $this->IsDeletedFromStage) {
520 $parent = Versioned::get_latest_version('SiteTree', $this->ParentID);
521 }
522 $base = $parent->RelativeLink($this->URLSegment);
523 } elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
524 // Unset base for root-level homepages.
525 // Note: Homepages with action parameters (or $action === true)
526 // need to retain their URLSegment.
527 $base = null;
528 }
After looking at the stack-trace I figured I would look in the Head.ss file and tried to comment out things in order to narrow down my search. So I found out that if I remove the $MetaTags(false) variable in Head.ss everything is working fine.
Trace:
SiteTree->RelativeLink()
SiteTree.php:468
SiteTree->Link()
SiteTree.php:484
SiteTree->AbsoluteLink()
Translatable.php:1583
Translatable->MetaTags(http://silverstripe.org" /> ,,,,,,)
Object.php:1068
SS_Object->extend(MetaTags,http://silverstripe.org" /> )
SiteTree.php:1429
SiteTree->MetaTags(false)
Object.php:746
SS_Object->__call(metatags,Array)
ViewableData.php:466
ViewableData->obj(MetaTags,Array,,1)
ViewableData.php:539
ViewableData->XML_val(MetaTags,Array,1)
SSViewer.php:187
SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:650
SSViewer_DataPresenter->__call(XML_val,Array)
.cache.themes.express.templates.Includes.Head.ss:23
include(/var/www/jackon.no/silverstripe-cache/www-data-php7.0.30-0ubuntu0.16.04.1/.cache.themes.express.templates.Includes.Head.ss)
SSViewer.php:1172
SSViewer->includeGeneratedTemplate(/var/www/jackon.no/silverstripe-cache/www-data-php7.0.30-0ubuntu0.16.04.1/.cache.themes.express.templates.Includes.Head.ss,Product_Controller,Array,Array,SSViewer_DataPresenter)
SSViewer.php:1234
SSViewer->process(Product_Controller,Array,SSViewer_DataPresenter)
SSViewer.php:1273
SSViewer::execute_template(Head,Product_Controller,Array,SSViewer_DataPresenter)
.cache.themes.express.templates.Page.ss:2
include(/var/www/jackon.no/silverstripe-cache/www-data-php7.0.30-0ubuntu0.16.04.1/.cache.themes.express.templates.Page.ss)
SSViewer.php:1172
SSViewer->includeGeneratedTemplate(/var/www/jackon.no/silverstripe-cache/www-data-php7.0.30-0ubuntu0.16.04.1/.cache.themes.express.templates.Page.ss,Product_Controller,,Array,)
SSViewer.php:1234
SSViewer->process(Product_Controller)
Controller.php:201
Controller->handleAction(SS_HTTPRequest,index)
RequestHandler.php:208
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:151
Controller->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:174
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:154
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:154
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ModelAsController.php:75
ModelAsController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:385
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:149
Director::direct(/bygg/jackon-thermomur/thermomur-350-super/,DataModel)
main.php:194
There is only one page out of many not working and when I try to see what the $MetaTags(false) outputs on one of the working pages it is three <link rel="alternate" ...> tags giving a link to the same page in three different languages.
I would love to get some help on how I can locate and fix the problem. I can't really understand how line 522 could go wrong with the if-conditional in line 519.
The page does have a parent and looks exactly the same as a page with the same parent except for changes in the content like text.

constant errors using insights Facebook marketing api (php)

I get this error when I try to run my app locally via xampp. Just to note, I generated code using quick start from developers.facebook so there shouldnt be errors within the code itself.
Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Logger\CurlLogger.php on line 83
Warning: fwrite() expects parameter 1 to be resource, string given in C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Logger\CurlLogger.php on line 182
Fatal error: Uncaught exception 'FacebookAds\Http\Exception\AuthorizationException' with message '(#100) Filtering field delivery_info is invalid. Please refer to the document https://developers.facebook.com/docs/marketing-api/insights for valid filters.' in C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Http\Exception\RequestException.php:144 Stack trace: #0 C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Http\Client.php(215): FacebookAds\Http\Exception\RequestException::create(Object(FacebookAds\Http\Response)) #1 C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Http\Request.php(282): FacebookAds\Http\Client->sendRequest(Object(FacebookAds\Http\Request)) #2 C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Api.php(162): FacebookAds\Http\Request->execute() #3 C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Api.php(204): FacebookAds\Api->executeRequest(Object(FacebookAds\Http\Request)) #4 C:\xampp\htdocs\working\vendor\facebo in C:\xampp\htdocs\working\vendor\facebook\php-ads-sdk\src\FacebookAds\Http\Exception\RequestException.php on line 144
I'm starting to suspect that I got the wrong files from the composer. or there might be a problem with my setup. The contents of my composer.json just before I ran composer.phar was
{
"require": {
"facebook/php-sdk-v4" : "~5.0",
"facebook/php-ads-sdk": "2.10.*"
}
}
I'm going to attach the code below just in case you guys want to look at it as well. The only thing that I modified there is adding the app_id since it was not included from the generated code.
<?php
require __DIR__ . '/vendor/autoload.php';
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdsInsights;
use FacebookAds\Api;
use FacebookAds\Logger\CurlLogger;
$app_id = '274807576345457';
$access_token = 'EAAD575ZC4O3EBAChoTmxC0nwdbvjXLRUKGGXgmZA6HZBFjmKZB6F3olMIe2mG2dgQSb9SudtN7EeeO8gzo7zgFZB0EHZAwTrg4wsIKsJxB3bhw5fonZC3YCZA0C4InaCSOgW42i4PswQa3BZCctMZBYTh94TwGLxGg8gZAZAj4zZC5PfgXl0kw6eOuxW4g1L41NOwtRDGS7O7FsJZBWZCM0IAe00WSf';
$ad_account_id = 'act_113902719358005';
$app_secret = 'aeb42f19e0f33f0937c023fff12909c4';
$api = Api::init($app_id, $app_secret, $access_token);
$api->setLogger(new CurlLogger());
$fields = array(
'cost_per_result',
'cost_per_total_action',
'cpm',
'cpp',
'frequency',
'impressions',
'impressions_auto_refresh',
'impressions_gross',
'reach',
'relevance_score:score',
'relevance_score:positive_feedback',
'relevance_score:negative_feedback',
'result_rate',
'results',
'social_impressions',
'social_reach',
'spend',
'today_spend',
'total_actions',
'total_unique_actions',
'actions:video_view',
'video_10_sec_watched_actions:video_view',
'delivery',
);
$params = array(
'level' => 'campaign',
'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('active','limited'))),
'breakdowns' => array(),
'time_range' => array('since' => '2017-09-28','until' => '2017-09-29'),
);
echo json_encode((new AdAccount($ad_account_id))->getInsights(
$fields,
$params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);
if comment this part
[json_encode((new AdAccount($ad_account_id))->getInsights(
$fields,
$params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);]
; the error stop.
if make [var_export((new AdAccount($ad_account_id));] show full array
I experienced the exact same error. I believe (in my case) this was because I was also using an older PHP version (5.6) resulting in some compatibility issues.
I solved this by changing the version of php-ads-sdk from 2.8 to "8.*" (or change it to any recent version according to when you are reading this solution) in composer.json.
Then call sudo composer update in your terminal

Amazon S3 and Yii2

I created a code to use Amazon S3 using this composer component:
https://github.com/2amigos/yii2-resource-manager-component
This worked very well.
But I changed my server and when I upload a image to Amazon S3 I received this error:
PHP Fatal Error – yii\base\ErrorException
Class 'Aws\S3\Enum\CannedAcl' not found
I did not change anything of code, I dont understand why this error, I cant find a solution
How can I fix it?
This is the complete error :
PHP Fatal Error – yii\base\ErrorException
Class 'Aws\S3\Enum\CannedAcl' not found
1. in /opt/app-root/src/admapps/vendor/2amigos/yii2-resource-manager-component/AmazonS3ResourceManager.php at line 78
69707172737475767778798081828384858687 * #return \Guzzle\Service\Resource\Model
*/
public function save($file, $name, $options = [])
{
$options = ArrayHelper::merge([
'Bucket' => $this->bucket,
'Key' => $name,
'SourceFile' => $file->tempName,
'ACL' => CannedAcl::PUBLIC_READ // default to ACL public read
], $options);
$this->getClient()->putObject($options);
}
/**
* Removes a file
* #param string $name the name of the file to remove
* #return boolean
*/
2. in /opt/app-root/src/admapps/vendor/yiisoft/yii2/base/InlineAction.php at line 55 – app\controllers\BeersController::actionUploadlogobeer()
3. in /opt/app-root/src/admapps/vendor/yiisoft/yii2/base/InlineAction.php at line 55 – call_user_func_array:{/opt/app-root/src/admapps/vendor/yiisoft/yii2/base/InlineAction.php:55}()
4. in /opt/app-root/src/admapps/vendor/yiisoft/yii2/base/Controller.php at line 154 – yii\base\InlineAction::runWithParams()
5. in /opt/app-root/src/admapps/vendor/yiisoft/yii2/base/Module.php at line 454 – yii\base\Controller::runAction()
6. in /opt/app-root/src/admapps/vendor/yiisoft/yii2/web/Application.php at line 87 – yii\base\Module::runAction()
7. in /opt/app-root/src/admapps/vendor/yiisoft/yii2/base/Application.php at line 375 – yii\web\Application::handleRequest()
8. in /opt/app-root/src/admapps/web/index.php at line 13 – yii\base\Application::run()
78910111213require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../helpers/Utils.php');
$config = require(__DIR__ . '/../config/web.php');
(new yii\web\Application($config))->run();
Posted by Bizley
This extension uses "aws/aws-sdk-php": "2.5.2" and it's very old (at GitHub version 3.18 is latest). AWS said they've removed CannedAcl in version 3 so it should not make impact on 2.5.2 (it is present in 2.5.2). Anyway there is the same issue reported about this github.com/2amigos/yii2-resource-manager-component/issues/10 – Bizley

"Constant CRLF already defined" error when using php-resque with Laravel

I'm running php-resque together with Laravel 3 on Ubuntu 12.04.
Problem: When a job is enqueued in resque, I get the following error:
Unhandled Exception
Message:
Constant CRLF already defined
Location:
/var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php on line 10
What does the error mean and how can we solve it?
PHP
// Enqueue in Resque
$data = array(
'name' => $name,
'email' => $email,
'created_at' => DB::raw('NOW()')
);
Resque::enqueue('queue', 'exampleWorker', $data);
However when I try to enqueue a job using artisan, it works!
Task
class Queue_Task
{
public function run()
{
// Autoload composer vendors.
require path('composer').DS.'autoload.php';
$args = array('name' => 'John Smith');
Resque::enqueue('MyAppName', 'ExampleWorker', $args);
echo "Resque job queued.\n";
return;
}
}
Output
PHP Notice: Constant CRLF already defined in /var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php on line 10
Notice: Constant CRLF already defined in /var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php on line 10
Resque job queued.
It's a guess, but I'd say in /var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php there's a second define('CRLF', 'something') on line 10 that should probably be commented out if you want these two pieces of software to work together.

Problems trying to use the Kohana pagination module

I have downloaded the Kohana Pagination module from Git and have been having some issues trying to use it.
I moved it into the modules folder and have updated my bootstrap to include the module...
'pagination' => MODPATH.'kohana-pagination',
I have the following code that loads some messages from a simple table with pagination...
public function action_index()
{
$content = View::factory('welcome')
->bind('messages', $messages)
->bind('pager_links', $pager_links);
$message = new Model_Message;
$message_count = $message->count_all();
$pagination = Pagination::factory(array(
'total_items' => $message_count,
'items_per_page' => 3,
));
$pager_links = $pagination->render();
$messages = $message->get_all($pagination->items_per_page, $pagination->offset);
$this->template->content = $content;
}
When I run load this in my browser, I get the following error message...
ErrorException [ Fatal Error ]: 1Call to undefined method Kohana::config()
MODPATH\kohana-pagination\classes\kohana\pagination.php [ 87 ]
82 * #return array config settings
83 */
84 public function config_group($group = 'default')
85 {
86 // Load the pagination config file
87 $config_file = Kohana::config('pagination');
88
89 // Initialize the $config array
90 $config['group'] = (string) $group;
91
92 // Recursively load requested config groups
{PHP internal call} » Kohana_Core::shutdown_handler()
If I remove the code relating to the pagination, the page loads the data fine from the database. Any pointers here would be great.
Update
Found this link: https://github.com/kloopko/kohana-pagination, on the back of Ikke, so cheers for the help folks.
Appears that the previously bundled pagination module has been removed, found the kohana-pagination module which has been updated to cater for 3.2.
Hope that helps someone else just starting out. :)
The issue is just the config system has changed for version 3.2. Most modules can be fixed by simply updating
$config_file = Kohana::config('pagination');
to
$config_file = Kohana::$config->load('pagination');
Let me update you the steps to resolve with Kohana paging.
Go to modules/pagination/classes/kohana/pagination.php
Change the
$config_file = Kohana::config('pagination');
to
$config_file = Kohana::$config->load('pagination');
in the same page at the line 199
change this line to
return URL::site(Request::current()->uri).URL::query(array($this->config['current_page']['key'] => $page));
to
return URL::site(Request::current()->uri()).URL::query(array($this->config['current_page']['key'] => $page));
Add uri braces.
This resolved my issue. thank you.

Categories