Query builder not recognize whereIn - mysql

When querying database using query builder, i get an error
Object of class Closure could not be converted to string
// Each type of where clauses has its own compiler function which is responsible
// for actually creating the where clauses SQL. This helps keep the code nice
// and maintainable since each clause has a very small method that it uses.
foreach ($query->wheres as $where)
{
$method = "where{$where['type']}";
$sql[] = $where['boolean'].' '.$this->$method($query, $where);
}
This is the beast that results the error
DB::table('questions')
->join('question_topic', 'question_topic.question_id', '=', 'questions.id')
->join('topics', 'topics.id', '=', 'question_topic.topic_id')
->join('chapters', 'chapters.id', '=', 'topics.chapter_id')
->join('subjects', 'subjects.id', '=', 'chapters.subject_id')
->whereIn('questions.teacher_id', '=', function($query) use ($school_id)
{
$query->select('user_id')
->from('schoolmember_school')
->where('school_id', '=', $school_id);
})
->select('questions.id', 'questions.question',
'topics.id as topic_id', 'chapters.name as chapter_name',
'chapters.class_id', 'subjects.name as subject_name',
'topics.name as topic_name')
->get();
Error:
ErrorException thrown with message "Object of class Closure could not be converted to string"
Stacktrace:
#26 ErrorException in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php:202
#25 Illuminate\Exception\Handler:handleError in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php:202
#24 Illuminate\Database\Query\Grammars\Grammar:compileWheres in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php:60
#23 Illuminate\Database\Query\Grammars\Grammar:compileComponents in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php:38
#22 Illuminate\Database\Query\Grammars\Grammar:compileSelect in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\MySqlGrammar.php:34
#21 Illuminate\Database\Query\Grammars\MySqlGrammar:compileSelect in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1234
#20 Illuminate\Database\Query\Builder:toSql in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1359
#19 Illuminate\Database\Query\Builder:runSelect in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1349
#18 Illuminate\Database\Query\Builder:getFresh in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1336
#17 Illuminate\Database\Query\Builder:get in A:\xampp\htdocs\learnsmart\app\controllers\TeacherController.php:187
#16 TeacherController:school_questions in <#unknown>:0
#15 call_user_func_array in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:231
#14 Illuminate\Routing\Controller:callAction in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:93
#13 Illuminate\Routing\ControllerDispatcher:call in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:62
#12 Illuminate\Routing\ControllerDispatcher:dispatch in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\Router.php:962
#11 Illuminate\Routing\Router:Illuminate\Routing\{closure} in <#unknown>:0
#10 call_user_func_array in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\Route.php:109
#9 Illuminate\Routing\Route:run in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\Router.php:1028
#8 Illuminate\Routing\Router:dispatchToRoute in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Routing\Router.php:996
#7 Illuminate\Routing\Router:dispatch in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:775
#6 Illuminate\Foundation\Application:dispatch in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:745
#5 Illuminate\Foundation\Application:handle in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Session\Middleware.php:72
#4 Illuminate\Session\Middleware:handle in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php:47
#3 Illuminate\Cookie\Queue:handle in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php:51
#2 Illuminate\Cookie\Guard:handle in A:\xampp\htdocs\learnsmart\vendor\stack\builder\src\Stack\StackedHttpKernel.php:23
#1 Stack\StackedHttpKernel:handle in A:\xampp\htdocs\learnsmart\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:641
#0 Illuminate\Foundation\Application:run in A:\xampp\htdocs\learnsmart\public\index.php:49

whereIn() doesn't have a operator! The second argument should be the closure:
->whereIn('questions.teacher_id', function($query) use ($school_id){ /* ... */})

Related

1064:You have an error in your SQL syntax

1064:You have an error in your SQL syntax
Is this error sql injectiable because personally I'm afraid I dont know how to fix it and if it is injectable i need to fix it fast?
1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' or categoryMark like '%'%' or packageName like '%'%')' at line 1 [ SQL ] : select count(id) as count from microvirt_app_i18n where advertiser = 'google' and color0 and countrycode = 'US' and (name like '%'%' or categoryMark like '%'%' or packageName like '%'%')
错误位置
FILE: /var/www/html/home/ThinkPHP/Library/Think/Db/Driver.class.php  LINE: 350
TRACE
#0 /var/www/html/home/ThinkPHP/Library/Think/Db/Driver.class.php(350): E('1064:You have a...')
#1 /var/www/html/home/ThinkPHP/Library/Think/Db/Driver.class.php(180): Think\Db\Driver->error()
#2 /var/www/html/home/ThinkPHP/Library/Think/Model.class.php(1382): Think\Db\Driver->query('select count(id...')
#3 /var/www/html/home/Application/Home/Controller/SearchController.class.php(31): Think\Model->query('select count(id...')
#4 [internal function]: Home\Controller\SearchController->index(''', 'en')
#5 /var/www/html/home/ThinkPHP/Library/Think/App.class.php(171): ReflectionMethod->invokeArgs(Object(Home\Controller\SearchController), Array)
#6 /var/www/html/home/ThinkPHP/Library/Think/App.class.php(110): Think\App::invokeAction(Object(Home\Controller\SearchController), 'index')
#7 /var/www/html/home/ThinkPHP/Library/Think/App.class.php(204): Think\App::exec()
#8 /var/www/html/home/ThinkPHP/Library/Think/Think.class.php(120): Think\App::run()
#9 /var/www/html/home/ThinkPHP/ThinkPHP.php(97): Think\Think::start()
#10 /var/www/html/home/index.php(33): require('/var/www/html/h...')
The error tells you where to look...
near '%' or categoryMark like '%'%' or packageName like '%'%')'
The strings '%'%' have a ' in the middle, which you haven't escaped.
Try '%''%' instead
(Where '' is treated as a literal character, rather than a string terminator).
As for whether it's injectable, any time you substitute strings in to queries, it's injectable.
Use parameterisation instead.
Parameterized queries in PHP with MySQL connection

Cakephp4 don't accept Content Type application/json; charset=utf-8

I upgrade my application from Cakephp3 to cakephp4 but unfortunately I am unable to update the android app accordingly due to logistic issues. The android app makes HTTP calls with Content-Type application/json; charset=utf-8 and cakephp4 keeps throwing bad request. Is there a way to get cakephp4 to accept this header as a stop gap measure before I collect all the tablets and update them accordingly?
Below is the error log:
1) App\Test\TestCase\Controller\Api\EmployeesControllerTest::testJwtTokenPost
Possibly related to Cake\Http\Exception\BadRequestException: "Bad Request"
#0 /var/www/html/vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Http\Middleware\BodyParserMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#1 /var/www/html/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php(166): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#2 /var/www/html/vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Routing\Middleware\RoutingMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#3 /var/www/html/vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php(68): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#4 /var/www/html/vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Routing\Middleware\AssetMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#5 /var/www/html/vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php(121): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#6 /var/www/html/vendor/cakephp/cakephp/src/Http/Runner.php(73): Cake\Error\Middleware\ErrorHandlerMiddleware->process(Object(Cake\Http\ServerRequest), Object(Cake\Http\Runner))
#7 /var/www/html/vendor/cakephp/cakephp/src/Http/Runner.php(58): Cake\Http\Runner->handle(Object(Cake\Http\ServerRequest))
#8 /var/www/html/vendor/cakephp/cakephp/src/Http/Server.php(90): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(App\Application))
#9 /var/www/html/vendor/cakephp/cakephp/src/TestSuite/MiddlewareDispatcher.php(190): Cake\Http\Server->run(Object(Cake\Http\ServerRequest))
#10 /var/www/html/vendor/cakephp/cakephp/src/TestSuite/IntegrationTestTrait.php(499): Cake\TestSuite\MiddlewareDispatcher->execute(Array)
#11 /var/www/html/vendor/cakephp/cakephp/src/TestSuite/IntegrationTestTrait.php(401): App\Test\TestCase\Controller\Api\EmployeesControllerTest->_sendRequest('/api/employees/...', 'POST', Array)
#12 /var/www/html/tests/TestCase/Controller/Api/EmployeesControllerTest.php(41): App\Test\TestCase\Controller\Api\EmployeesControllerTest->post('/api/employees/...', Array)
#13 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php(1415): App\Test\TestCase\Controller\Api\EmployeesControllerTest->testJwtTokenPost()
#14 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php(1035): PHPUnit\Framework\TestCase->runTest()
#15 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php(691): PHPUnit\Framework\TestCase->runBare()
#16 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php(763): PHPUnit\Framework\TestResult->run(Object(App\Test\TestCase\Controller\Api\EmployeesControllerTest))
#17 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(597): PHPUnit\Framework\TestCase->run(Object(PHPUnit\Framework\TestResult))
#18 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(627): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#19 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(204): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, Array, true)
#20 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(163): PHPUnit\TextUI\Command->run(Array, true)
#21 /var/www/html/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#22 {main}
and below is the token method
public function token()
{
$this->getRequest()->allowMethod('post');
$employee = $this->Employees
->find()
->select(['Employees.id','Employees.project_id', 'Employees.name'])
->where(['Employees.pin_code' => $this->request->getData('pin_code')])
->firstOrFail()
->toArray();
$sites = TableRegistry::getTableLocator()->get('Sites');
$currentSite = array('id' => 0, 'name'=> 0);
$currentTransactionId = 0;
$transactions = TableRegistry::getTableLocator()->get('Transactions');
$previousTransaction = $transactions->find()->where([
'Transactions.employee_id' => $employee['id']
])->order([
'Transactions.created' => 'DESC'
])->first();
if(!empty($previousTransaction) && empty($previousTransaction->photo_out)) {
$currentSite = $sites->get($previousTransaction->site_id);
$currentTransactionId = $previousTransaction->id;
}
$this->set([
'success' => true,
'employee' => $employee,
'current_site' => $currentSite,
'sites' => $sites->find()->matching('Projects', function ($q) use ($employee) {
return $q->where(['Projects.id' => $employee["project_id"]]);
}),
'transaction_id' => $currentTransactionId,
'data' => [
'token' => JWT::encode([
'sub' => $employee['id'],
'exp' => time() + 604800
],
Security::getSalt())
],
]);
// Specify which view vars JsonView should serialize.
$this->viewBuilder()->setOption('serialize', ['success', 'employee', 'current_site', 'sites', 'transaction_id', 'data']);
}
and yes the middleware is set up in src/Application.php
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(new ErrorHandlerMiddleware(Configure::read('Error')))
// Handle plugin/theme assets like CakePHP normally does.
->add(new AssetMiddleware([
'cacheTime' => Configure::read('Asset.cacheTime'),
]))
// Add routing middleware.
// If you have a large number of routes connected, turning on routes
// caching in production could improve performance. For that when
// creating the middleware instance specify the cache config name by
// using it's second constructor argument:
// `new RoutingMiddleware($this, '_cake_routes_')`
->add(new RoutingMiddleware($this))
// Parse various types of encoded request bodies so that they are
// available as array through $request->getData()
// https://book.cakephp.org/4/en/controllers/middleware.html#body-parser-middleware
->add(new BodyParserMiddleware())
// Cross Site Request Forgery (CSRF) Protection Middleware
// https://book.cakephp.org/4/en/controllers/middleware.html#cross-site-request-forgery-csrf-middleware
// ->add(new CsrfProtectionMiddleware([
// 'httponly' => false,
// ]))
// Add the middleware to the middleware queue
->add(new AuthenticationMiddleware($this));
return $middlewareQueue;
}
and below is the test method
public function testJwtTokenPost() {
$this->configRequest([
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json; charset=utf-8'
]
]);
// $this->enableCsrfToken();
$this->post('/api/employees/token', [
'pin_code' => '1001'
]);
$this->assertResponseOk();
$this->assertResponseContains('success');
$this->assertResponseContains('employee');
$this->assertResponseContains('current_site');
$this->assertResponseContains('transaction_id');
$this->assertResponseContains('sites');
$this->assertResponseContains('data');
}
Below is my postman json call
When testing non-application/x-www-form-urlencoded requests you must pass the data as a string, as the test case can't reliably make assumptions about how to possibly transform the data into a string itself.
ie, pass a JSON string as POST data, not an array, a string is how application/json data would be exposed by PHP for an actual HTTP request:
$this->post('/api/employees/token', json_encode([
'pin_code' => '1001'
]));
There's no need to further configure the body parser middleware for this, it supports JSON out of the box.

C++ Converting protobuf in json

I'am trying to connect some data from protobuf to json.
This are the relevants parts of my code:
Message* m;
std::string json;
std::string binary_s;
...fill the message...
m->serializeToString(&binary_s);
MessageToJsonString(*m, &json);
The istruction below works fine and produced the expected output.
m->serializeToString(&binary_s);
But when I try to convert it into json, this error always appear:
Program received signal SIGSEGV, Segmentation fault.
google::protobuf::DescriptorPool::FindFileByName (this=0x0, name="FLATBUFFER_DEFINITION.proto") at google/protobuf/descriptor.cc:1415
1415 MutexLockMaybe lock(mutex_);
(gdb) backtrace
#0 google::protobuf::DescriptorPool::FindFileByName (this=0x0, name="AutoPilot.proto")
at google/protobuf/descriptor.cc:1415
#1 0x00007ffff7aba42d in google::protobuf::internal::AssignDescriptors (filename="AutoPilot.proto",
schemas=0x4463a0 <protobuf_AutoPilot_2eproto::schemas>,
default_instances_=0x446500 <protobuf_AutoPilot_2eproto::file_default_instances>,
offsets=0x445c20 <protobuf_AutoPilot_2eproto::TableStruct::offsets>, factory=0x0,
file_level_metadata=0x665020 <protobuf_AutoPilot_2eproto::file_level_metadata>,
file_level_enum_descriptors=0x6651e0 <protobuf_AutoPilot_2eproto::file_level_enum_descriptors>,
file_level_service_descriptors=0x0) at google/protobuf /generated_message_reflection.cc:2316
#2 0x000000000040730c in protobuf_AutoPilot_2eproto::protobuf_AssignDescriptors() ()
#3 0x00007ffff7a24bd5 in google::protobuf::internal::FunctionClosure0::Run (this=0x7fffffffda90)
at ./google/protobuf/stubs/callback.h:129
#4 google::protobuf::GoogleOnceInitImpl (
once=0x665388 <protobuf_AutoPilot_2eproto::protobuf_AssignDescriptorsOnce()::once>, closure=0x7fffffffda90)
at google/protobuf/stubs/once.cc:83
#5 0x0000000000433abb in google::protobuf::GoogleOnceInit(long*, void (*)()) ()
#6 0x0000000000407383 in protobuf_AutoPilot_2eproto::protobuf_AssignDescriptorsOnce() ()
#7 0x0000000000431503 in Message::GetMetadata() const ()
#8 0x00007ffff7b536cc in google::protobuf::Message::GetDescriptor (this=0x68e0b0) at ./google/protobuf/message.h:336
#9 google::protobuf::util::MessageToJsonString (message=warning: RTTI symbol not found for class 'Message'
..., output=0x7fffffffdd60, options=...)
at google/protobuf/util/json_util.cc:217
It seems like it can't find the file "FLATBUFFER_DEFINITION.proto", but it is in the same directory of the executable.
google::protobuf::DescriptorPool::FindFileByName **(**this=0x0**,** name="FLATBUFFER_DEFINITION.proto") at google/protobuf/descriptor.cc:1415
1415 MutexLockMaybe lock(mutex_);
Object pointer is null. I had call ShutdownProtobufLibrary(); and after ,continue using his functions.

Getting exception in editing customer details from admin panel in magento 2

I am attaching the exception log and base URL below
URL:
https://dev.xxxxxxx.com/admin/customer/index/edit/id/12/key/xxxxxxxxxxxxxxxxxxxxxxxx/
EXCEPTION:
1 exception(s):
Exception #0 (BadMethodCallException): Missing required argument $options of Magento\Eav\Model\Entity\Attribute\Source\Config.
Exception #0 (BadMethodCallException): Missing required argument $options of Magento\Eav\Model\Entity\Attribute\Source\Config.
#0 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\Eav\Mod...', Array, Array)
#1 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Eav\Mod...', Array)
#2 /var/www/html/vendor/magento/framework/Validator/UniversalFactory.php(36): Magento\Framework\ObjectManager\ObjectManager->create('Magento\Eav\Mod...', Array)
#3 /var/www/html/vendor/magento/module-eav/Model/Entity/Attribute/AbstractAttribute.php(537): Magento\Framework\Validator\UniversalFactory->create('Magento\Eav\Mod...')
#4 /var/www/html/vendor/magento/module-customer/Model/Customer/DataProvider.php(320): Magento\Eav\Model\Entity\Attribute\AbstractAttribute->getSource()
#5 /var/www/html/vendor/magento/module-customer/Model/Customer/DataProvider.php(152): Magento\Customer\Model\Customer\DataProvider->getAttributesMeta(Object(Magento\Eav\Model\Entity\Type))
#6 /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Magento\Customer\Model\Customer\DataProvider->__construct('customer_form_d...', 'entity_id', 'id', Object(Magento\Ui\DataProvider\EavValidationRules), Object(Magento\Customer\Model\ResourceModel\Customer\CollectionFactory), Object(Magento\Eav\Model\Config), Object(Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool), Array, Array)
#7 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Custome...', Array)
#8 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Custome...', Array)
#9 /var/www/html/vendor/magento/framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php(60): Magento\Framework\ObjectManager\ObjectManager->create('Magento\Custome...', Array)
#10 /var/www/html/var/generation/Magento/Framework/Data/Argument/InterpreterInterface/Proxy.php(95): Magento\Framework\View\Element\UiComponent\Argument\Interpreter\ConfigurableObject->evaluate(Array)
#11 /var/www/html/vendor/magento/framework/Data/Argument/Interpreter/Composite.php(61): Magento\Framework\Data\Argument\InterpreterInterface\Proxy->evaluate(Array)
#12 /var/www/html/vendor/magento/module-ui/Model/Manager.php(188): Magento\Framework\Data\Argument\Interpreter\Composite->evaluate(Array)
#13 /var/www/html/vendor/magento/module-ui/Model/Manager.php(192): Magento\Ui\Model\Manager->evaluateComponentArguments(Array)
#14 /var/www/html/vendor/magento/module-ui/Model/Manager.php(172): Magento\Ui\Model\Manager->evaluateComponentArguments(Array)
This issue occur post migration and i have tried all cache process and deleted that many times so please provide some other good way to fix
In case any other information required let me know.
You can change your \Magento\Eav\Model\Entity\Attribute\Source\Config
from
public function __construct(array $options)
to
public function __construct(array $options = null)
and make a breackpoint at line
$this->_optionsData = $options;
to catch the case when $options is not set. So you would find the corresponding attribute and fix it.
Refer this link :- https://github.com/magento/magento2/issues/10141
This link solved my problem.

Mediawiki dies with FileBackendException: 'Backend with name `shared-backend` already registered'

I am trying to setup Mediawiki. I have confirmed that i am able to load Special pages (any of them), but when it comes to the regular pages the site dies with the following:
Exception encountered, of type "FileBackendException"
[32b52f48] /Main_Page FileBackendException from line 125 of /......../mediawiki/includes/filebackend/FileBackendGroup.php: Backend with name `shared-backend` already registered.
Backtrace:
#0 /......../mediawiki/includes/filebackend/FileBackendGroup.php(109): FileBackendGroup->register(array)
#1 /......../mediawiki/includes/filebackend/FileBackendGroup.php(47): FileBackendGroup->initFromGlobals()
#2 /......../mediawiki/includes/filerepo/FileRepo.php(152): FileBackendGroup::singleton()
#3 /......../mediawiki/includes/filerepo/LocalRepo.php(54): FileRepo->__construct(array)
#4 /......../mediawiki/includes/filerepo/RepoGroup.php(418): LocalRepo->__construct(array)
#5 /......../mediawiki/includes/filerepo/RepoGroup.php(403): RepoGroup->newRepo(array)
#6 /......../mediawiki/includes/filerepo/RepoGroup.php(228): RepoGroup->initialiseRepos()
#7 /......../mediawiki/includes/GlobalFunctions.php(4079): RepoGroup->checkRedirect(Title)
#8 /......../mediawiki/includes/parser/Parser.php(2247): wfIsBadImage(string, Title)
#9 /......../mediawiki/includes/parser/Parser.php(2013): Parser->replaceInternalLinks2(string)
#10 /......../mediawiki/includes/parser/Parser.php(1262): Parser->replaceInternalLinks(string)
#11 /......../mediawiki/includes/parser/Parser.php(439): Parser->internalParse(string)
#12 /......../mediawiki/includes/content/WikitextContent.php(331): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#13 /......../mediawiki/includes/content/AbstractContent.php(497): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
#14 /......../mediawiki/includes/poolcounter/PoolWorkArticleView.php(140): AbstractContent->getParserOutput(Title, integer, ParserOptions)
#15 /......../mediawiki/includes/poolcounter/PoolCounterWork.php(123): PoolWorkArticleView->doWork()
#16 /......../mediawiki/includes/page/Article.php(676): PoolCounterWork->execute()
#17 /......../mediawiki/includes/actions/ViewAction.php(44): Article->view()
#18 /......../mediawiki/includes/MediaWiki.php(490): ViewAction->show()
#19 /......../mediawiki/includes/MediaWiki.php(287): MediaWiki->performAction(Article, Title)
#20 /......../mediawiki/includes/MediaWiki.php(714): MediaWiki->performRequest()
#21 /......../mediawiki/includes/MediaWiki.php(508): MediaWiki->main()
#22 /......../mediawiki/index.php(41): MediaWiki->run()
#23 {main}
Unfortunately there is no documentation that i can find anywhere that deals with this exception apart from this which isn't of much use.
I have tried disabling all of the extensions, thinking that some of them may be at fault, generating some object that needs to remain as a singleton, but that didn't help.
$wgFileBackends is only defined once in DefaultSettings.php.
# grep -R 'wgFileBackends' .
./includes/DefaultSettings.php: * The name "local-fs" should correspond by name to an entry in $wgFileBackends.
./includes/DefaultSettings.php: * #see $wgFileBackends
./includes/DefaultSettings.php: * - backend A file backend name (see $wgFileBackends).
./includes/DefaultSettings.php:$wgFileBackends = array();
./includes/filebackend/FileBackendGroup.php: global $wgLocalFileRepo, $wgForeignFileRepos, $wgFileBackends;
./includes/filebackend/FileBackendGroup.php: $this->register( $wgFileBackends );
./includes/filebackend/README:$wgFileBackends. To access one of those defined backends, one would use
./includes/externalstore/ExternalStoreMwstore.php: * The file backends must be defined in $wgFileBackends and must be global
./tests/phpunit/includes/filebackend/FileBackendTest.php: global $wgFileBackends;
./tests/phpunit/includes/filebackend/FileBackendTest.php: foreach ( $wgFileBackends as $conf ) {
./tests/phpunit/includes/filerepo/StoreBatchTest.php: global $wgFileBackends;
./tests/phpunit/includes/filerepo/StoreBatchTest.php: foreach ( $wgFileBackends as $conf ) {
./tests/phpunit/includes/parser/NewParserTest.php: global $wgFileBackends;
./tests/phpunit/includes/parser/NewParserTest.php: foreach ( $wgFileBackends as $conf ) {
Thanks to Tgr's comments i was able to figure out the answer.
The problem was the $wgForeignFileRepos array that was defined in the LocalSettings.php. It was left from the previous version of Mediawiki, where apparently same names were not the problem.
It is essential that the names given to the cells is different and none can be titled 'shared'. This point is actually made on the $wgForeignFileRepos documentation page:
$wgForeignFileRepos[] = array(
'class' => 'ForeignAPIRepo',
'name' => 'commonswiki', // Must be a distinct name
'apibase' => 'https://commons.wikimedia.org/w/api.php',
'hashLevels' => 2,
...
);