Closed elmar001 closed 10 months ago
How are you triggering the queued jobs, via CLI? If so, try running vendor/bin/sake dev/build
before running vendor/bin/sake dev/tasks/ProcessJobQueuetask
. I wonder if it could be because your webserver user and CLI users are different
It is runned by cronjob every minute, not manual. Web server and CLI users are indeed different. However, I have already tested changing all possible permission and ownership and it did not make any difference.
Interesting, now I used vendor/bin/sake dev/build
from CLI and all the issue seems to be resolved. All classes can be initialized now. Thanks heaps man! Previously, I relied on running IP+/dev/build?flush=1
from the browser only. It succeded and did not show any error. My understanding was that there is no difference between them? Or why vendor/bin/sake dev/build
from CLI works but IP+/dev/build?flush=1
from the browser would not?
It’s because in Silverstripe, caches are maintained per-user. So if your webserver user is www-data
and your CLI user is myuser
you’ll have two cache directories - if you create a silverstripe-cache
directory in your document root you’ll see:
/path/to/docroot/silverstripe-cache/www-data/
/path/to/docroot/silverstripe-cache/myuser/
I think this is to prevent issues where, for example, www-data
writes a cache file but myuser
can’t overwrite it as it doesn’t own it. It’s possible to allow that in unix, but it means Silverstripe would need to make assumptions about environment, permissions etc.
We run our cronjobs as the same user as the webserver (e.g. crontab -e -u www-data
), if that’s an option for you it might save future headaches.
Module version(s) affected
5.0.3
Description
Any newly created Silverstripe dataobject can not be initialized or used inside custom class which is extending AbstractQueuedJob and used as a cronjob processor. However, dataobjects which are created before installing symbiote/silverstripe-queuedjobs and have exact same namespaces are fine and work without any issue. There seem to be cached class datamap or something that will not allow new models - dataobjects to be used. This is the error:
[2024-01-28 05:52:04][ERROR] Class "revi\models\Ego" not found {"exception":"[object] (Error(code: 0): Class \"revi\\models\\Ego\" not found at /usr/share/nginx/html/s1/app/src/queueHandlers/SendNotificationJob.php:60)"} []
Now, to narrow down the issue, I have already checked:
$classes = get_declared_classes();
"revi\models\Ego"::get()->byID(1);
"\revi\models\Ego"::get()->byID(1); or \Ego::get()->byID(1);
$targetCategory = new Ego(); echo $targetCategory->byID(1);
- still not working$injector = Injector::inst(); $targetCategory = $injector->get(Ego::class);
- still not working$targetCategory = Ego::singleton()::get()->byID(1);
- still not workingIn the added example code below: ApiLog, Task, CustomLogger are old dataobjects and each oof them works perfectly in the same context with the exact same namespaces. Test class Ego would not work at all.
Plus, I tried to uninstall and reinstall
symbiote/silverstripe-queuedjobs
as a last option and it would not work due to dependencies:How to reproduce
Possible Solution
Assuming there should be a built-in way to update class map, if it is indeed saved in cache or trigger it some way
Additional Context
This the output of composer info: composer info
asyncphp/doorman 4.0.0 Child process management composer/ca-bundle 1.4.0 Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle. composer/installers v2.2.0 A multi-framework Composer library installer doctrine/instantiator 2.0.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 3.0.0 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. egulias/email-validator 4.0.2 A library for validating emails against several RFCs embed/embed v4.4.10 PHP library to retrieve page info using oembed, opengraph, etc guzzlehttp/guzzle 7.8.1 Guzzle is a PHP HTTP client library guzzlehttp/promises 2.0.2 Guzzle promises library guzzlehttp/psr7 2.6.2 PSR-7 message implementation that also provides common utility methods intervention/image 2.7.2 Image handling and manipulation library with support for Laravel integration league/csv 9.14.0 CSV data manipulation made easy in PHP league/flysystem 3.23.0 File storage abstraction for PHP league/flysystem-local 3.23.0 Local filesystem adapter for Flysystem. league/mime-type-detection 1.14.0 Mime-type detection for Flysystem m1/env 2.2.0 Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP. marcj/topsort 2.0.0 High-Performance TopSort/Dependency resolving algorithm masterminds/html5 2.8.1 An HTML5 parser and serializer. ml/iri 1.1.4 IRI handling for PHP ml/json-ld 1.2.1 JSON-LD Processor for PHP monolog/monolog 3.5.0 Sends your logs to files, sockets, inboxes, databases and various web services myclabs/deep-copy 1.11.1 Create deep copies (clones) of your objects nikic/php-parser v4.18.0 A PHP parser written in PHP oscarotero/html-parser v0.1.8 Parse html strings to DOMDocument phar-io/manifest 2.0.3 Component for reading phar.io manifest information from a PHP Archive (PHAR) phar-io/version 3.2.1 Library for handling version information and constraints phpunit/php-code-coverage 9.2.30 Library that provides collection, processing, and rendering functionality for PHP code coverage information. phpunit/php-file-iterator 3.0.6 FilterIterator implementation that filters files based on a list of suffixes. phpunit/php-invoker 3.1.1 Invoke callables with a timeout phpunit/php-text-template 2.0.4 Simple template engine. phpunit/php-timer 5.0.3 Utility class for timing phpunit/phpunit 9.6.16 The PHP Unit Testing framework. psr/cache 3.0.0 Common interface for caching libraries psr/container 2.0.2 Common Container Interface (PHP FIG PSR-11) psr/event-dispatcher 1.0.0 Standard interfaces for event handling. psr/http-client 1.0.3 Common interface for HTTP clients psr/http-factory 1.0.2 Common interfaces for PSR-7 HTTP message factories psr/http-message 1.1 Common interface for HTTP messages psr/log 3.0.0 Common interface for logging libraries psr/simple-cache 3.0.0 Common interfaces for simple caching ralouphie/getallheaders 3.0.3 A polyfill for getallheaders. sebastian/cli-parser 1.0.1 Library for parsing CLI options sebastian/code-unit 1.0.8 Collection of value objects that represent the PHP code units sebastian/code-unit-reverse-lookup 2.0.3 Looks up which function or method a line of code belongs to sebastian/comparator 4.0.8 Provides the functionality to compare PHP values for equality sebastian/complexity 2.0.3 Library for calculating the complexity of PHP code units sebastian/diff 4.0.5 Diff implementation sebastian/environment 5.1.5 Provides functionality to handle HHVM/PHP environments sebastian/exporter 4.0.5 Provides the functionality to export PHP variables for visualization sebastian/global-state 5.0.6 Snapshotting of global state sebastian/lines-of-code 1.0.4 Library for counting the lines of code in PHP source code sebastian/object-enumerator 4.0.4 Traverses array structures and object graphs to enumerate all referenced objects sebastian/object-reflector 2.0.4 Allows reflection of object attributes, including inherited and non-public ones sebastian/recursion-context 4.0.5 Provides functionality to recursively process PHP variables sebastian/resource-operations 3.0.3 Provides a list of PHP built-in functions that operate on resources sebastian/type 3.2.1 Collection of value objects that represent the types of the PHP type system sebastian/version 3.0.2 Library that helps with managing the version number of Git-hosted PHP projects silverstripe/admin 2.0.13 SilverStripe admin interface silverstripe/asset-admin 2.0.4 Asset management for the SilverStripe CMS silverstripe/assets 2.0.6 SilverStripe Assets component silverstripe/campaign-admin 2.0.2 SilverStripe campaign admin interface silverstripe/closure 3.99.99 A library that can be used to serialize closures (anonymous functions) and arbitrary objects. silverstripe/cms 5.0.7 The SilverStripe Content Management System silverstripe/config 2.0.0 SilverStripe configuration based on YAML and class statics silverstripe/errorpage 2.0.2 ErrorPage component for SilverStripe CMS silverstripe/event-dispatcher 1.0.0 Publish and subscribe to events in Silverstripe CMS or your Silverstripe application silverstripe/framework 5.0.23 The SilverStripe framework silverstripe/graphql 5.0.3 GraphQL server for SilverStripe models and other data silverstripe/login-forms 5.0.0 A collection of templates for the CMS login screens silverstripe/mimevalidator 3.0.0 Checks uploaded file content roughly matches a known MIME type for the file extension. silverstripe/recipe-cms 5.0.0 SilverStripe recipe for fully featured page and asset content editing silverstripe/recipe-core 5.0.0 SilverStripe framework-only core recipe silverstripe/recipe-plugin 2.0.0 Helper plugin to install SilverStripe recipes silverstripe/reports 5.0.3 Reports module for SilverStripe CMS silverstripe/session-manager 2.0.2 Allow users to manage and revoke access to multiple login sessions across devices. silverstripe/siteconfig 5.0.2 Site wide settings administration. silverstripe/vendor-plugin 2.0.2 Allows vendor modules to expose directories to the webroot silverstripe/versioned 2.0.2 SilverStripe Versioned component silverstripe/versioned-admin 2.0.4 SilverStripe versioned admin interface sminnee/callbacklist 0.1.1 PHP class that manages a list of callbacks stripe/stripe-php v10.21.0 Stripe PHP Library symbiote/silverstripe-queuedjobs 5.0.3 A framework for defining and running background jobs in a queued manner symfony/cache v6.4.2 Provides extended PSR-6, PSR-16 (and tags) implementations symfony/cache-contracts v3.4.0 Generic abstractions related to caching symfony/config v6.4.0 Helps you find, load, combine, autofill and validate configuration values of any kind symfony/deprecation-contracts v3.4.0 A generic function and convention to trigger deprecation notices symfony/dom-crawler v6.4.0 Eases DOM navigation for HTML and XML documents symfony/event-dispatcher v6.4.2 Provides tools that allow your application components to communicate with each other by dispatching events and listening to them symfony/event-dispatcher-contracts v3.4.0 Generic abstractions related to dispatching event symfony/filesystem v6.4.0 Provides basic utilities for the filesystem symfony/finder v6.4.0 Finds files and directories via an intuitive fluent interface symfony/mailer v6.4.2 Helps sending emails symfony/mime v6.4.0 Allows manipulating MIME messages symfony/polyfill-ctype v1.28.0 Symfony polyfill for ctype functions symfony/polyfill-intl-idn v1.28.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.28.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.28.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php72 v1.28.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/service-contracts v3.4.1 Generic abstractions related to writing services symfony/translation v6.4.2 Provides tools to internationalize your application symfony/translation-contracts v3.4.1 Generic abstractions related to translation symfony/var-exporter v6.4.2 Allows exporting any serializable PHP data structure to plain PHP code symfony/yaml v6.4.0 Loads and dumps YAML files theseer/tokenizer 1.2.2 A small library for converting tokenized PHP source code into XML and potentially other formats ua-parser/uap-php v3.9.14 A multi-language port of Browserscope's user agent parser. webonyx/graphql-php v15.9.1 A PHP port of GraphQL reference implementation
Validations
silverstripe/installer
(with any code examples you've provided)